/* General --- Start */

function itwAddLoadEvent(strNewFunc) 
{
	if(strNewFunc.indexOf("(") == -1 && strNewFunc.indexOf(")") == -1)
	{
		strNewFunc = strNewFunc + "()";
	}
	var objOldOnload = window.onload;
	if (typeof window.onload == 'function') 
	{
		window.onload = function() 
		{	
			objOldOnload();
			eval(strNewFunc);
		}
	}
	else
	{
		window.onload = function() 
		{	
			eval(strNewFunc);
		}
	}
}

/* General --- End */

/* Scripts for ShopProductDetail.xsl --- Start */

function ottSubmitShopProductDetail(strAction, hasInCart, msg) {
	if (strAction != ''){
		if (strAction == 'default.asp?C=UserShoppingCartAdd' && hasInCart == 1)
		{
			if (confirm(msg))
			{
				document.frmAddToShoppingCart.action = strAction;
				document.frmAddToShoppingCart.submit();
			}

		}
		else
		{
			document.frmAddToShoppingCart.action = strAction;
			document.frmAddToShoppingCart.submit();
		}
	}
/* old code */
/*	document.frmAddToShoppingCart.optAction.selectedIndex = 0 */
}

function ottTermsShopProductDetail(){
    gintError = 0 
    var strErrorMessage = ''
    var blnTerms = document.frmAddToShoppingCart.chkTerms.checked
    var intDelivery = document.frmAddToShoppingCart.optDelivery.value
	var intPayment = document.frmAddToShoppingCart.optPayment.value
	if (blnTerms == false){
		gintError = gintError+1
		strErrorMessage += gintError + '. '+ gstrNoTerms + '\n'
	}
	if (intDelivery == 0){
		gintError = gintError+1
		strErrorMessage += gintError + '. '+ gstrNoDelivery + '\n'
	}
	if (intPayment == 0){
		gintError = gintError+1
		strErrorMessage += gintError + '. '+ gstrNoPayment + '\n'
	}
	if (gintError > 0){
		alert(strErrorMessage)
	}
}

function ottLoadPic(intDirection) {
	if (gintLastPic == gastrPic.length-1 && intDirection == 1)
		intCurPic = 0
	else if (gintLastPic == 0 && intDirection == -1) 
		intCurPic = gastrPic.length-1
	else 
		intCurPic = gintLastPic + intDirection

		
	if (DOM) {
		if (gastrPicWidth[intCurPic] > 150)
			{document.getElementById(gstrImageName).setAttribute("width", gastrPicWidth[intCurPic]);}
		else
			{document.getElementById(gstrImageName).setAttribute("width", "");};
		document.getElementById(gstrImageName).setAttribute("src", gastrPic[intCurPic]);
		document.getElementById("divPicDesc").firstChild.nodeValue = gastrPicDesc[intCurPic]
	}
	 
	if (MS && !DOM) {
		objPicLayer = eval("document.all."+gstrPicLayer)
		if (gastrPicWidth[intCurPic] > 150)
			{objPicLayer.innerHTML = '<img src=" '+gastrPic[intCurPic]+' " width="150"/>'}
		else
			{objPicLayer.innerHTML = '<img src=" '+gastrPic[intCurPic]+' "/>'};
	}
	 
	if (NS && !DOM) {
		objPicLayer = eval("document."+gstrPicLayer)
		if (gastrPicWidth[intCurPic] > 150)
			{test='<img src=" '+gastrPic[intCurPic]+' " width="150"/>'}
		else
			{test='<img src=" '+gastrPic[intCurPic]+' "/>'};
		document.divPicLayer.document.open()
		document.divPicLayer.document.write(test)
		document.divPicLayer.document.close()
	}
	gintLastPic = intCurPic
}

function itwShowPic(strPicPath,strCss){
		/*strClose='schlie&#223;en'
		F1 = window.open("","Detail","width=340,height=350,left=0,top=0,resizable=yes,scrollbars=yes");
		var strCloseButton = '	<input type="button" name="Close" value="' + strClose + '" onclick="javascript:window.close()" class="ShopSortButton"/>';
		var strImage = '<img src="'+strPicPath+'"/>';
		var strHead = '<html><link rel="stylesheet" type="text/css" href="' +strCss + '"/><body class="b13">';
		var strDiv = '<div id="PicContainer"  style="position:absolute;text-align:center;vertical-align:bottom ;padding:0px;width:100%;height:100%;">';
		var strObj = strHead + strDiv + strImage + '<br/><br/>' + strCloseButton + '</div></body></html>';
		F1.document.write(strObj );*/
		F1 = window.open(strPicPath,"Detail","width=450,height=450,left=0,top=0,resizable=yes,scrollbars=yes");
}

/* Scripts for ShopProductDetail.xsl --- End */


/* Scripts for UserShoppingCard.xsl --- Start */

function ottUserShoppingCardSubmit(rintAction) {
	var objCurForm = eval("document."+gstrFormName)
	for (i=0;i < gaintID.length;i++) {
		var objHidden = eval("document."+gstrFormName+"."+gastrChkName[rintAction]+gaintID[i])
		var objAction = eval("document."+gstrFormName+"."+gstrChkSource +gaintID[i])
		if (objAction.checked == true)
			objHidden.value=1
		else
			objHidden.value=0
	}
	objCurForm.action =gastrLink[rintAction]
	objCurForm.submit();
}

/* Scripts for UserShoppingCard.xsl --- End */


/* Scripts for UserShoppingListDetail.xsl --- Start */

