function openCreateaPencil()
{
	window.open("CreateaPencil.asp", "win2", "width=600, height=400, top=100,left=190, resizable=yes, scrollbars=yes");
}
function emailPage(productid,productcode)
{
	if (typeof(document.forms[0].varlist)!="undefined")
	{
		varname = document.forms[0].varlist.value;
		varname = varname.split("===");
		window.location.href="ClientEmailPage.asp?from=details&prodid="+productid+"&prodcode="+productcode+"&varName="+varname[0];
	}
	else
	{
		varname ="";
		window.location.href="ClientEmailPage.asp?from=details&prodid="+productid+"&prodcode="+productcode+"&varName="+varname;
	}
	//window.close();
}

function spimg(productId,productImage)
{
//	alert(productId);
//	alert(productImage);
	if (productImage.indexOf("_")!=-1)
	{
			strsplitTempImg = productImage.split("_")[1];
			productImage=strsplitTempImg;
	}		
	window.open("spimg.asp?productid="+productId+"&productimage="+productImage, "win3", "width=700, height=550, top=100,left=150, resizable=yes, scrollbars=yes")
	
}
function EnlargeImagethis(productId,productcolorid,productImage)
{
//	alert(productId);
//	alert(productImage);
	if (productImage.indexOf("_")!=-1)
	{
			strsplitTempImg = productImage.split("_")[1];
			productImage=strsplitTempImg;
	}		
	window.open("enlargeimage.asp?productid="+productId+"&productcolorid="+productcolorid+"&productimage="+productImage, "win3", "width=580, height=500, top=50,left=50, resizable=no, scrollbars=no")
	
}


function openSearch(val)
{
	if (val=="Advance")
	{
		window.opener.location.href="ClientAdvancedSearch.asp";
		window.close();
	}
	if (val=="Catalog")
	{
		window.opener.location.href="ClientAdvancedSearch.asp";
		window.close();
	}
}
function loginChk(ProductImage,ProductId,ProductCode,ProductType)
{
	var filename = "ClientAddLogo.asp?logosearchtype=C^^^^productimage="+ProductImage.split("/")[ProductImage.split("/").length-1]+"^^^^productid="+ProductId+"^^^^productcode="+ProductCode+"^^^^producttype="+ProductType;
	document.forms[0].method="post";
	document.forms[0].target="";
	window.opener.location.href="clientlogin.asp?Filename="+filename;
	window.close();
}
function viewMoreLogos(ProductImage,ProductId,ProductCode,ProductType)
{
	var filename = "viewvirtualsample.asp?productimage="+ProductImage+"^^^^prodid="+ProductId+"^^^^prodcode="+ProductCode+"^^^^producttype="+ProductType;
	document.forms[0].method="post";
	document.forms[0].target="";
	window.opener.location.href="clientlogin.asp?Filename="+filename;
	window.close();
}
function loginUser()
{
	window.opener.location.href="clientlogin.asp";
	window.close();
}
function browseSite(url)
{
	document.location.href = url;
	childwindow.close(); // Closing the product details window for the main window. Here 'childwindow' is the name of the child window
}
function quoteChk()
{
	event.keyCode=quoteDisallow(event.keyCode)	
}
function quoteDisallow(keyPressed)
{
	if (keyPressed==39 || keyPressed==34 || keyPressed==13)
	{
		keyPressed = 0
	}
	else
	{		
	}
	return keyPressed	
}
function test()
{
	//alert("hiiiiiiii");
}
function RegisterGuestWL(val,productId,prodImg,productCode,productOffer)
{
	if (val == "guest")
	{
		var prodDet = "||"+productId+"^^"+productCode+"^^";
		document.forms[0].method="post";
		document.forms[0].target="";
		var strDetails="ClientShortList.asp?Filename=GuestSave+"+prodDet+"";
		window.opener.location.href="clientlogin.asp?Filename="+strDetails;
		window.close();
	}
	/*else
	{
		document.frmProductDetails.method="post";
		document.location.href="ClientProductDetails.asp?addsc=Y&logoid="+logoId+"&logoSearchType="+Logosearchtype+"&listvalues="+variantName+"|"+productColor+"&productId="+productId+"&productname="+ProductName+"&productimage="+prodImg+"&productcode="+productCode+"&producttype="+prodType+"&productoffer="+productOffer+"Filename="+strDetails+"&mode="+mode;
	}*/
}
function prodDetShortList(productId,productImage,ProductColorId,productOffer,rowCount)
{
	if (rowCount == 0 )
	{
		mode="createnew";
		chSListWin=window.open("CreateShortList.asp?productid="+productId+"&productimage="+productImage+"&ProductColorId="+ProductColorId+"&productoffer="+productOffer+"&mode="+mode, "win2", "width=400, height=300, top=100,left=490, resizable=yes, scrollbars=yes")
		//alert("CreateShortList.asp?productid="+productId+"&productimage="+productImage+"&ProductColorId="+ProductColorId+"&productoffer="+productOffer+"&mode="+mode, "win2", "width=400, height=300, top=100,left=490, resizable=yes, scrollbars=yes")
		chSListWin.focus();
	}
	else
	{
		var mode = "addproduct";
		document.forms[0].target = "_parent";
		document.forms[0].method="post";
		document.forms[0].action =  "ClientProductDetails.asp?shortlistid="+document.frmProductDetails.selectshortlist.value+"&productid="+productId+"&productimage="+productImage+"&ProductColorId="+ProductColorId+"&productoffer="+productOffer+"&mode="+mode;
		//alert("ClientProductDetails.asp?shortlistid="+document.frmProductDetails.selectshortlist.value+"&productid="+productId+"&productimage="+productImage+"&ProductColorId="+ProductColorId+"&productoffer="+productOffer+"&mode="+mode)
		document.forms[0].submit();
	}
}		
function ChkTextSearch(loginid,FolderNo)
{
	var strSearchTxt = document.frmProductSearch.txtSearchTxt.value;
	while(''+strSearchTxt.charAt(0)==' ')
		strSearchTxt=strSearchTxt.substring(1,strSearchTxt.length);
	document.frmProductSearch.txtSearchTxt.value=strSearchTxt;
	if (strSearchTxt == "")
	{
		alert("Please enter Search Criteria");
		document.frmProductSearch.txtSearchTxt.focus();
		return false;
	}
	var strCriteria;
	strCriteria=document.frmProductSearch.txtSearchTxt.value;
	if (strCriteria=="%")
	{
		strCriteria=""
	}
	document.frmProductSearch.action="ClientProductListing.asp?strSearch=text&loginid="+ loginid +"&FolderNo="+FolderNo+"&strPageno=0&strCriteria="+strCriteria;
	return true;
}

