
function winOpener(sUrl, sWinName, sWinWidth, sWinHeight){
window.open(sUrl, sWinName,'toolbar=no,width='+ sWinWidth +',height='+ sWinHeight +',directories=no,status=no,scrollbars=yes,resize=no,menubar=no')
}

function SelectSORT(form){
var index2=form.cboSortiment.selectedIndex;
window.location.href = form.cboSortiment.options[index2].value;
}

function SelectNext(){
var form = document.productview;
var index2=(form.cboSortiment.selectedIndex+1);
window.location.href = form.cboSortiment.options[index2].value;
}

function SelectPrev(){
var form = document.productview;
var index2=(form.cboSortiment.selectedIndex-1);
window.location.href = form.cboSortiment.options[index2].value;
}

function ProToBasket(sProID, sLang){
var nRecepient = sLang;

if(sProID != ""){
	x = 0;
	y = 0;
	strProVariant = "";
	strProOptional = "";
	nQty = "1";
	objForm = document.productview;

	for(i = 0; i < objForm.elements.length; i++){
		objCtrl = objForm.elements[i];

		if(objCtrl.type != "hidden" && objCtrl.name == sProID){
			var optProVariant = objCtrl.selectedIndex;
			var nProVarID = objCtrl.options[optProVariant].value;
			x = x+1;
			strProVariant = strProVariant + chrSep(x) + nProVarID
			}

		if(objCtrl.type == "checkbox" && objCtrl.checked == true){
			var nProOptID = objCtrl.value;
			y = y+1;
			strProOptional = strProOptional + chrSep(y) + nProOptID
			}

		if(objCtrl.type == "text"){
			nFldName = objCtrl.name;
			nFldSplit = nFldName.split("_");
			nFldID = nFldSplit[1];

			if(nFldID == sProID){
				var iCount = objCtrl.value.length;
				if(iCount > "0"){
					for(pos=0; pos<iCount; pos++){
						if (objCtrl.value.charAt(pos) < "0" || objCtrl.value.charAt(pos) > "9"){
							compose('errProQuantityFalse',objCtrl.name);
							return;
							}
						}
					}
				else{
					compose('errProQuantityFalse',objCtrl.name);
					return;					
					}
				nQty = objCtrl.value;
				}
			}
		}
	document.frmAryPro.aryProID.value = sProID;
	document.frmAryPro.aryProVariant.value = strProVariant;
	document.frmAryPro.aryProOptional.value = strProOptional;
	document.frmAryPro.txtMenge.value = nQty;

	document.frmAryPro.action = nRecepient;
	document.frmAryPro.submit();
	}
}

function chrSep(x){
	if(x > 1)
		{strSep = ", ";}
	else
		{strSep = "";}
return strSep;
}

function proQuantity(txtAlert,vTyp,vFieldName,vQuantity){
	if (vTyp == "add")
	{
	vQuantity++;
		{vFieldName.value = vQuantity;}
	}
	
	if (vTyp == "sub")
		{
		if (vQuantity == '1')
			{alert(txtAlert)}
		else
			{
			vQuantity--;
				{vFieldName.value = vQuantity;}
			}
		}
}

function OptProMark(sProID){
nFldID = eval('opener.document.productview.'+ sProID);
nFldID.checked = true;
window.close();
}

function custom_print(){
    if (document.all) {
        if (navigator.appVersion.indexOf("5.0") == -1) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(6, 2);
            WebBrowser1.outerHTML = "";
        } else {
            self.print();
        }
    } else {
        self.print();
    }
}