/* ************************************************* *//* GENERAL USAGE *//* ************************************************* */// url, params{?param1=value1&param2=value2 or NULL}, modal{true:false}, iframe{iframe}, title, width, heightfunction openGreyformPopupLink(url, params, modal, iframe, title, width, height) { //NEW	//alert(encodeURIComponent("%26"));	//alert("openGreyform: " + params);	if (width==null || width==0)		width=700; //default value	if (height==null || height==0)		height=450; //default value	if (iframe=="iframe")		iframe="TB_iframe=true";	else iframe="";	var obj = document.getElementById("greyformPopupLink");	if (title!=null && title!="")		obj.title=title;	else obj.title="";	if (params!=null && params!=""){		// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!		// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!		//this replacement is done for the jQuery. Otherwise (based on some tests) if the singe quotation mark (')		//presnts in the params - it will be removed by jQuery parser withing		//this call: $("#greyformPopupLink").click();. Replacement by \' does not work here-jQuery replaces it anyway.		//I replace by explicit value %27 (kind of URL encoded value). Actually ' should not be encoded		//for URL. But servlets recognize this value properly and decoded it back to '. 		//There is no issue with the double quotation mark (")		//2008.04.09 - I change some code and don't pass as a parameter the name and description (numbers only)		//since this change I think this is not needed anymore		var re = /\'/g;		params = params.replace(re, "%27");				//alert("openGreyfoem href 1: " + obj.href);		obj.href = url+params + ((iframe=="")?"":"&TB_iframe=true")+"&width="+width+"&height="+height+"&modal="+modal;	} else {		obj.href = url+((iframe=="")?"?":"?TB_iframe=true&")+"width="+width+"&height="+height+"&modal="+modal;		//alert("openGreyfoem href 2: " + obj.href);	}		//alert("openGreyform2: " + params);	//alert("openGreyform href: " + obj.href);	//alert("BEFORE CLICK");		$("#greyformPopupLink").click();	//alert("AFTER CLICK");	//$("#greyformPopupLink").trigger("click");	return false;}//*** AJAX FOR UPLOAD LOGO ***//function startCallback() {	// make something useful before submit (onStart)				var str = document.getElementById("uploadFile").value;    if (document.getElementById("uploadFile").value == "") {    	alert("You must select an image file to upload before you can proceed.\nClick the \"Browse\" button to select files from your computer.");		return false;	}				document.getElementById('logoThumb').src="/onp/images/loading.gif";	return true;}function completeCallback(response) {	// make something useful after (onComplete)	//alert(response);	parent.setContentjQuery("/ONPManager", "action=productGrid", "contentWrapper");}function removeUploadedLogoFromCookie() { //NEW	SetCookie("clickpathonp", "", 100);	parent.setContentjQuery("/ONPManager", "action=productGrid", "contentWrapper");}//*** END AJAX FOR UPLOAD LOGO ***////*** AJAX USING jQuery ***//function setContentjQuery(url, vars, containerid){ //NEW	$.post(url,  vars ,	    function(response) {			$('#'+containerid).html(response);		});}function setContentjQuery(url, vars, containerid, icon_AJAXLoading_Id){ //NEW	if (icon_AJAXLoading_Id){		document.getElementById(icon_AJAXLoading_Id).style.visibility = "visible";	}		$.post(url,  vars ,	    function(response) {			$('#'+containerid).html(response);						if (icon_AJAXLoading_Id){				document.getElementById(icon_AJAXLoading_Id).style.visibility = "hidden";			}		});}function sendRequestAndChangeElementjQuery(url, vars, elementId, newElementValue){	$.post(url,  vars ,	    function(response) {	    	if (response.indexOf("true")!=-1){				document.getElementById(elementId).innerHTML = newElementValue;			}		});}function sendRequestAndGoToURLjQuery(url, vars, urlNew){	$.post(url,  vars ,	    function(response) {	    	/*	    	if (response.indexOf("true")!=-1){				document.getElementById("frameRight").contentWindow.document.getElementById(elementId).innerHTML = newElementValue;			}			*/			//TODO appropriate way is window.document.location.href ???			window.location.href = urlNew;		});}//*** END AJAX USING jQuery ***///* ************************************************* *//* FOR index.jsp *//* ************************************************* */function login(){	if (emailCheck(document.loginForm.email.value, "Email")) {      	if (document.loginForm.password.value.length!=0){        	 return true; //document.loginForm.submit();        }else{            alert ('Password should not be empty.');        }	}	return false;}/* ************************************************* *//* FOR mProductGrid.jsp *//* ************************************************* */		function bannerMPresentationEditor_Clicked(selectedSupplierId){			//switch to Advanced mode search			document.getElementById("advanced_search_div").className="";			document.getElementById("advanced_search_link").innerHTML="Simple search";			document.getElementById("searchButton1").style.display="none";			document.getElementById("searchButton2").style.display="block";			currentSearchMode = "advanced";			//activate selected Supplier in the list			obj = document.getElementById("supplier");			for (v=0;v<obj.options.length;v++){				if (obj.options[v].value==selectedSupplierId){					obj.options[v].selected = true;					break;				}			}						//set all other options to default			document.getElementById("search").value="";			document.getElementById("category").options[0].selected = true;			updateSubCategoryListBasedOnCategoryId(0);			parent.setContentjQuery("/ONPManager", "action=search&catId=0&subCatId=0&supplierId="+selectedSupplierId+"&search=&clickedFrom=banner", "contentWrapper", "icon_AJAXLoading_Id");			return false;		}		function hideMoreProductInfo(objId){			//document.getElementById(objId).style.visibility = "hidden";			document.getElementById(objId).style.display = "none";		}				function showMoreProductInfo(objId){			document.getElementById(objId).style.display = "block";		}				function updateProductInPresentation (productId, styleId, techniqueId){			var totalNumber = 0;			try {				totalNumber = parseFloat(document.getElementById("productsInPresentation").innerHTML);			} catch (e){}						sendRequestAndChangeElementjQuery("/ONPManager", "action=addProductToPresentation&productId="+productId+"&styleId="+styleId+"&techId="+techniqueId, "productsInPresentation", totalNumber);			return true;		}				function addRemoveProductToFromPresentation (productId, styleId, techniqueId){			var totalNumber = 0;			try {				totalNumber = parseFloat(document.getElementById("productsInPresentation").innerHTML);			} catch (e){}						var link = document.getElementById("actionsLink_" + productId);						if (link.name=="add"){				//add product				totalNumber++; 				sendRequestAndChangeElementjQuery("/ONPManager", "action=addProductToPresentation&productId="+productId+"&styleId="+styleId+"&techId="+techniqueId, "productsInPresentation", totalNumber);				link.innerHTML="Remove from presentation";				link.name="remove";								//link.className="added";								document.getElementById("addedIcon_"+productId).className = "overlay";				document.getElementById("actionsSpan_"+productId).className = "actions added";								return true;			}else{				//remove product				var varConfirm = confirm("Are you sure you want to remove the product?");				if (varConfirm) {					totalNumber--;					sendRequestAndChangeElementjQuery("/ONPManager", "action=removeProductFromPresentation&productId="+productId, "productsInPresentation", totalNumber);					link.innerHTML="Add to presentation";					link.name="add";										//link.className="add";										document.getElementById("addedIcon_"+productId).className = "overlayNoDisplay";					document.getElementById("actionsSpan_"+productId).className = "actions add";										return true;				}			}						return false;		}				//used to remove product in PresentationPreview opened from PresentationEditor // NEW		function removeProductFromPresentationInPreviewPresentation (productId, presentationId, currentPageNumber){			var varConfirm = confirm("Are you sure you want to remove this product from the Presentation?");			if (varConfirm) {				var url = "/presentation/"+presentationId + "?action=reloadInfo&v=fromAccount"				var logoId = GetCookie("clickpathonp");				if (logoId!=null && logoId!="")					url += "&logoId="+logoId;				url += "&pgn="+currentPageNumber;								sendRequestAndGoToURLjQuery("/ONPManager", "action=removeProductFromPresentation&productId="+productId, url);			}			return false;		}		function addRemoveProductStillNotPossible (productId, link){			alert("Your account is still under approval process.\r\nYou can't add/remove product.");			return false;		}		function showProductDetailedView (accId, sku, productId, v){					//this works			//IFRAME VERSION WORKS VERY SLOWLY			//later I figured out why: becasue of UploadLogo asp module			//it's downloading very slowly (.asp file sometimes has such bechaivour on my DEV)			//and iframe version probably waits until all component will be uploaded			openGreyformPopupLink("/ONPManager", "?action=showProductDetailedView&accid="+accId+"&sku="+encodeURIComponent(sku)+"&productId="+productId+"&v="+v, "true", "iframe", "Product detailed information", 800, 530)						//AJAX VERSION WORKS VERY QUICKLY			//openGreyformPopupLink("/ONPEmbeddedManager", "?accid="+accId+"&sku="+encodeURIComponent(sku), "false", "ajax", "Additional information", 700, 500)						//var obj = document.getElementById("greyformPopupLink");			//obj.href = "/OneClickEmbeddedManager?accid="+accId+"&sku="+sku + "&TB_iframe=true&width=700&height=450";			//$("#greyformPopupLink").click();			return false;		}				function productGridAfterLogoUpload(){			//document.getElementById("logoImage").src="<%=sitename%>/imagedump/thumbs/"+obj.value+".jpg.jpg";			//clickPath = obj.value;			//SetCookie("clickpath", obj.value, 100);			//parent.setContent("/ONPManager", "action=productGrid&imid="+obj.value, "content");			parent.setContentjQuery("/ONPManager", "action=productGridAfterLogoUpload", "content");			tb_remove();			//return true;		}		//TODO IS IT USED/*		function changeLogoInAccount_V2_rowOfLogos(logoId){			if (logoId==null || logoId==""){				document.getElementById("logoImage").src="/onp/images/noLogoUploaded_50x50.png";				parent.document.getElementById("logoImageOnPresentationEditor").src="/onp/images/noLogoUploaded_50x50.png";			}else{				document.getElementById("logoImage").src="/imagedumponp/thumbs/"+logoId+".jpg.jpg";				parent.document.getElementById("logoImageOnPresentationEditor").src="/imagedumponp/thumbs/"+logoId+".jpg.jpg";			}			SetCookie("clickpathonp", logoId, 100);//TODO - don't reload content, update images sources in JS						parent.setContentjQuery("/ONPManager", "action=productGrid", "contentWrapper");			return true;		}*/		function changeLogoInRowOfLogosPresEditorNoActivePres(logoId){ //NEW			if (logoId==null || logoId==""){				document.getElementById("logoImage").src="/onp/images/noLogoUploaded_50x50.png";			}else{				document.getElementById("logoImage").src="/imagedumponp/thumbs/"+logoId+".jpg.jpg";			}			SetCookie("clickpathonp", logoId, 100);			setContentjQuery("/ONPManager", "action=productGrid", "contentWrapper");			return true;		}				function changeLogoInRowOfLogosPresEditorActivePres(logoId){ //NEW			if (logoId==null || logoId==""){				document.getElementById("logoImage").src="/onp/images/noLogoUploaded_50x50.png";			}else{				document.getElementById("logoImage").src="/imagedumponp/thumbs/"+logoId+".jpg.jpg";			}			SetCookie("clickpathonp", logoId, 100);			document.getElementById("logoSmallThumbLink_"+logoId).className="select";			document.getElementById("logoSmallThumbLink_"+currentLogoId).className="";			//this declared at the top of the HTML page			currentLogoId = logoId;			setContentjQuery("/ONPManager", "action=productGrid", "contentWrapper");			return true;		}				function changeCurrentViewPage(pageValue){			parent.setContentjQuery("/ONPManager", "action=changeCurrentViewPage&cvp="+pageValue, "contentWrapper");			//return true;		}		function changeSortingType(obj){			parent.setContentjQuery("/ONPManager", "action=changeSortingType&cst="+obj.value, "contentWrapper");	  		return true;		}		//TODO is this used?/*		function changeViewModeFromDefault(){			parent.setContentjQuery("/ONPManager", "action=changeViewMode&cvm=1", "contentWrapper");	  		//return true;		}*/		function changeViewMode(viewMode){			parent.setContentjQuery("/ONPManager", "action=changeViewMode&cvm="+viewMode, "contentWrapper");	  		return true;		}		function changeProductsOnPage(obj){			parent.setContentjQuery("/ONPManager", "action=changeProductsOnPage&pn="+obj.value, "contentWrapper");	  		return true;		}/* ************************************************* *//* FOR mPresentationList.jsp *//* ************************************************* */		function previewPresentationFromList(presentationId) { //NEW			//var url = "/ONPManager?action=presentationView&presentationId="+presentationId; //+"&v=fromAccount"			var url = "/presentation/"+presentationId + "?action=reloadInfo"; //+"&v=fromAccount"			var logoId = parent.GetCookie("clickpathonp");			if (logoId!=null && logoId!="")				url += "&logoId="+logoId			var winNew = window.open(url, "winNew", "");			return false;		}		//need this separate function for preview from Panel (below is a very similar) because we need to reload the ProductsCollection		//each time in order to reflect changes (product was added/removed) during Presentation editing		//actually this method should not look for cookie here. it can be done on the page that calls this		//in same window		function previewPresentationFromEditor(presentationId) { //NEW			var url = "/presentation/"+presentationId + "?action=reloadInfo&v=fromAccount"			var logoId = parent.GetCookie("clickpathonp");			if (logoId!=null && logoId!="")				url += "&logoId="+logoId;			window.location.href = url;			return false;		}						//actually this method should not look for cookie here. it can be done on the page that calls this		function confirmPresentationDelete(presentationId) { //NEW		  	var varConfirm = confirm("Are you sure you want to delete the presentation?");		  	if (varConfirm) {	    		sendRequestAndGoToURLjQuery("/ONPManager", "action=deletePresentation&presentationId="+presentationId, "/mypresentations");			}			return false;		}		function editPresentation(presentationId, presentationStatus) { //NEW			if (presentationStatus==3){ //<%=onp.Presentation.PRESENTATION_STATUS_sent%>){				var varConfirm = confirm("This presentation has been sent.\nIf you add or remove some products in it\nthe sent presentation(s) will include these changes as well.");		  		if (!varConfirm) {					return false;				}			}    		sendRequestAndGoToURLjQuery("/ONPManager", "action=editPresentation&presentationId="+presentationId, "/products");			return false;		}