function getOffersDetail(loginid,folderno,productid,productname)
{
	window.opener.location.href="ClientProdDetOffer.asp?loginid="+loginid+"&folderno="+folderno+"&productid="+productid;	
	window.close();
}

function getOffers(loginid,folderno,productid,productname)
{
	window.opener.location.href="ViewOfferDisc.asp?loginid="+loginid+"&folderno="+folderno+"&productid="+productid;	
	window.close();
}



function changeImage(producttype,folderno,variantdetails,prodid,prodcode,colorcode,prodimage,variantname,apppathusers,apppathusers1)
{
	document.imgProdImg.src = apppathusers+"images/products/"+prodimage;
	var splitvar = variantdetails.split(";");
	//alert(splitvar[splitvar.length]);
	//alert(colorcode);
	document.frmProductDetails.txtProdCode.value = prodcode;
	document.frmProductDetails.prodcode.value =colorcode;
	arrcolrodet=variantdetails.split(";")
	
	
	//	alert(arrcolrodet[4]);
	setProductvarprice(prodid,variantname,apppathusers,apppathusers1,arrcolrodet[4],prodimage,prodcode)
//	alert(prodcode);
	//alert(colorcode);
	
}


/*function changeImage(producttype,folderno,variantdetails,prodid,prodcode,prodimage,variantname,apppathusers,apppathusers1)
{
	//alert("hiiii"+prodimage);
	document.frmProductDetails.logooption.value=producttype;
	//document.frmProductDetails.hidProductType.value = producttype;
	variantname = variantname.replace("=+=","\"").replace("=","'");
	var splitvar = variantdetails.split(";");
	var splitvar1 = splitvar[1].replace("=+=","\"").replace("=","'");
//	if (unescape(splitvar1)!="")
//	{
//		document.frmProductDetails.hidProdVariant.value = document.frmProductDetails.cboProdVariant.value;
//	}	
//	else
//	{
//		document.frmProductDetails.hidProdVariant.value="";
//	}
	var tempvar="";
	for (i=0;i<=splitvar[4].split(",").length;i++)
	{
		tempvar = tempvar + unescape(splitvar[4].split(",")[i]);
		if (i<splitvar[4].split(",").length)
		{
			tempvar = tempvar + ",";
		}
	}
	tempvar = tempvar.replace("=+=","\"").replace("=","'");
	//alert("ss"+prodcode);
	if (prodcode=="change")
	{
		document.forms[0].method="post";
		document.forms[0].target="iFraProdColor";
		document.forms[0].action = "ClientProductColours.asp?producttype="+producttype+"&variantname="+escape(splitvar[1])+"&folderno="+folderno+"&productcolours="+splitvar[2]+"|"+tempvar+"&productid="+prodid+"&productcode="+splitvar[3];
//		document.forms[0].submit();
		document.frmProductDetails.txtProdCode.value = splitvar[3].split(",")[0];
		document.frmProductDetails.hidProdColor.value = unescape(splitvar[4]).split(",")[0];
// for pricing
		//alert(splitvar[4].split(",")[0])
		
		if (producttype=="0")
		{
			if (splitvar[4].split(",")[0]=="N")
			{
				document.imgProdImg.src = apppathusers+"images/products/blank.jpg";
			}
			else
			{
				document.imgProdImg.src = apppathusers+"images/products/"+splitvar[2].split(",")[0];
			}
		}
		else if (producttype=="withoutlogo")
		{
			if (splitvar[2].split(",")[0].split("_").length=="1")
			{
				document.imgProdImg.src =apppathusers+"images/products/"+splitvar[2].split(",")[0];
			}
			else
				document.imgProdImg.src = apppathusers+"images/products/"+splitvar[2].split(",")[0].split("_")[1];
		}
		else
		{
			if (splitvar[2].split(",")[0]=="")
			{
				document.imgProdImg.src = apppathusers+"images/products/"+prodimage;
			}
			else
				document.imgProdImg.src = apppathusers+"images/products/"+splitvar[2].split(",")[0];			
		}
	}
	else
	{
//		alert('hiiiiiiiiiiii');
		document.forms[0].method="post";
		document.forms[0].target="iFraProdColor";
		document.forms[0].action = "ClientProductColours.asp?producttype="+producttype+"&variantname="+escape(variantname)+"&folderno="+folderno+"&productcolours="+splitvar[2]+"|"+tempvar+"&productid="+prodid+"&productcode="+splitvar[3];
//		document.forms[0].submit();
		document.frmProductDetails.txtProdCode.value = prodcode;		
		for (var i=0;i<splitvar[3].split(",").length;i++ )
		{
			if (splitvar[3].split(",")[i]==prodcode)
			{
				document.frmProductDetails.hidProdColor.value = unescape(splitvar[4]).split(",")[i];
			}
		}
		if (producttype=="0")
		{
			if (splitvar[4].split(",")[0]=="N")
			{
				document.imgProdImg.src = apppathusers+"images/products/blank.jpg";
			}
			else
			{
				document.imgProdImg.src = apppathusers+"images/products/"+prodimage;
			}
		}
		else if (producttype=="withoutlogo")
		{
			if (prodimage.split("_").length=="1")
			{
				document.imgProdImg.src = apppathusers+"images/products/"+prodimage;
			}
			else
				document.imgProdImg.src =apppathusers+"images/products/"+prodimage.split("_")[1];
		}
		else
		{
			if (prodimage.split("_").length=="1")
			{
				document.imgProdImg.src = apppathusers+"images/products/"+prodimage;
			}
			else
				document.imgProdImg.src = apppathusers+"images/products/"+prodimage;
		}
	}

	arrcolrodet=variantdetails.split(";")
	
	setProductvarprice(prodid,variantname,apppathusers,apppathusers1,arrcolrodet[4])
	
}*/