function ottUserShoppingListDetailAction(rintAction){
	var intCount = 0
	var objCurForm = eval("document."+gstrFormName)
	var objSet1 = eval("document."+gstrFormName+"."+gastrChkName[1])
	var objSet2 = eval("document."+gstrFormName+"."+gastrChkName[2])
	for (i=0;i < gaintID.length;i++) {
		var objHidden1 = eval("document."+gstrFormName+"."+gastrChkName[1]+gaintID[i])
		var objHidden2 = eval("document."+gstrFormName+"."+gastrChkName[2]+gaintID[i])
		intIDOffer = objHidden1.value
		var objHidden3 = eval("document."+gstrFormName+"."+gastrChkName[3]+intIDOffer)
		objHidden3.value = 0
		var objAction = eval("document."+gstrFormName+"."+gstrChkSource +gaintID[i])
		
		if (objAction.checked == true){
			intCount = intCount+1
			objSet1.value = objHidden1.value
			objSet2.value = objHidden2.value
			
			objHidden3.value = 1
		}
	}
    if (intCount == 1){
		objCurForm.action =gastrLink[rintAction]
		objCurForm.submit();
	}
	else if (rintAction == 4){
		objCurForm.action =gastrLink[rintAction]
		objCurForm.submit();
	}
	else if (intCount > 1)
		alert(strError)
	
	document.frmShopListDetail.selAction.selectedIndex = 0
}

/* Scripts for UserShoppingListDetail.xsl --- End */


/* Scripts for ShopSearchForProductSpecialForm.xsl --- Start */

function ottSearchForProdSpecial() {
	if (document.frmSearchSpecial.txtSearchString.value=='')
	{
		alert(strErrMsg1);
		document.frmSearchSpecial.txtSearchString.focus();
		return;
	}
	document.frmSearchSpecial.submit();
}
function ottLoadRegionsForProdSpecial(strAction) {
	document.frmSearchSpecial.action=strAction;
	document.frmSearchSpecial.submit();
}
function ottLoadBranchesForProdSpecial(strAlphabet) {
	document.frmSearchSpecial.idAlphabet.value = strAlphabet;
	document.frmSearchSpecial.action = 'default.asp?C=ShopSearchForProductSpecialForm';
	document.frmSearchSpecial.submit();
}
function ottCheckBoxes(pstrName,pintType){
	if (pintType==1) {
		for (i=1; i < 100;i++) {
			objChkBox = eval("document.getElementsByName('" +pstrName+ "')" + "[" +i+ "]");
			if (objChkBox)
				objChkBox.checked = 0
		}
	}
	if (pintType==2) {
		objChkBox=eval("document.getElementById('" +pstrName+ 0 + "')")
		objChkBox.checked = 0
	}

}

/* Scripts for ShopSearchForProductSpecialForm.xsl --- End */



/* Scripts for ShopSearchForShopSpecialForm.xsl --- Start */

function ottSearchForShopSpecial() {
	if (document.frmSearchSpecial.txtSearchString.value=='')
	{
		alert(strErrMsg1);
		document.frmSearchSpecial.txtSearchString.focus();
		return;
	}
	document.frmSearchSpecial.submit();
}
function ottLoadRegionsForShopSpecial(strAction) {
	document.frmSearchSpecial.action=strAction;
	document.frmSearchSpecial.submit();
}
function ottLoadBranchesForShopSpecial(strAlphabet) {
	document.frmSearchSpecial.idAlphabet.value = strAlphabet;
	document.frmSearchSpecial.action = 'default.asp?C=ShopSearchForShopSpecialForm';
	document.frmSearchSpecial.submit();
}
function ottCheckShopBoxes(pstrName,pintType){
var objChkBox
	if (pintType==1) {
		for (i=1; i < 100;i++) {
			objChkBox = eval("document.getElementsByName('"+pstrName+"')"+"["+i+"]");
			if (objChkBox)
				objChkBox.checked = 0
		}
	}
	if (pintType==2) {
		objChkBox=eval("document.getElementById('"+pstrName+0+"')")
		objChkBox.checked = 0
	}

}

/* Scripts for ShopSearchForShopSpecialForm.xsl --- End */


/* Scripts for UserShoppingList.xsl --- Start */

function ottShoppingListSubmit(rintAction) {
	var objCurForm = eval("document."+gstrFormName)
	var objAction = eval("document."+gstrFormName+"."+gstrChkSource)
	for (i=0;i < gaintID.length;i++) {
		if (objAction.length) {
			if (objAction[i].checked) {
				var objNameSet = eval("document."+gstrFormName+".Name_"+gaintID[i])
				var objName = eval("document."+gstrFormName+".Name")
				objName.value = objNameSet.value
				objCurForm.action = gastrLink[rintAction]+gaintID[i];
				objCurForm.submit();
			}
		}
		else {
			if (objAction.checked) {
				var objNameSet = eval("document."+gstrFormName+".Name_"+gaintID[i])
				var objName = eval("document."+gstrFormName+".Name")
				objName.value = objNameSet.value
				objCurForm.action = gastrLink[rintAction]+gaintID[i];
				objCurForm.submit();
			}
		}
	}
}


/* Scripts for UserShoppingList.xsl --- End */

/* Scripts for Printing --- Start */

function itwPrintPage() {
	document.getElementById("Print").style.visibility = "hidden";
//	window.print();
//	window.close();
}
function itwPrintWindow(pstrHref) {
	var intHrefLength = pstrHref.length

	if(pstrHref.charAt(intHrefLength-1) == "&")
	{
		pstrHref = pstrHref.slice(0, intHrefLength - 1);
	}

	strLink = 'default.asp?' + pstrHref + '&amp;Print=1';
	objWindow = window.open(strLink, "PrintWindow", "menubar=yes,resizable=yes,status=yes,scrollbars=yes,location=yes");
	objWindow.focus();
}

/* Scripts for Printing --- End */