/*function setProductColour(producttype,folderno,productid,productimage,productcode,productcolor,apppathusers,apppathusers1,exval)
{		
	alert(productimage);
	var imgDet = productcode.split("==")
	prodCode = imgDet[0];
	productimage = imgDet[1];
	exval=imgDet[2];
	var productimage=productimage.substring(productimage.lastIndexOf("/") + 1)
	frmProductDetails.txtProdCode.value = prodCode;
	frmProductDetails.hidProdColor.value = productcolor.replace("=+=","\"").replace("=","'");
	if (producttype=="0")
	{
		if (exval=="N")
		{
			document.imgProdImg.src = apppathusers+"images/products/blank.jpg";
		}
		else
		{
			document.imgProdImg.src = apppathusers+"images/products/"+productimage;
		}
	}
	else if (producttype=="withoutlogo")
	{
		if (productimage.split("_").length=="1")
		{
			document.imgProdImg.src = apppathusers+"images/products/"+productimage;
		}
		else
			document.imgProdImg.src = apppathusers+"images/products/"+productimage.split("_")[1];
	}
	else
	{
		if (productimage.split("_").length=="1")
		{
			document.imgProdImg.src = apppathusers+"images/users/"+folderno+"/"+productid+"_"+productimage;
		}
		else
			document.imgProdImg.src = apppathusers+"images/users/"+folderno+"/"+productimage;
	}
	
//	alert(productid);
//	alert(parent.document.forms[0].txtProdCode.value);

}*/


function setProductColour(productid,productimage,colorname,apppathuser,prodcode,colorcode)
{	
	parent.document.imgProdImg.src = apppathuser+"images/products/"+productimage;	
	parent.document.frmProductDetails.txtProdCode.value = prodcode;
	parent.document.frmProductDetails.prodcode.value = colorcode;
}



function changeLogo(producttype,folderno,logoid,variantdet,prodname,prodid,srcimage,listvalues,logoimage,apppathusers,apppathusers1)
{
	document.frmProductDetails.guestlogoid.value = logoid;
	document.frmProductDetails.imgLogoImage.src = apppathusers+"/images/logos/guest/"+logoimage;
	var prodsrcimage=logoid+"_"+srcimage.split('//')[1].split('/')[srcimage.split('//')[1].split('/').length-1].split("_")[1];
	var splitvar = variantdet.split(";")
	prodimages = "";
	for (var i=0;i<splitvar[2].split(",").length;i++)
	{
		prodimages = prodimages+logoid+"_"+((splitvar[2].split(",")[i]).split("_")[1]);
		if (i<splitvar[2].split(",").length-1)
		{
			prodimages = prodimages +",";
		}
	}
	iFraProdColor.location.href="ClientProductColours.asp?defaultlogoimage="+logoimage+"&listvalues="+listvalues+"&producttype="+producttype+"&variantname="+unescape(splitvar[1])+"&folderno="+folderno+"&productcolours="+prodimages+"|"+unescape(splitvar[4])+"&productname="+prodname+"&productid="+prodid+"&productcode="+splitvar[3];	
	if (producttype=="0")
	{
		document.imgProdImg.src = apppathusers+"/images/products/"+prodsrcimage;
	}
	else
		document.imgProdImg.src = apppathusers+"/images/users/"+folderno+"/"+prodsrcimage;
}

function getProductDetails(producttype,loginid,folderno,productid,productname,productimage,productcode,variantname,listvalues,logosearchtype,logoid,productoffer,imagesourceid,logoimage)
{
	if (productid!="")
	{
		if(productoffer !="" && productoffer.charAt(0)==',')
		{
			productoffer=productoffer.substr(1);
		}
		if (logoimage==null)
		{
			logoimage="";
		}
		window.open("ClientProductDetails.asp?productoffer="+escape(productoffer)+"&logoid="+logoid+"&logosearchtype="+logosearchtype+"&listvalues="+escape(listvalues)+"&producttype="+producttype+"&variantname="+escape(variantname)+"&loginid="+loginid+"&folderno="+folderno+"&productid="+productid+"&logoimage="+logoimage+"&productname="+escape(productname)+"&imagesourceid="+imagesourceid+"&productimage="+productimage+"&productcode="+escape(productcode),"getProductDetails","top=0,left=0,width=680,height=700,resizable=yes,scrollbars=yes");
	}	
}

function pickProductDetails(producttype,loginid,folderno,productid,productimage,productcode,logosearchtype,logoid,productoffer,imagesourceid,logoimage)
{
	if (productid!="")
	{
		if(productoffer !="" && productoffer.charAt(0)==',')
		{
			productoffer=productoffer.substr(1);
		}
		if (logoimage==null)
		{
			logoimage="";
		}

		document.location.href="ClientProductDetails.asp?productoffer="+productoffer+"&logoid="+logoid+"&logosearchtype="+logosearchtype+"&producttype="+producttype+"&loginid="+loginid+"&folderno="+folderno+"&productid="+productid+"&logoimage="+logoimage+"&imagesourceid="+imagesourceid+"&productimage="+productimage+"&productcode="+productcode,"getProductDetails";
		//document.location.href="ClientProductDetails.asp?productoffer="+productoffer+"&logoid="+logoid+"&logosearchtype="+logosearchtype+"&producttype="+producttype+"&loginid="+loginid+"&folderno="+folderno+"&productid="+productid+"&logoimage="+logoimage+"&imagesourceid="+imagesourceid+"&productimage="+productimage+"&productcode="+productcode","getProductDetails";
		//window.open("ClientProductDetails.asp?productoffer="+productoffer+"&logoid="+logoid+"&logosearchtype="+logosearchtype+"&producttype="+producttype+"&loginid="+loginid+"&folderno="+folderno+"&productid="+productid+"&logoimage="+logoimage+"&imagesourceid="+imagesourceid+"&productimage="+productimage+"&productcode="+productcode,"getProductDetails","top=0,left=0,width=680,height=700,resizable=yes,scrollbars=yes");
	}		
}

function saveImage(productimage)
{
	var arrFileSplitValues = productimage.split('//')[1].split('/');
	var strFileName = "";
	for (var intCtr1=0;intCtr1<arrFileSplitValues.length;intCtr1++)
	{
		if (arrFileSplitValues[intCtr1]=="images")
		{
			for (var intCtr2=intCtr1;intCtr2<arrFileSplitValues.length;intCtr2++)
			{
				strFileName = strFileName + arrFileSplitValues[intCtr2];
				if (parseInt(intCtr2)<parseInt(arrFileSplitValues.length-1))
				{

					strFileName = strFileName + "/"

				}
			}
			break;
		}
	}
	document.location.href="ClientSaveImage.asp?FileName="+strFileName;
}

function getLogo(logosearchtype,producttype,loginid,folderno,productid,productname,productimage,productcode,variantname,productoffer,productColor)
{
	document.frmProductDetails.hidLogoSearchType.value = logosearchtype;
	document.frmProductDetails.target="_self";
	document.frmProductDetails.method="post";
	document.frmProductDetails.action="ClientSetProductLogo.asp?productColor="+productColor+"&productoffer="+productoffer+"&logosearchtype="+logosearchtype+"&producttype="+producttype+"&loginid="+loginid+"&folderno="+folderno+"&productid="+productid+"&productname="+productname+"&productimage="+productimage+"&productcode="+productcode+"&variantname="+variantname;
	document.frmProductDetails.submit();
}


function CloseWindow(val,loginid,folderno,ProductId,prodimg,productcode,productoffer)
{
	if (val=="N")
	{
		document.frmProductDetails.ShopCart.value=ProductId+"||"+productcode;
		document.forms[0].method="post";
		document.forms[0].target="";
		window.location="clientlogin.asp?CartDet="+document.frmProductDetails.ShopCart.value+"&Filename=AddToShoppingCart.asp?";
		//window.close();
	}
	else
	{
		document.frmProductDetails.ShopCart.value=ProductId+"||"+productcode;
		document.frmProductDetails.method="post";
		document.forms[0].target="_parent";
		document.frmProductDetails.action="ClientProductDetails.asp?addsc=Y&folderno="+folderno+"&loginid="+loginid+"&productid="+ProductId+"&productimage="+prodimg+"&productcode="+productcode+"&productoffer="+productoffer+"&CartVal="+document.frmProductDetails.ShopCart.value;
		document.frmProductDetails.submit();
	}
}

function openwinPrdDet(productId,productImage,ProductColorId,productOffer)
{
	chSListWin=window.open("CreateShortList.asp?productid="+productId+"&productimage="+productImage+"&ProductColorId="+ProductColorId+"&productoffer="+productOffer, "win2", "width=400, height=300, top=100,left=490, resizable=yes, scrollbars=yes")
	chSListWin.focus();
}

function changeLogoImage(logodetails,productid,loginid,productimage,productcode,producttype,apppathusers,apppathusers1)
{
	if (logodetails.split("|")[0]!="NS")
	{
		var logoid = logodetails.split("|")[0];
		var logoimage = logodetails.split("|")[1];
		document.location.href="viewvirtualsample.asp?productimage="+productimage+"&prodid="+productid+"&prodcode="+productcode+"&producttype="+producttype+"&logosearchtype=R&logoid="+logoid+"&imagesourceid=0&logoimage="+logoimage;
	}
}

function changeYourLogoImage(logodetails,productid,folderno,productimage,productcode,producttype,apppathusers,apppathusers1)
{
	if (logodetails.split("|")[0]!="NS")
	{
		var logoid = logodetails.split("|")[0];
		var logoimage = logodetails.split("|")[1];
		document.imgLogoImage.src = apppathusers+"images\logos\\"+logoimage;
		var productimage = productimage;
		document.location.href="viewvirtualsample.asp?productimage="+productimage+"&prodid="+productid+"&prodcode="+productcode+"&producttype="+producttype+"&logosearchtype=C&logoid="+logoid+"&imagesourceid="+folderno+"&logoimage="+logoimage;
	}	
}

function manageLogos(productoffer,producttype,productid,productimage,productcode)
{
	window.opener.location.href="ClientAddLogo.asp?logosearchtype=C&productoffer="+productoffer+"&producttype="+producttype+"&productid="+productid+"&productimage="+productimage+"&productcode="+productcode;
	window.close();
}

var temp = ""; 

function addProduts(prodNo,countTempProd,countUserProd,strProdId, strProdColorId)
{
	
	
	//alert(strProdColorId);
	
	var TotEflyerProducts;
	/*alert("ProdNo "+prodNo);
	alert("Temp Product " +countTempProd);
	alert("User Product " +countUserProd);
	alert("strProdId " +strProdId);
	alert("strProdColorId " +strProdColorId);
	*/
	var strmsgCheck = true;
	
	strProdId  = strProdId.split(":");

	strProdColorId  = strProdColorId.split(":");

	chkflag = 0
	for (i=0;i<strProdColorId.length-1;i++)
	{
//		if(eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".checked") == true)
//			chkflag = 1;
			
		if(eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".checked") == true) 
		{
//			alert(eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".checked"));
			if (eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".disabled") == false)
			{
				chkflag = 1;
			}
		}
	}

	if(chkflag == 0)
	{
		alert("Please select a product to add to the Eflyer!");
		return;
	}

	if (countUserProd == "")
	{
		countUserProd=0;
	}
	//1st time if condition
	var CurrCount = 0;
	for(i=0;i<strProdColorId.length-1;i++)
	{
//		if(eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".checked"))
//			CurrCount = CurrCount + 1;
		if(eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".checked")) 
		{
			if (eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".disabled") == false)
			{
				CurrCount = CurrCount + 1;
			}
		}

	}
	//alert ("Current Count " +CurrCount);
	
	TotEflyerProducts=parseInt(eval("document.frmProductSearch.eflyertest.value"))
	TotEflyerProducts2=parseInt(eval("document.frmProductSearch.productadded.value"))
	
	//alert("TotEflyerProducts " +TotEflyerProducts)
	//alert("TotEflyerProducts2 " +TotEflyerProducts2)
	
	//if ((TotEflyerProducts >= 2 ) || (CurrCount > 2) )
	//{
	//	alert("countUserProd "+countUserProd);
	//	alert("CurrCount "+CurrCount);
	//	alert("countTempProd "+countTempProd);
		
			if ( (parseInt(countUserProd) + parseInt(CurrCount)) > parseInt(countTempProd))
			{
				alert("The Template you have selected allows only "+countTempProd+" products to be added for the Eflyer! ");
					var unDisabled,unDisabled1;
					var unCheck,unCheck1;
					for (i=0;i<strProdColorId.length-1;i++)
					{
						if(i==0)
						{
							unDisabled = eval("document.frmProductSearch.chkProd"+strProdColorId[i]+"");
							if (unDisabled.disabled == false)
							{
								unCheck = eval("document.frmProductSearch.chkProd"+strProdColorId[i]+"");
								unCheck.checked = false;
							}
						}
						else
						{
							if (typeof(strProdColorId[i]) != "undefined" && strProdColorId[i] != "")
							{
								unDisabled1 = eval("document.frmProductSearch.chkProd"+strProdColorId[i]+"");
								if (unDisabled1.disabled == false)
								{
									unCheck1 = eval("document.frmProductSearch.chkProd"+strProdColorId[i]+"");
									unCheck1.checked = false;
								}
							}
						}
					}
				
				return;
			}
	

	//}

	var msg=false;
	if (countUserProd < 1)
	{
			msg = false;
			for (i=0;i<strProdColorId.length-1;i++)
			{
				if(i==0)
				{

					if (eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".checked") == true) 
					{
						if (eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".disabled") == false)
						{
							
							document.frmProductSearch.selectedProducts.value = document.frmProductSearch.selectedProducts.value + eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".value") + "^^"
							//alert("Pag1");
							alert("The product has been added to the Eflyer");
							countUserProd=parseInt(countUserProd)+1;
							msg = true;
											
						}
					}
					prodNo=parseInt(prodNo)+1;
				}//if
				else
				{
					if (parseInt(countUserProd) <= parseInt(countTempProd))
					{
						if (strProdColorId[i] != "")
						{

							if (eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".checked") == true) 
							{
								if (eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".disabled") == false)
								{
									document.frmProductSearch.selectedProducts.value = document.frmProductSearch.selectedProducts.value + eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".value") + "^^"
									countUserProd = parseInt(countUserProd) + 1
								}
							}
						}
					}
				}//else
			}//for
			
			if (msg == false)
				//alert("Pag2");
				alert("The product has been added to the Eflyer");
				
				TotEflyerProducts=parseInt(eval("document.frmProductSearch.eflyertest.value"))
				
			//alert(TotEflyerProducts);
			TotEflyerProducts = TotEflyerProducts +1;
			eval("document.frmProductSearch.eflyertest.value=TotEflyerProducts");
			TotEflyerProducts=parseInt(eval("document.frmProductSearch.eflyertest.value"))
			//alert(TotEflyerProducts);
			//alert(document.frmProductSearch.eflyerschstring.value);
			document.frmProductSearch.method="post";
			document.frmProductSearch.action = document.frmProductSearch.eflyerschstring.value;
			document.frmProductSearch.submit();
	}
	else
	{
		var1 = document.frmProductSearch.selectedProducts.value.split("^^");
		var2 = prodNo;
		var str = false;
for (j=0;j<strProdColorId.length-1;j++)
{
	if(j==0)
	{
		for (var i=0; i < var1.length; i++) 
		{
			if (strProdColorId[j] ==  var1[i]) 
			{
				str=true;
				break;
			} 
			if (str == false)
			{
				if (parseInt(countUserProd) < parseInt(countTempProd))
				{

					if(eval("document.frmProductSearch.chkProd"+strProdColorId[j]+".checked") == true) 
					{
						if (eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".disabled") == false)
						{
							document.frmProductSearch.selectedProducts.value = document.frmProductSearch.selectedProducts.value + eval("document.frmProductSearch.chkProd"+strProdColorId[i]+".value") + "^^"
							countUserProd=parseInt(countUserProd)+1;
							//alert("Pag3");
							alert("The product has been added to the Eflyer");
							msg = true;
							break;
						}
					}
				}  
			}
		}
		prodNo = parseInt(prodNo) + 1;
	}//if
	else
	{
		str=false;
		var1 = document.frmProductSearch.selectedProducts.value.split("^^");
		
		for (var i=0; i < var1.length; i++) 
		{
			if (strProdColorId[j] ==  var1[i]) 
			{
				str=true
				break;
			} 

			if (str == false)
			{
					if (parseInt(countUserProd) >= countTempProd)
					{
						if (strmsgCheck == true)
						{
							//alert("The Template you have selected allows only "+countTempProd+" products to be added for the Eflyer!");
						}
						strmsgCheck=false;
					}
					else
					{
						if (strProdColorId[j] != "")
						{

							if(eval("document.frmProductSearch.chkProd"+strProdColorId[j]+".checked") == true) 
							{
								if (eval("document.frmProductSearch.chkProd"+strProdColorId[j]+".disabled") == false)
								{
									//alert(document.frmProductSearch.selectedProducts.value + " := " + document.frmProductSearch.selectedProducts.value + " + " + eval("document.frmProductSearch.chkProd"+strProdId[j]+".value") + "^^");
									document.frmProductSearch.selectedProducts.value = document.frmProductSearch.selectedProducts.value + eval("document.frmProductSearch.chkProd"+strProdColorId[j]+".value") + "^^"
									countUserProd=parseInt(countUserProd)+1;
									break;
								}
							}
						}  
					}
				}

		}//for inner
	}//else
}//for outer	

		if (msg == false)
			//alert("Pag4");
			alert("The product has been added to the Eflyer");
			TotEflyerProducts=parseInt(eval("document.frmProductSearch.eflyertest.value"))
			//alert(TotEflyerProducts);
			TotEflyerProducts = TotEflyerProducts +1;
			eval("document.frmProductSearch.eflyertest.value=TotEflyerProducts");
			TotEflyerProducts=parseInt(eval("document.frmProductSearch.eflyertest.value"))
			//alert(TotEflyerProducts);
			//alert(document.frmProductSearch.eflyerschstring.value);
			//alert(eval("document.frmProductSearch.eflyertest.value=TotEflyerProducts"));
		document.frmProductSearch.method="post";
		document.frmProductSearch.action = document.frmProductSearch.eflyerschstring.value;
		document.frmProductSearch.submit();
	}
} 




function SaveEflyer(countTempProd,countUserProd)
{
	if (parseInt(countUserProd) == 0)
	{
		alert("The Template you have selected needs you to select atleast 1 Product for the E-Flyer \n If you have already selected a Product then please click on the Add to Mailer Button");
		return;
	}
	document.forms[0].method="post";
	document.forms[0].action="EflyerPreview.asp";
	document.forms[0].submit();
}

function pickProductDetailsEflyer(producttype,loginid,folderno,productid,productimage,productcode,logosearchtype,logoid,productoffer,imagesourceid,logoimage)
{
	
	if (productid!="")
	{
		if(productoffer !="" && productoffer.charAt(0)==',')
		{
			productoffer=productoffer.substr(1);
		}
		if (logoimage==null)
		{
			logoimage="";
		}
		window.open("../../../ClientProductDetails.asp?productoffer="+productoffer+"&logoid="+logoid+"&logosearchtype="
		+logosearchtype+"&producttype="+producttype+"&loginid="+loginid+"&folderno="+folderno+"&productid="+
			productid+"&logoimage="+logoimage+"&imagesourceid="+imagesourceid+"&productimage="+productimage+
			"&productcode="+productcode+"&virtsamples=jsp","getProductDetails","top=0,left=0,width=800,height=650,resizable=yes,scrollbars=yes");
	}	
}

function setProductvarprice(strProductId,val,Apppathusers,apppathusers1,colordet,prodimage,prodcode)
{
	if (colordet !='')
	{
		var strcolornames=colordet;
		var strvarnames=val;
		
	}
	else
	{
		var arrprodvarcol=val.split("===");
		var lenval=parseInt(arrprodvarcol.length-1)
		var strcolornames=arrprodvarcol[lenval];
		var strvarnames=arrprodvarcol[0];
		
	}

	document.forms[0].method="post"
	document.forms[0].action="clientproductpricing.asp?strProductId="+strProductId+"&varname="+strvarnames+"&colornames="+strcolornames+"&prodimage="+prodimage+"&prodcode="+prodcode;
	document.forms[0].target="pricedisp"
	document.forms[0].submit();
}

function viewImprintCol()
{
	openNew = window.open('ImprintCol.html','charge','top=0,left=300,width=523,height=455,resizable=yes');
	openNew.focus();
}
function ViewCharges()
{
	openNew = window.open('Charges.html','charge','top=0,left=455,width=221,height=285,resizable=yes');
	openNew.focus();
}

function open3d(prodfname)
{
	window.open(prodfname,"3D","top=0,left=0,width=600,height=300,resizable=no,scrollbars=yes");
}


function pickProductDetails3D(producttype,loginid,folderno,productid,productimage,productcode,logosearchtype,logoid,productoffer,imagesourceid,logoimage)
{
	if (productid!="")
	{
		if(productoffer !="" && productoffer.charAt(0)==',')
		{
			productoffer=productoffer.substr(1);
		}
		if (logoimage==null)
		{
			logoimage="";
		}
		window.open("swf/"+productid+"3D.asp?productoffer="+productoffer+"&logoid="+logoid+"&logosearchtype="+logosearchtype+"&producttype="+producttype+"&loginid="+loginid+"&folderno="+folderno+"&productid="+productid+"&logoimage="+logoimage+"&imagesourceid="+imagesourceid+"&productimage="+productimage+"&productcode="+productcode,"getProductDetails","top=0,left=0,width=680,height=700,resizable=yes,scrollbars=yes");
	}	
}

function pickProductDetails3Dback(producttype,loginid,folderno,productid,productimage,productcode,logosearchtype,logoid,productoffer,imagesourceid,logoimage)
{
	if (productid!="")
	{
		if(productoffer !="" && productoffer.charAt(0)==',')
		{
			productoffer=productoffer.substr(1);
		}
		if (logoimage==null)
		{
			logoimage="";
		}
		window.open("../ClientProductDetails.asp?productoffer="+productoffer+"&logoid="+logoid+"&logosearchtype="+logosearchtype+"&producttype="+producttype+"&loginid="+loginid+"&folderno="+folderno+"&productid="+productid+"&logoimage="+logoimage+"&imagesourceid="+imagesourceid+"&productimage="+productimage+"&productcode="+productcode,"getProductDetails","top=0,left=0,width=680,height=700,resizable=yes,scrollbars=yes");
	}	
}

function virtualsamp(prodid,prodcode)
{
	//alert("dd");
	
		window.open("viewvirtualsample.asp?prodid="+prodid+"&prodcode="+prodcode ,"getvirtualsample","top=0,left=0,width=700,height=700,resizable=yes,scrollbars=yes");
}