

								  
								  

var CurrentTimeoutTimer;
var mousex, mousey;

document.onmousemove = getXY;

//*****************************************************************************
// Function    : getXY
// Description :
// Created     : 27-10-2005
// Author      : ATP
//*****************************************************************************
function getXY(e) {
  mousex = event.clientX + document.body.scrollLeft;
  mousey = event.clientY + document.body.scrollTop;
  return true;
}

function ehOnMouseOver()
{
	if(window.event.srcElement != null && window.event.srcElement.cImg)
	{
	//DisplayPopup(window.event.srcElement.cImg)
    //window.event.srcElement.alt=''
	var imgid=window.event.srcElement.id
	
	if (imgid=='productPage')
	{
		DisplayPopup(window.event.srcElement.cImg)
		window.event.srcElement.alt=''
	}
	else if (imgid=='grouplistPage')
	{
		DisplayPopupGrpList(window.event.srcElement.cImg)
		window.event.srcElement.alt=''
	} 
	}
	
}

function ehOnMouseOut()
{
	if(window.event.srcElement != null && window.event.srcElement.cImg)
	{
		//ClearPopup()
		
		var imgid=window.event.srcElement.id;
		
		if (imgid=='productPage')
		{
		ClearPopup()
		}
		else if (imgid=='grouplistPage')
		{
		ClearPopup2()
		} 
	}
		
	
	 
}

//*****************************************************************************
// Function    : ClearPopup
// Description :
// Created     : 27-10-2005
// Author      : ATP
//*****************************************************************************
function ClearPopup()
{
	window.clearTimeout(CurrentTimeoutTimer);	
	ResizeDiv.className = 'PopImageHidden';
	//ResizeDiv2.className = 'PopImageHidden';
	fDoDisplayPopup = false;
}
function ClearPopup2()
{
	window.clearTimeout(CurrentTimeoutTimer);	
 	 ResizeDiv2.className = 'PopImageHidden';
	fDoDisplayPopup = false;
}

//*****************************************************************************
// Function    : DisplayPopup
// Description :
// Created     : 27-10-2005
// Author      : ATP
//*****************************************************************************
function DisplayPopup(PopPageParam)
{
	var width=width;
	window.clearTimeout(CurrentTimeoutTimer);	
	if (document.body != null)
	{
		if (PopPageParam != '' && PopPageParam != null) {

      var AreaHeight = 10;
      var AreaWidth  = 10;
      
      
	    if (mousex != null)
	    {
 		   if (mousex < (document.body.offsetWidth-150)+50)
			   { ResizeDiv.style.left		= mousex-25;}
		    else
			   { ResizeDiv.style.left		= mousex-(AreaWidth-30);}
  				
		    if (mousey < (document.body.offsetHeight/2)+20)
			    {ResizeDiv.style.top			= mousey+10;}
		    else
			   { ResizeDiv.style.top			= mousey-(AreaHeight+10);}
				
			  ResizeDiv.className = 'PopImageLoading';
			  fDoDisplayPopup			= true;
			  ResizeDiv.innerHTML = 'Loading!';
			  CurrentTimeoutTimer	= window.setTimeout('DoDisplayPage(\''+ PopPageParam +'\')', 500);
				
	    }

		}
	}
}

function DisplayPopupGrpList(PopPageParam)
{
 
	window.clearTimeout(CurrentTimeoutTimer);	
	if (document.body != null)
	{
		if (PopPageParam != '' && PopPageParam != null) {

      var AreaHeight = 50;
      var AreaWidth  = 10;
      
      
	    if (mousex != null)
	    {
		   if (mousex < (document.body.offsetWidth-350)+50)
			   { ResizeDiv2.style.left		= mousex-25;}
		    else
			   { ResizeDiv2.style.left		= mousex-(AreaWidth-30);}
  				
		    if (mousey < (document.body.offsetHeight/2)+20)
			    {ResizeDiv2.style.top			= mousey+10;}
		    else
			   {// ResizeDiv.style.top			= mousey-(AreaHeight+10);
			   ResizeDiv2.style.top			= mousey-(300);	}
			  ResizeDiv2.className = 'PopImageLoading';
			  fDoDisplayPopup			= true;
			  ResizeDiv2.innerHTML = 'Loading!';
			   CurrentTimeoutTimer	= window.setTimeout('DoDisplayPageGrp(\''+ PopPageParam +'\')', 500);
				
	    }

		}
	}
}


//*****************************************************************************
// Function    : DoDisplayPage
// Description :
// Created     : 27-10-2005
// Author      : ATP
//*****************************************************************************
function DoDisplayPage(PopPageParam)
{
	window.clearTimeout(CurrentTimeoutTimer);	
  
  if (fDoDisplayPopup)
  {
    ResizeDiv.className = 'PopImageDisplay';
    ResizeDiv.innerHTML = '<img width=150 src=\"' + PopPageParam + '\" />';
  }
}

function DoDisplayPageGrp(PopPageParam)
{
	window.clearTimeout(CurrentTimeoutTimer);	
  
  if (fDoDisplayPopup)
  {
    ResizeDiv2.className = 'PopImageDisplay';
    ResizeDiv2.innerHTML = '<img width=400 align=top src=\"' + PopPageParam + '\" />';
  }
}




function DoStatus(ByElem)
{
	if (ByElem.checked)
	{
		var elem = document.getElementById('PaymentNext')
		if (elem != null) {
			elem.disabled = false;
		}
	} else
	{
		var elem = document.getElementById('PaymentNext')
		if (elem != null) {
			elem.disabled = true;
		}
	}
}

//*****************************************************************************
// Function    : DropJump(URL)
// Parameters  : URL with page navigation number.
// Description : On change the dropdown list, URL value is passed along with the position for the current page. 
				//Function returns URL which loads the  same page with the different page content(i.e)Products,
				//Based on the page number selected.
// Created     : 9-Jan-2008
// Author      : Huang He
//*****************************************************************************

function DropJump(URL) {

	if (URL.options[URL.selectedIndex].value != "") 
	//var enqType=URL.options[URL.selectedIndex].value;
	//formEnq.submit();//NOT REQUIRED
	//alert(URL.options[URL.selectedIndex].value);
	self.location.href = URL.options[URL.selectedIndex].value;	
	return true;
}

//*****************************************************************************
// Function    : openWin(URL)
// Parameters  : URL with image information.
// Description : Opens new window with the image.
// Created     : 23-Jan-2008

//*****************************************************************************

function openWin(theURL,winName,features)
{
			var popLink;
			var PopWinView;
			var popWinName=winName;
			var e=document.getElementById("MainImage");
			if (e!="" && popWinName=="ImageView")
			{
				popLink=e.src;
				//alert(popLink);
				PopWinView=window.open(popLink,winName,features);}
			else
			{
				popLink=theURL;
				PopWinView=window.open(popLink,winName,features);}
}

function openPrintWin(theURL,winName,features)
{
	var PopWinView;
	//alert ('theURL:'+theURL);
	var e= document.getElementById("printRef");
	//alert('href '+e.href);
	var e2 = document.getElementById("imgProductGuid");
	//alert('e2.value: '+e2.value);
	var URL =theURL+e2.value;
	//alert('URL'+URL);
	//e.href=e2.value;
	//alert('href after: '+e.href);
	PopWinView=window.open(URL,winName,features);
}


function   Cookie(){  
  //Cookie.set(String   sName,String   sValue,[Date   dHours,String   sRegion,String   sPath,String   sDomain,Boolean   bSecure])  
  this.set=function(sName,sValue,dHours,sRegion,sPath,sDomain,bSecure){  
  var   str=new   String();  
  var   nextTime=new   Date();  
  nextTime.setHours(nextTime.getHours()+dHours);//   set expiry hours 
  sValue=escape(sValue);//   Encode value 
  if(sRegion){//   if got subkey  
  var   tValue=this.get(sName,"",true);//   get main key value(include subkeys)  
  var   tStr=tValue.replace(new   RegExp("\\b("+sRegion+"=)[^\\&]+\\b","i"),"$1"+sValue);//   find and replace in value got, replace value of the subkey 
  if(RegExp.$1)//   if replace succeed  
  str=sName+"="+tStr;//   set Main key value  
  else//   if not succeed  
  str=sName+"="+sRegion+"="+sValue+(/=/.exec(tValue)?"&"+tStr:"");//   write the value, if already set, write original value  
  }  
  else//   if no subkey indicated  
  str=sName+"="+sValue;  
  if(dHours)//   If set expire Hours 
  str+=";expires="+nextTime.toGMTString();  
  if(sPath)//   If set path  
  str+=";path="+sPath;  
  if(sDomain)//   set domain 
  str+=";domain="+sDomain;  
 if(bSecure)//   secure cookie?
  str+=";secure";  
  document.cookie=str;  
  }  
  //Cookie.get(String   sName,[String   sRegion,Boolean   bCode])  
  this.get=function(sName,sRegion,bCode){  
  var   rs=new   RegExp("(^|)"+sName+"=([^;]*)(;|$)","g").exec(document.cookie);//   search in main key 
  if(sRegion&&rs){//   if indicated subkey and main key not empty  
  var   rs1=new   RegExp("(^|)"+sRegion+"=([^\&]*)(\&|$)","g").exec(rs[2]);//   search in subkey  
  return   rs1?bCode?rs1[2]:unescape(rs1[2]):"";//   return value in subkey 
  }  
  else{  
  return   rs?bCode?rs[2]:unescape(rs[2]):"";//   return value in main key  
  }  
  }  
  //Cookie.remove(String   sName)  
  this.remove=function(sName){  
  this.set(sName,"",-1);  
  }  
  }  
   
function   SetCookie(sName,sValue,dHours,sRegion,sPath,sDomain,bSecure){
	
	var   _s=new   Cookie();  
    _s.set(sName,sValue,dHours,sRegion,sPath,sDomain,bSecure);  
	window.location=window.location.href;
}


/********************************************************************* 
Function	: setShipCookie(cookieName,CookieValue,expiryDate,form,url)
Parameter	: Name,value and date of expiration for product cookie. 
   			  Name&Value=Product NO,Date=0, form values, url(shipping.asp) for page reload
Description	: Creates drpCountry,drpShipMethod cookie for selected country value 
			  and shipping method respectively.
			  
***********************************************************************/

function setShipCookie(name,days,form,url)
{
	if (name=='drpCountry')
	{
		var countryVal=form.CountryGuid.options[form.CountryGuid.options.selectedIndex].value;
		if (days) 
		{
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+escape(countryVal)+expires+"; path=/";
		var cokie=document.cookie;
	}
	else if (name=='drpShipMethod')
	{
		var ShipMethods=form.ShipMethods.options[form.ShipMethods.options.selectedIndex].value;
		if (days) 
		{
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
			else var expires = "";
			document.cookie = name+"="+ShipMethods+expires+"; path=/";
			var cokie=document.cookie;

	}
	window.location=url;
	
}

/********************************************************************* 
Function	: setQuickCookie(form,url)
Parameter	: Form Fields are passed as parameters and url for page redirection.
Description	: Creates Product Item No cookie for Left quick pad. 
Sets the Cookie Leftquickpad with the values from 5 item No text boxes and Quantities
First checks Special characters in the Item No.If found then sets boolean bitemSplMsg value as TRUE

***********************************************************************/

function setQuickCookie(form,url)
{  
	

	var itemNoarray1=new Array(form.itemNo0.value,form.itemNo1.value,form.itemNo2.value,form.itemNo3.value,form.itemNo4.value);
    var quanArray1=new Array(form.Quantity0.value,form.Quantity1.value,form.Quantity2.value,form.Quantity3.value,form.Quantity4.value);
	var splCharItem=new Array(5);
	var splCharQuan=new Array(5);
	/*Check for existing item no's */
	
Array.prototype.has = function(value1) 
	{
		var i,loopcnt,value1,value2;
		//alert(loopcnt);
		//alert(value1);
		for (var i = 0;i < 5; i++) 
		{
			if(this[i] ==value1) 
			{
			//alert('inside'+i);
			return true;
			}
			
		}
		//alert('outside');
		return false;
	};
	
	var itemNoarray2=new Array(form.itemNo0.value,form.itemNo1.value,form.itemNo2.value,form.itemNo3.value,form.itemNo4.value);
	//alert(itemNoarray2[0]);
	//itemNoarray2[0] = form.itemNo1.value;
	//alert(itemNoarray2.has(form.itemNo1.value)); // Should display true
	//alert(arr.has('test2')); // Should display false



	
try//************** check for spl char.	******************
	{
		for(var i=0;i<itemNoarray1.length; i++)
		{
				var comp=itemNoarray1[i];
				var quantity=quanArray1[i].length;
				var quanSpl=quanArray1[i];
				//Check 1: Number of characters in the item no textbox.Limited to 25 characters
				if(comp.length>=25)
				{
				alert("Number of Characters in  "+itemNoarray1[i]+" exceeds Max limit. Pls Chk the item No.."); 
				var bitemCnt=true;
				}
				//Check 2: Number of digits in quantity textbox. Limited to 4 digits.
				if(quantity>4)
				{
				alert("Quantity for "+itemNoarray1[i]+" exceeds Max limit. Pls Chk the Quantity value.."); 
				var bquanCnt=true;
				}
				//Check 3: For  special characters and alphabets in quantity textbox.
				if(quantity<=4 && quanSpl!=="" )
				{
					var iChars = "!@#$%^&*()+=-[]\\\';,/{}|\":<>?abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
					for (var k=0;k<quanSpl.length;k++)
					{
						if(iChars.indexOf(quanSpl.charAt(k)) !==-1)
						{
						splCharQuan[i]=","+itemNoarray1[i];
						var bquansplMsg=true;
						}
						else splCharQuan[i]=" ";
					}
				}
				else splCharQuan[i]=" ";
			// Check 4: Special characters in item No textbox
				var iChars = "!@#$%^&*+=[]\\\';,{}|\":<>?";
				//Removed (),-,/  characters as, some ProductGuid has these characters. 

				if(comp!=="")
				{
					for (var k=0;k<comp.length;k++)
					{
						if(iChars.indexOf(comp.charAt(k)) !==-1)
						{
						splCharItem[i]=","+comp;
						var bitemSplMsg=true;
						}
						else splCharItem[i]=" ";
					}
				}
				else splCharItem[i]=" ";
			
		}
			//Msg display for special characters in item no and quantity.
			if(bitemSplMsg==true)
			{var splCharItems=splCharItem[0]+splCharItem[1]+splCharItem[2]+splCharItem[3]+splCharItem[4];
			splCharItems=splCharItems.substr(1,splCharItems.length);
			alert("Invalid Characters in following Item(s).\nPlease Check the same.\n Item No(s). "+splCharItems);}
			if(bquansplMsg==true)
			{var splCharQuans=splCharQuan[0]+splCharQuan[1]+splCharQuan[2]+splCharQuan[3]+splCharQuan[4];
			splCharQuans=splCharQuans.substr(1,splCharQuans.length);
			alert("Invalid Characters for Quantity in following Item(s).\nPlease Check the same.\n Item No(s). "+splCharQuans);}
			
	}
	catch(err)
	{alert(" Error in Spl Char Check :"+err.description);	}
//**************End of check for spl char.	******************
try//***********SET Cookie Array ************//
	{if(bitemSplMsg!==true && bitemCnt!==true && bquanCnt!==true && bquansplMsg!==true )
	{
		var itemNoarray=new Array(form.itemNo0.value,form.itemNo1.value,form.itemNo2.value,form.itemNo3.value,form.itemNo4.value);
		var quanArray=new Array(form.Quantity0.value,form.Quantity1.value,form.Quantity2.value,form.Quantity3.value,form.Quantity4.value);
		var cookieArray= new Array();
		var cookieValue="";
		var itemCount=0;
		for(i=0;i<=4;i++)
		{
			if(itemNoarray[i]!=="")
			{itemCount=itemCount+1;	}
			if(itemNoarray[i]!=="" && quanArray[i]=="")// Cond 1: If item No is NOT empty and quantity is empty, Set quantity=1 
			{
				quanArray[i]=1;
				cookieArray[i]=itemNoarray[i]+"="+quanArray[i];
			}
			else if(itemNoarray[i]!=="" && quanArray[i]!=="")//Cond 2: If item No and quantity both are NOT empty.
			{cookieArray[i]=itemNoarray[i]+"="+quanArray[i];}
			else if(itemNoarray[i]=="" && quanArray[i]=="") //Cond 3: If item No and quantity both are empty.
			{cookieArray[i]="";	}
			else if(itemNoarray[i]=="" && quanArray[i]!=="")// Cond 4: If item No is empty and quantity is NOT empty. 
			{cookieArray[i]="";	}
			if(cookieArray[i]!=="")
			{cookieValue=cookieArray[0]+"&"+cookieArray[1]+"&"+cookieArray[2]+"&"+cookieArray[3]+"&"+cookieArray[4];}
		}//***********SET Cookie Array ************//
		
	}
	//***********Check for Leftquickpad existance ************//
	try
	{
		
	  var arg = "Leftquickpad"+"=";
	  var alen = arg.length;
	  var clen = document.cookie.length;
	  var i = 0;
	  while (i < clen) 
	  {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) 
		{
			var endstr = document.cookie.indexOf (";", j);
			if (endstr == -1) 
			{ 
			//alert('insideloop'+i+","+j +","+endstr);
			endstr = document.cookie.length; 
			}
			var exisval= unescape(document.cookie.substring(j, endstr));
			//alert("existing value"+exisval);
			
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
		}
	}
	catch(err)
	{ alert("Error in check for cookie existance "+err.description);}
 //***********End of Check for Leftquickpad existance ************//
  
 //********Cookie Creation******************//
 
		var days=0;//Expiry date set to 0. Cookies expire when browser is closed.
		var name="Leftquickpad";
		cookieValue=cookieValue+"&"+exisval;
		if (days) 
		{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+escape(cookieValue)+expires+"; path=/";

	} //********End of Cookie Creation******************//
	catch(err)
	{alert("Error in cookie creation "+err.description);}
	if(bitemSplMsg!==true && bitemCnt!==true && bquanCnt!==true && bquansplMsg!==true )//IF special char message not set then reload the page.
	{window.location=url;}
	
}

/********************************************************************* 
Function	: deleteQuickCookie(name,cookievalue,url)
Parameter	: Name of the cookie, cookievalue and url to reload the page.
Description	: Confirms deletion and replace the cookievalue 
with empty string in the leftquickpad cookie
***********************************************************************/

function deleteQuickCookie(cookieName,cookieRow,url)
{
	var bdelConfirm;
	if (confirm("Are you sure you want to delete the item from quickpad?")==true)
    bdelConfirm=true;
  	else
    bdelConfirm=false;
	try//***** Check for cookie existance. Search and replace the cookie value*******//
	{
	if(bdelConfirm)
	{
	  var toRep=cookieRow;
	 // alert(toRep);
	  //var subitem=cookieRow.substring(0,cookieRow.length-2);
	  var cookieRowLen=cookieRow.length;
	  var arg = cookieName+"=";
	  var alen = arg.length;
	  var clen = document.cookie.length;
	  var i = 0;
	  while (i < clen) 
	  {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) 
		{
			var endstr = document.cookie.indexOf (";", j);
			if (endstr == -1) { endstr = document.cookie.length; }
			var exisval= unescape(document.cookie.substring(j, endstr));
  		 	//alert("value exist" +exisval);
			var exisval=exisval.replace(toRep,"");//Replace the cookie value with empty string.
			//alert("repvalue is:" +exisval);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
		}
		
		//*******Cookie creation with replaced value****************//
		var days=0;
		var name=cookieName;
		//cookieValue=cookieValue+"&"+exisval;
		if (days) 
		{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+escape(exisval)+expires+"; path=/";
		window.location=url;
		//alert(name+"Item Deleted "+cookieRow);
	}
		else(bdelConfirm==false)
		{window.location=url;}

  }
	catch(err)
	{alert("Error in cookie deletion "+err.description);}
	
	
}


/********************************************************************* 
Function	: setProCookieNew(name,value,days,url)
Parameter	: "ProductCookie",product number , expiry date and url for page redirection.
Description	: Creates Product Item No cookie for Left quick pad. 
Sets the Cookie Leftquickpad with the values from 5 item No text boxes and Quantities
First checks Special characters in the Item No.If found then sets boolean bitemSplMsg value as TRUE

***********************************************************************/
function setProCookieNew(name,value,days,url)
{
try
{
 	var arg = "chkstock"+"=";
	  var alen = arg.length;
	  var clen = document.cookie.length;
	  var i = 0;
	  while (i < clen) 
	  {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) 
		{
			var endstr = document.cookie.indexOf (";", j);
			if (endstr == -1) { endstr = document.cookie.length; }
			var exisval= unescape(document.cookie.substring(j, endstr));
  		 	alert("value exist" +exisval);
			//var exisval=exisval.replace(value,"");//REPLACE FUNC
			//alert("repvalue is:" +exisval);
			//COOKIE CREATION
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
		var days=0;
		var name="chkstock";
		var value=1;
		if(exisval!=="")
		{
		//value=value+"&"+exisval;
		value=parseInt(exisval)+parseInt(1);
		}
		else if (exisval="")
		 {
		 value=1;
		alert(value);
		alert('value2'+value);
		 }

		if (days) 
		{
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		
		value=Number(value);
		document.cookie = name+"="+value+expires+"; path=/";
		alert("cookie created"+document.cookie);

	}//END OF TRY
	catch(err)
	{alert("in check for existing value 1"+err.description);}
	//document.location.reload();
	//window.location=url;
	
}

/********************************************************************* 
Function	: formSubmit(buttonid,linkurl)
Parameter	: button clicked(Purchase or Enquiry) and url for page submit.
Description	: quickpad page is submitted to _cart.asp if "Purchase" Button clicked
or to enquiry.asp if "Enquiry" button clicked.
***********************************************************************/


function formQuickSubmit(buttonid,linkurl)
{
	var myForm=document.getElementById('formQuickPad');
	var url;
	if(buttonid=="Purchase")
	{url=linkurl;}
	else if(buttonid=="Enquiry")
	{url=linkurl;}
	formQuickPad.setAttribute("action",url);
	formQuickPad.setAttribute("method","post");
	formQuickPad.submit();
}

/********************************************************************* 
Function	: productImageLink(productLink)
Parameter	: product link to display large image of the selected product small image.
Description	: onclick of product small image, page displays the Larger image, 
			by setting the main image source(MainImage.src) link dynamically
***********************************************************************/

function productImageLink(productLink,picturename)
{
	var e=document.getElementById("MainImage");
 	var e2= document.getElementById("imgProductGuid");
//checked for print other views
	e2.value=picturename;
	//alert('imgProductGuid= '+e2.value);
	//alert('picturename'+picturename);
	e.src=productLink;
	//alert("Main Image source:"+e.src);
}

/********************************************************************* 
Function	: emailValidation()
Parameter	: Nil.
Description	: function is called on submit of enquiry page. check  
			for user name and email id not null values. If null then alert 
			messages displayed.
			Validation for Email Id .
			If invalid then alert msg displayed.
			Once all the validation cleared form is submitted.
***********************************************************************/

function emailValidation()
{
	 //var userName=document.formEnq.UserName.value;
	//var EmailID=document.formEnq.EmailID.value;
	var userName=document.getElementById('userName').value;
	var EmailID=document.getElementById('EmailID').value;
	var enqType=document.getElementById('enqType').value;
	var txtUserEnq=document.getElementById('txtEnq').value.length;
	var blnUserName;
	var blnEmailID;
	var blnenqType;
	var blnValidEmail;
	var blnTxtUserEnq;
	if(userName=="")
	{
		alert("User Name cannot be blank");
		blnUserName=false;
	}
	else if(userName!="")
	  blnUserName=true;
	if(enqType=='Null')
	{
		alert("Select a request");
		blnenqType=false;
	}
	else
	blnenqType=true;
	
	if(EmailID=="")
	{
		alert("Email ID cannot be blank");
		blnEmailID=false;
	}
	else if(EmailID!="")
	{
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if(filter.test(EmailID))
		{
		blnValidEmail=true;
		blnEmailID=true;
		}
		else
		{
			alert("Invalid Email Address. Please check the same");
			blnValidEmail=false;
			blnEmailID=true;
		}
	}
//To check empty textarea
	if(txtUserEnq<=0)
	{
		alert("Please enter your enquiry/feedback.");
		blnTxtUserEnq=false;
	}
	else if(txtUserEnq!="")
	blnTxtUserEnq=true;
	if (blnUserName && blnEmailID && blnValidEmail &&blnTxtUserEnq &&blnenqType)
	{
		return true 
	}
	else 
	return false
}
/************************END of Email Check *****************/

					function deleteQuickCookie1(cookieName,cookieRow,URL)
					{
						/*var days=0;
						var name="Leftquickpad";
						var	cookieValue=document.getElementById("leftCookie").value;
						alert("cookieValue==="+cookieValue);
						if (days) 
						{
						var date = new Date();
						date.setTime(date.getTime()+(days*24*60*60*1000));
						var expires = "; expires="+date.toGMTString();
						}
						else var expires = "";
						document.cookie = name+"="+escape(cookieValue)+expires+"; path=/";
						function deleteQuickCookie(cookieName,cookieRow,url)*/

	var bdelConfirm;
	if (confirm("Are you sure you want to delete the item from quickpad?")==true)
    bdelConfirm=true;
  	else
    bdelConfirm=false;
	try//***** Check for cookie existance. Search and replace the cookie value*******//
	{
	if(bdelConfirm)
	{
	 
		
		//*******Cookie creation with replaced value****************//
		var days=0;
		var name=cookieName;
		//cookieValue=cookieValue+"&"+exisval;
		if (days) 
		{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+escape(cookieRow)+expires+"; path=/";
		window.location=URL;
		//alert(name+"Item Deleted "+cookieRow);
	}
		else(bdelConfirm==false)
		{window.location=URL;}

  }
	catch(err)
	{alert("Error in cookie deletion "+err.description);}
	
	
}
//*****************************************************************************
// Function    : SetPopularIndexValue
// Description :
// Created     : 18-Sep-2008
 //*****************************************************************************

function SetPopularIndexValue(textId,textValue)
{
	var value=document.getElementById(textId).value;
	document.getElementById('Hidden-'+textId).value=value;
	document.getElementById('productid-'+textId).value=textId;
	document.getElementById('Update').disabled=false;
}

function message(blnSent)

{
	var blnSent=blnSent;
	//alert('bln'+blnSent);
	if (blnSent=='True')
	{
	document.getElementById('frmReq').style.visibility='hidden';
	document.getElementById('message').style.visibility='visible';
	//alert('bln2'+blnSent);
	}
	else
	{
	document.getElementById('message').style.visibility='hidden';
	document.getElementById('frmReq').style.visibility='visible';
	//alert('bln3'+blnSent);
	}
}

function textMsg(textNow,textAct)
{
	var textNow1,textAct1;
	textNow1=textNow.value;
	textAct1=textAct;
	alert("textNow1"+textNow1);
	alert("textAct1"+textAct1);
	if(textNow1!=textAct1)
	{
	textNow.style.backgroundColor = '#D0F5A9';
	alert("value changed");
	}
	else if (textNow1==textAct1)
	{
		textNow.style.backgroundColor='#FFFFFF';
		alert("value not changed");
	}
 return true;
}

function enableDiv(selCtry)

{
	var selCtry=selCtry;
	 alert('value'+selCtry);
	 if (selCtry='')
	{
	document.getElementById('divUserAdd').style.visibility='hidden';
	document.getElementById('selCountry').style.visibility='visible';
	//alert('bln2'+blnSent);
	}
	else
	{
	document.getElementById('selCountry').style.visibility='hidden';
	document.getElementById('divUserAdd').style.visibility='visible';
	//alert('bln3'+blnSent);
	}
}

/* function enableDiv(selCtry)
 {
	 var selCtry=selCtry;
	 alert(selCtry);
	 if (selCtry=='')
	 {
		 document.getElementById('selCountry').style.visibility='visible';
 		 document.getElementById('divUserAdd').style.visibility='hidden';
	 }
	 else if(selCtry!=='')
	 {
   		 document.getElementById('selCountry').style.visibility='hidden';
 		 document.getElementById('divUserAdd').style.visibility='visible';
	 }
 }*/
	
 function GoTo(url)
{	
if(url !=="")
{
 window.location=url;
}
else
alert('Selezionare un opzione riportato di seguito');
}
  	
	function message2(blnSent)

{
	var blnSent=blnSent;
	//alert('bln'+blnSent);
	if (blnSent=='True')
	{
		 
	document.getElementById('tableForm').style.visibility='hidden';
	document.getElementById('messageFlase').style.visibility='hidden';
	document.getElementById('message').style.visibility='visible';
	//alert('bln2'+blnSent);
	}
	else if(blnSent=='False')
	{
		 
	document.getElementById('tableForm').style.visibility='visible';
	document.getElementById('message').style.visibility='hidden';
	document.getElementById('messageFlase').style.visibility='visible';
	}
	else
	{
		 
	document.getElementById('message').style.visibility='hidden';
	//document.getElementById('messageFlase').style.visibility='hidden';
	document.getElementById('tableForm').style.visibility='visible';
	//alert('bln3'+blnSent);
	}
	
}


/********************************************************************************* 
Function	: writeCookie(name)
Parameter	: value ; cookie value to write in chkstock2 cookie
Description	: Function called to write cookie value

**********************************************************************************/
 
function writeCookie(value)
{
	 //alert(value);
	 var name="chkstock2";
	 var days=1;
	 var value = parseInt(value);
	 var expires;
	 var path ='/';
	 if(days)
	 {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			expires = date.toGMTString();
	 }
	 else
	 {
		 expires="";
	 }
	document.cookie = name +'=' + value +'; expires=' + expires +'; path=' + path;
	// alert(document.cookie)
	return document.cookie
	//var read =  readCookie('chkstock2');
// alert('read'+(read));
}

/********************************************************************************* 
Function	: readCookie(name)
Parameter	: name; cookie name  
Description	: Function called to return existing cookie value

**********************************************************************************/


function readCookie(name)
{
	var name = name+'=';
	var cookieArray = document.cookie.split(';');
	var eachCookie;
	var i;
	var bexist;
	var existval;
	for (i=0;i<cookieArray.length;i++)
	{
		var eachCookie = cookieArray[i];
		while(eachCookie.charAt(0)==' ') eachCookie =eachCookie.substring(1,eachCookie.length);
		if(eachCookie.indexOf(name) == 0 )
		{ bexist =true;
		existval = eachCookie.substring(name.length,eachCookie.length);
		}
	}
	return existval;
}


/********************************************************************************* 
Function	: onPageLoad2(name,blnproduct)
Parameter	: name; cookie name , blnproduct; check for product template.
Description	: Function called on page load event to intialize write stock display 
			cookie , also checks the existing cookie value if value is less than 
			upper limit(10 counts) and enables the display of inventory value,
			if exceeds upper limit, then shows the contact us link.
Other function call:readCookie(name)
					writeCookie(value)	

**********************************************************************************/


function onPageLoad2(name,blnproduct)
{
 //check if product page
	if(blnproduct=='True')
	{
		var readvalue = readCookie(name);
		//alert(readvalue);
		if(readvalue)
		{
			if(readvalue<10)
			{
 			document.getElementById('chkstocklink').style.visibility='visible';
 			 document.getElementById('invDisplay').style.visibility='hidden';
			document.getElementById('invDisplayYes').style.visibility='hidden';
			document.getElementById('invDisplayNo').style.visibility='hidden';
			document.getElementById('contactUsLink').style.visibility='hidden'; 
 			}
			else if(readvalue>=10)
			{
 			document.getElementById('chkstocklink').style.visibility='hidden';
			document.getElementById('invDisplay').style.visibility='hidden';
 			document.getElementById('invDisplayYes').style.visibility='hidden';
			document.getElementById('invDisplayNo').style.visibility='hidden';
			document.getElementById('contactUsLink').style.visibility='visible'; 
 			}
		}
		else
		{
		document.getElementById('chkstocklink').style.visibility='visible';
		document.getElementById('invDisplay').style.visibility='hidden';
		document.getElementById('invDisplayYes').style.visibility='hidden';
		document.getElementById('invDisplayNo').style.visibility='hidden';
		document.getElementById('contactUsLink').style.visibility='hidden';
		var loadCookie=	writeCookie(parseInt(0));
		//alert(loadCookie);
		}
	}//end of product check

}

/********************************************************************************* 
Function	: chkStockNew()
Parameter	: name; cookie name
Description	: Function called to write stock display cookie , checking 
			the existing value if value is less than upper limit(10 counts), 
			then increments cookie value by 1 , and enables the display of 
			inventory value,if exceeds upper limit, then shows the contact us link.
Other function call: readCookie(name)
					writeCookie(value)
**********************************************************************************/


function chkStockNew(name,actualstock)
{
	var actualstock =actualstock;
 	var txtstock = document.getElementById('txtQuantity').value;
 	var blnstockexists;
 	if (txtstock>0 && txtstock!="")
	{
 		if(txtstock>actualstock)
		{
 			blnstockexists='False'
 		}
		else if(txtstock<=actualstock)
		{
 			blnstockexists='True'
 		}
		
	}
 	
	var readvalue = readCookie(name);
		if(readvalue<10)
		{
		//alert('readvalue<3'+readvalue)	 ;
		document.getElementById('chkstocklink').style.visibility='visible';
		if(blnstockexists=='True')
		{//alert('inside true');
		document.getElementById('invDisplayYes').style.visibility='visible';
		document.getElementById('invDisplayNo').style.visibility='hidden';
		}
		else if(blnstockexists=='False')
		{//alert('inside false');
		document.getElementById('invDisplayYes').style.visibility='hidden';
		document.getElementById('invDisplayNo').style.visibility='visible';
		}
		document.getElementById('contactUsLink').style.visibility='hidden';
		var loadCookie=	writeCookie(parseInt(readvalue)+1);
		//alert(loadCookie);
		}
		else if(readvalue>=10)
		{
		//alert('readvalue>=3'+readvalue);
		document.getElementById('chkstocklink').style.visibility='hidden';
		document.getElementById('invDisplayYes').style.visibility='hidden';
		document.getElementById('invDisplayNo').style.visibility='hidden';
		document.getElementById('contactUsLink').style.visibility='visible'; 
		var loadCookie=	writeCookie(parseInt(readvalue));
		//alert(loadCookie);
 		}
  
}

/********************************************************************************* 
Function	: chkSplChar()
Parameter	: name; cookie name, actualstock
Description	: Function called to check special character entered if any in quantity 
textbox. If invalid characters exists displays warning message to user, else calls 
chkStocknew function to update cookie value.
Other function call: chkStockNew(name,actualstock)
					
**********************************************************************************/


function chkSplChar(name,actualstock)
{
	var txtstock = document.getElementById('txtQuantity').value;
	var blnsplcharexist='False';
	//check whether quantity not null and also greater than zero 
	if(txtstock=="")
	{
		alert('Quantity not entered.\nPlease try again..');
		blnsplcharexist='True' ;
 	}
	else if(txtstock==0)
	{
		alert('Enter quantity greater than zero..');
		blnsplcharexist='True' ;
	}
	//check special character entry in the textbox and then proceed further with other checks
	var iChars = "!.`~@#$%^&*()+=-_[]\\\';,/{}|\":<>?abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 	for (var k=0;k<txtstock.length;k++)
	{
		if(iChars.indexOf(txtstock.charAt(k)) !==-1)
		{
		 blnsplcharexist='True' 
		 alert('Entered an invalid character.\nPlease try again..');
		 break;
 		}
 	}	
	//alert('final'+blnsplcharexist);
	if(blnsplcharexist=='True')
	{
		//just display the check availability divs
		document.getElementById('chkstocklink').style.visibility='visible';
		document.getElementById('invDisplayYes').style.visibility='hidden';
		document.getElementById('invDisplayNo').style.visibility='hidden';
		document.getElementById('contactUsLink').style.visibility='hidden'; 
		//var loadCookie=	writeCookie(parseInt(readvalue));
		//alert(loadCookie);
	}
	else if(blnsplcharexist=='False')
	{
		 chkStockNew(name,actualstock)
	}
	
}
/*Display none try functions*/

function onPageLoad4(name,blnproduct)
{
 //check if product page

  	var textContactUs = document.getElementById("invContact").value;
	if(blnproduct=='True')
	{
		var readvalue = readCookie(name);
 		if(readvalue>0)
		{
			if(readvalue<10)
			{
				//alert('inside1');
				//createText
 			document.getElementById('chkstocklink').style.display='inline';
  			}
			else if(readvalue>=10)
			{
 			document.getElementById('chkstocklink').style.display='none';
			createDiv(textContactUs);
			document.getElementById("stockmsg").style.visibility='visible';
 			}
		}
		else
		{

//alert('inside2');
//createText
		document.getElementById('chkstocklink').style.display='inline';
		var loadCookie=	writeCookie(parseInt(0));
		//alert(loadCookie);
		}
	}//end of product check

}

/********************************************************************************* 
Function	: chkStockNew2()
Parameter	: name; cookie name
Description	: Function called to write stock display cookie , checking 
			the existing value if value is less than upper limit(10 counts), 
			then increments cookie value by 1 , and enables the display of 
			inventory value,if exceeds upper limit, then shows the contact us link.
Other function call: readCookie(name)
					writeCookie(value)
**********************************************************************************/


function chkStockNew2(name,actualstock)
{
	var actualstock =actualstock;
 	var txtstock = document.getElementById('txtQuantity').value;
 	var blnstockexists;
	var textInvYes =  findreplace(document.getElementById("invYes").value,txtstock);
  	var textInvNo = findreplace(document.getElementById("invNo").value,txtstock);
  	var textContactUs = document.getElementById("invContact").value;
  	if (txtstock>0 && txtstock!="")
	{
 		if(txtstock>actualstock)
		{
 			blnstockexists='False'
 		}
		else if(txtstock<=actualstock)
		{
 			blnstockexists='True'
 		}
		
	}
 	
	var readvalue = readCookie(name);
 		if(readvalue<20)
		{
			document.getElementById('chkstocklink').style.display='inline';
			if(blnstockexists=='True')
			{
 				createDiv(textInvYes);
				document.getElementById("stockmsg").style.visibility='visible';
			}
			else if(blnstockexists=='False')
			{
 				createDiv(textInvNo)  ;
 				document.getElementById("stockmsg").style.visibility='visible';
 
			}
			var loadCookie=	writeCookie(parseInt(readvalue)+1);
 		}
		else if(readvalue>=20)
		{
 		document.getElementById('chkstocklink').style.display='none'; 
		createDiv(textContactUs);
		document.getElementById("stockmsg").style.visibility='visible';
 		var loadCookie=	writeCookie(parseInt(readvalue));
  		}
  
}

/********************************************************************************* 
Function	: chkSplChar2()
Parameter	: name; cookie name, actualstock
Description	: Function called to check special character entered if any in quantity 
textbox. If invalid characters exists displays warning message to user, else calls 
chkStocknew function to update cookie value.
Other function call: chkStockNew2(name,actualstock)
					
**********************************************************************************/


function chkSplChar2(name,actualstock)
{
	//clear stock message div content if any.
	var stockmsg =document.getElementById("stockmsg");
	while (stockmsg.childNodes[0])  
	{    
		stockmsg.removeChild(stockmsg.childNodes[0]);
	}
	var txtstock = document.getElementById('txtQuantity').value;
 	var blnsplcharexist='False';
	//check whether quantity not null and also greater than zero 
	if(txtstock=="")
	{
		alert('Quantity not entered.\nPlease try again..');
		blnsplcharexist='True' ;
 	}
	else if(txtstock==0)
	{
		alert('Enter quantity greater than zero..');
		blnsplcharexist='True' ;
	}
	//check special character entry in the textbox and then proceed further with other checks
	var iChars = "!.`~@#$%^&*()+=-_[]\\\';,/{}|\":<>?abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 	for (var k=0;k<txtstock.length;k++)
	{
		if(iChars.indexOf(txtstock.charAt(k)) !==-1)
		{
		 blnsplcharexist='True' 
		 alert('Entered an invalid character.\nPlease try again..');
		 break;
 		}
 	}	
 	if(blnsplcharexist=='True')
	{
		//just display the check availability divs
		document.getElementById('chkstocklink').style.display='inline';
 	}
	else if(blnsplcharexist=='False')
	{
 		 chkStockNew2(name,actualstock)
	}
	
}
/************************************************************************************
Function:createDiv(divtext)
Description: To create html elments dynamically, based on current stock cookie value
Parameter: divtext,htmltext to be written
Related functions:
onPageLoad3,chkStockNew2
*************************************************************************************/
function createDiv(divtext)
{
 	var pTag = document.createElement("p");
	pTag.setAttribute("align","left");
	pTag.innerHTML = divtext;
	//alert(pTag.innerHTML);
	var stockmsg =document.getElementById("stockmsg");
	while (stockmsg.childNodes[0])  
	{    
		stockmsg.removeChild(stockmsg.childNodes[0]);
	}
	document.getElementById("stockmsg").appendChild(pTag);
	//document.getElementById("txtQuantity").value="";
 }


function createDivContact(divtext)
{
	var pTag = document.createElement("span");
	pTag.setAttribute("align","left");
	pTag.innerHTML = divtext;
	var stockmsg =document.getElementById("stockmsg");
	while (stockmsg.childNodes[0])  
	{    
		stockmsg.removeChild(stockmsg.childNodes[0]);
	}
	document.getElementById("stockmsg").appendChild(pTag);

}


function createText()
{
	var pInp = document.createElement("input");
 	pInp.setAttribute("type","textbox");
	pInp.setAttribute("size","5");
	pInp.setAttribute("id","txtQuantity2");
	//pInp.innerHTML = divtext;
	var stockmsg =document.getElementById("divQuantity");
	while (stockmsg.childNodes[0])  
	{    
		stockmsg.removeChild(stockmsg.childNodes[0]);
	}
	document.getElementById("divQuantity").appendChild(pInp);
	 var pButton = document.createElement("input");
	var btnClick = document.getElementById("btnOnClick").value;
	//alert('btnClick'+btnClick);
	pButton.setAttribute("type","button");
	pButton.setAttribute("id","btnChkStock2");
	pButton.setAttribute("class","textButtonInfo3");
	pButton.setAttribute("value","Check Stock");
	pButton.setAttribute("onclick",btnClick);
	document.getElementById("divQuantity").appendChild(pButton); 
}

/***********************************************************************************************
Function:findreplace
Description: Find special characters in text and replace with use entered quantity value
Parameter: divtext ; actual string to be checked for special characters, quantity;textbox value
Related functions: Javascript RegExp , replace functions. 
************************************************************************************************/
function findreplace(divtext,quantity)
{
	var acttext = divtext;
	var substrng = new RegExp( "%1","");
 	acttext = acttext.replace(substrng,quantity)
 	return acttext;
}



/**************************************************************************************** 
Function	: onPageLoad3(name,blnproduct)
Parameter	: name; cookie name , blnproduct; check for product template.
Description	: Function called on page load event to intialize write stock display 
			cookie for products if inventory value is greater thatn zero, 
			also checks the existing cookie value if value is less than 
			upper limit(10 counts) and enables the display of inventory value,
			if exceeds upper limit, then shows the contact us link.
			If template is other than product, then rewrite the cookie value with current 
			value. else increments the cookie count.
Other function call:readCookie(name)
					writeCookie(value)	

******************************************************************************************/


function onPageLoad3(name,blnproduct)
{
	 
	//Check whether product template
  	if(blnproduct=='True')
	{
 		var readvalue = readCookie('chkstock2');
		var textContactUs = document.getElementById("invContact").value;
		if(readvalue)
		{
			if(readvalue<20)
			{
				 
 				 document.getElementById('chkstocklink').style.display='inline';
  			}
			else if(readvalue>=20)
			{ 
			 
 			document.getElementById('chkstocklink').style.display='none';
			createDiv(textContactUs);
  			}
		}
		else
		{
 
 		document.getElementById('chkstocklink').style.display='inline';
		var loadCookie=	writeCookie(parseInt(0));
		
		}
	}//end of product check
		
	// If not product template,  
	else if (blnproduct=='False')
	{
		 
		var readvalue = readCookie('chkstock2');
		if(readvalue)
		{	 
		 
			var loadCookie2=writeCookie(parseInt(readvalue));
 		}
		else
		{
  
  		var loadCookie3=writeCookie(parseInt(0));
  		}
	}
	
}
/********************************************************************************* 
Function	: later()
Parameter	: -
Description	: Function called after ccompleting product page load to set display for 
			catalog page number and download dwg file rows, which was set to hidden 
			when page loaded intially.
 
**********************************************************************************/


function later()
	{
	 
 	document.getElementById('divRight2').style.display='inline';
	document.getElementById('divRight3').style.display='inline';
	 
 	}
	
	/****************************************************************
Function:clearform
Desc: Used to clear textbox and hidden values in the called form

*****************************************************************/

function clearform(form)
{
var frm_elements = form.elements; 
for(i=0; i<frm_elements.length; i++) 
{
	field_type = frm_elements[i].type.toLowerCase();
	switch(field_type) 
	{
	
	case "text":
	case "password":
	case "textarea":
	case "hidden":
	
	frm_elements[i].value = "";
	break;
	
	case "select-one":
		case "select-multi":
            		elements[i].selectedIndex = -1;
			break;

		default: 
			break;
	
	}
}
}

function stockValidation()
{
	
	var prodcollection=document.getElementsByName('productno');
	var QTYcollection=document.getElementsByName('quantity');
	var emptycnt=0;
	for (i=0; i<prodcollection.length; i++)
	{
 		var prodid = prodcollection[i].value;
		if(prodid=="")
		emptycnt=emptycnt+1;
		else
		{
			//alert('else');
			//alert(prodid);
			emptycnt=emptycnt;
			//var blnsplcharexist=chkSplChar22(prodid);
			//alert(blnsplcharexist);
			/*if (blnsplcharexist=='True')
			{
				prodcollection[i].style.backgroundColor = '#D0F5A9';
			}*/
		}
	}
	for (i=0; i<QTYcollection.length; i++)
	{
 		var QTYid = QTYcollection[i].value;
 		if(QTYid=="")
		emptycnt=emptycnt+1;
		else
		emptycnt=emptycnt;
	}
	//alert('emptycnt:'+emptycnt);
	if(emptycnt==42)
	{
		alert(emptycnt);
	alert('All Fields Blank.\nPlease Enter Values..');
	return false;
	}
	else
	{
		return true;
	}
	
}

function formSubmit(buttonid,linkurl)
{
	var myForm=document.getElementById('formChkStock');
	var url=linkurl;
	myForm.setAttribute("action",url);
	myForm.setAttribute("method","post");
		myForm.setAttribute("target","_parent");
	if (stockValidation2())
	{
	myForm.submit();
	}
}


function emailValidation2()
{
	 //var userName=document.formEnq.UserName.value;
	//var EmailID=document.formEnq.EmailID.value;
	var userName=document.getElementById('userName').value;
	var EmailID=document.getElementById('EmailID').value;
 	var txtUserEnq=document.getElementById('txtEnq').value.length;
	var blnUserName;
	var blnEmailID;
 	var blnValidEmail;
	var blnTxtUserEnq;
	if(userName=="")
	{
		alert("User Name cannot be blank");
		blnUserName=false;
	}
	else if(userName!="")
	  blnUserName=true;
	 
	
	if(EmailID=="")
	{
		alert("Email ID cannot be blank");
		blnEmailID=false;
	}
	else if(EmailID!="")
	{
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if(filter.test(EmailID))
		{
		blnValidEmail=true;
		blnEmailID=true;
		}
		else
		{
			alert("Invalid Email Address. Please check the same");
			blnValidEmail=false;
			blnEmailID=true;
		}
	}

	if (blnUserName && blnEmailID && blnValidEmail )
	{
		return true 
	}
	else 
	return false
}

/************************END of Email Check *****************/

function formSubmit_newWindow(buttonid,linkurl,winName,features)
{
	var myForm=document.getElementById('formChkStock');
	var theURL=linkurl;
	var popLink;
	var PopWinView;
	var popWinName=winName;
	popLink=theURL;
	//alert(theURL);
	PopWinView=window.open('',winName,features);
	myForm.setAttribute("target",winName);
	myForm.setAttribute("action",theURL);
	myForm.setAttribute("method","post");
	myForm.submit();
}

function printAndSubmit()
{
window.print();
document.formChkStockPrint.submit();
}


function stockValidation2()
{
	
	var prodcollection=document.getElementsByName('productno');
	var QTYcollection=document.getElementsByName('quantity');
	var emptycnt=0;
	var blnsplcharexist='False';
	for (i=0; i<prodcollection.length; i++)
	{
 		var prodid = prodcollection[i].value;
		if(prodid=="")
		emptycnt=emptycnt+1;
		else
		{emptycnt=emptycnt;}
	}
	for (i=0; i<QTYcollection.length; i++)
	{
 		var QTYid = QTYcollection[i].value;
 		if(QTYid=="")
		emptycnt=emptycnt+1;
		else
		emptycnt=emptycnt;
	}
	//alert('emptycnt:'+emptycnt);
	if(emptycnt==42)
	{
	alert('All Fields Blank.\nPlease Enter Values..');
	return false;
	}
	else
	{
		for (i=0; i<QTYcollection.length; i++)
		{
			var QTYid = QTYcollection[i].value;
			if(QTYid!="")
			{
				var iChars = "!.`~@#$%^&*()+=-_[]\\\';,/{}|\":<>?abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
				for (var k=0;k<QTYid.length;k++)
				{
					if(iChars.indexOf(QTYid.charAt(k)) !==-1)
					{
					 blnsplcharexist='True' 
					 //alert('Entered an invalid character.\nPlease try again..');
					 QTYcollection[i].style.backgroundColor = '#D0F5A9';
					// break;
					// return false;
					}
				}	
				
 			}
		}
		if(blnsplcharexist=='True')
		{
		alert('Entered an invalid character(s).\nPlease try again..');
		return false;
		}
		else if(blnsplcharexist=='False')
		{return true;}
	}
	return true;
}
/********************************************************************************* 
Function	: validateChkStockText()
Parameter	: -
Description	: Func to check check stock textboxes entries before submitting to product
 			page. empty values, special characters in QTY textbox are checked.
**********************************************************************************/
function validateChkStockText()
{
 	var txtartno=document.getElementById('productno').value;
	var txtQTY=document.getElementById('quantity').value;
	var blnartno=true;
	var blnQTY=true;
 	var blnValidQTY=true;
	if(txtartno=="")
	{
		alert("Art.# cannot be blank");
		blnartno=false;
	}
	else if(txtartno!="")
	  blnartno=true;
	
	if(txtQTY=="")
	{
		alert("Quantity not entered.\nPlease try again..");
		blnQTY=false;
		blnValidQTY=false;
	}
	else if(txtQTY==0)
	{
		
		document.getElementById('quantity').style.backgroundColor = '#63BF87';
		blnValidQTY=false;
		blnQTY=true;
		alert('Enter quantity greater than zero..');
	}
	else if(txtQTY!="")
	{
		//check special character entry in the textbox and then proceed further with other checks
		var iChars = "!.`~@#$%^&*()+=-_[]\\\';,/{}|\":<>?abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		for (var k=0;k<txtQTY.length;k++)
		{
			if(iChars.indexOf(txtQTY.charAt(k)) !==-1)
			{
			blnValidQTY=false;
			blnQTY=true;
			document.getElementById('quantity').style.backgroundColor = '#63BF87';
			alert('Entered invalid character(s).\nPlease try again..');
			break;
			}
		}	
	}

	if (blnartno && blnQTY && blnValidQTY )
	{
		return true 
	}
	else 
	{
	return false}
}

/* Code for Image zoom  */

var MojoZoom = (function() {

	var $ = function(id) { return document.getElementById(id);};
	var dc = function(tag) { return document.createElement(tag);};

	var defaultWidth = 256;
	var defaultHeight = 256;

	function addEvent(element, ev, handler) 
	{
		var doHandler = function(e) {
			return handler(e||window.event);
		}
		if (element.addEventListener) { 
			element.addEventListener(ev, doHandler, false); 
		} else if (element.attachEvent) { 
			element.attachEvent("on" + ev, doHandler); 
		}
	}

	function getElementPos(element)
	{
		var x = element.offsetLeft;
		var y = element.offsetTop;
		var parent = element.offsetParent;
		while (parent) {
			x += parent.offsetLeft;
			y += parent.offsetTop;
			parent = parent.offsetParent;
		}
		return {
			x : x,
			y : y
		}
	}

	function getEventMousePos(element, e) {
		var scrollX = document.body.scrollLeft || document.documentElement.scrollLeft;
		var scrollY = document.body.scrollTop || document.documentElement.scrollTop;

		if (e.currentTarget) {
			var pos = getElementPos(element);
			return {
				x : e.clientX - pos.x + scrollX,
				y : e.clientY - pos.y + scrollY
			}
		}
		return {
			x : e.offsetX,
			y : e.offsetY
		}
	}

	function makeZoomable(img, zoomSrc, zoomImgCtr, zoomWidth, zoomHeight, alwaysShow) {
		// make sure the image is loaded, if not then add an onload event and return
		
		if (!img.complete && !img.__mojoZoomQueued) {
			addEvent(img, "load", function() {
				img.__mojoZoomQueued = true;
				setTimeout(function() {
				makeZoomable(img, zoomSrc, zoomImgCtr, zoomWidth, zoomHeight, alwaysShow);
				}, 1);
			});
			return;
		}

		img.__mojoZoomQueued = false;

		// Wrap everything in a timeout.
		// this fixes a problem where, if makeZoomable is called a second time after changing the src,
		// FF would not have figured out the new offsetHeight of the image yet. A small timeout helps though it's rather hackish.
		setTimeout(function(){

		// sorry
		var isIE = !!document.all && !!window.attachEvent && !window.opera;

		var w = img.offsetWidth;
		var h = img.offsetHeight;

		var oldParent = img.parentNode;
		if (oldParent.nodeName != "A") {
			var linkParent = dc("a");
			linkParent.setAttribute("href", zoomSrc);
			oldParent.replaceChild(linkParent, img);
			linkParent.appendChild(img);
		} else {
			var linkParent = oldParent;
		}

		linkParent.style.position = "relative";
		linkParent.style.display = "block";
		linkParent.style.width = w+"px";
		linkParent.style.height = h+"px";
//alert('linkwidth'+linkParent.style.width );
//alert('linkheight'+linkParent.style.height );
		var imgLeft = img.offsetLeft;
		var imgTop = img.offsetTop;

		var zoom = dc("div");
		zoom.className = "mojozoom_marker";

		var zoomImg = dc("img");
		zoomImg.className = "mojozoom_img";

		zoomImg.style.position = "absolute";
		zoomImg.style.left = "-9999px";
		zoomImg.style.top = "-9999px";

		document.body.appendChild(zoomImg);

		var parent = img.parentNode;

		var ctr = dc("div");
		with (ctr.style) {
			position = "absolute";
			left = imgLeft+"px";
			top = imgTop+"px";
			width = w+"px";
			height = h+"px";
			overflow = "hidden";
			display = "none";
		}

		ctr.appendChild(zoom);
		parent.appendChild(ctr);

		var zoomInput = parent;

		// clear old overlay

		if (img.__mojoZoomOverlay)
			parent.removeChild(img.__mojoZoomOverlay);
		img.__mojoZoomOverlay = ctr;

		// clear old high-res image
		if (img.__mojoZoomImage && img.__mojoZoomImage.parentNode)
			img.__mojoZoomImage.parentNode.removeChild(img.__mojoZoomImage);
		img.__mojoZoomImage = zoomImg;

		var useDefaultCtr = false;
		if (!zoomImgCtr) {
			zoomImgCtr = dc("div");
			zoomImgCtr.className = "mojozoom_imgctr";

			var imgPos = getElementPos(img);
			zoomImgCtr.style.left = w + imgPos.x + "px";
			zoomImgCtr.style.top = imgPos.y + "px";

			zoomImgCtr.style.width = (zoomWidth ? zoomWidth : defaultWidth) +"px";
			zoomImgCtr.style.height = (zoomHeight ? zoomHeight : defaultHeight) +"px";
//alert('width'+zoomImgCtr.style.width);
//alert('height'+zoomImgCtr.style.height);
			document.body.appendChild(zoomImgCtr);
			useDefaultCtr = true;
		}
		zoomImgCtr.style.overflow = "hidden";

		if (!alwaysShow) {
			zoomImgCtr.style.visibility = "hidden";
		}

		addEvent(zoomImg, "load", function() {

			// bail out if img has been removed from dom
			if (!zoomImg.parentNode) return;

			var zoomWidth = zoomImg.offsetWidth;
			var zoomHeight = zoomImg.offsetHeight;

			var ctrWidth = zoomImgCtr.offsetWidth;
			var ctrHeight = zoomImgCtr.offsetHeight;

			var ratioW = zoomWidth / w;
			var ratioH = zoomHeight / h;

			var markerWidth = Math.round(ctrWidth / ratioW);
			var markerHeight = Math.round(ctrHeight / ratioH);

			document.body.removeChild(zoomImg);
			zoomImgCtr.appendChild(zoomImg);

			var zoomFill = dc("div");
			zoomFill.className = "mojozoom_fill";
			zoom.appendChild(zoomFill);

			var zoomBorder = dc("div");
			zoomBorder.className = "mojozoom_border";
			zoom.appendChild(zoomBorder);

			zoom.style.width = markerWidth+"px";
			zoom.style.height = markerHeight+"px";


			if (alwaysShow) {
 				zoom.style.left = "0px";
				zoom.style.top = "0px";
	
				zoomImg.style.left = "0px";
				zoomImg.style.top = "0px";
			}

			var isInImage = false;

			if (!alwaysShow) {
 				addEvent(zoomInput, "mouseout", 
					function(e) {
						var target = e.target || e.srcElement;
						if (!target) return;
						if (target.nodeName != "DIV") return;
						var relTarget = e.relatedTarget || e.toElement;
						if (!relTarget) return;
						while (relTarget != target && relTarget.nodeName != "BODY" && relTarget.parentNode) {
							relTarget = relTarget.parentNode;
						}
						if (relTarget != target) {
							isInImage = false;
							ctr.style.display = "none";
							zoomImgCtr.style.visibility = "hidden";
						}
					}
				);
				// a bit of a hack, mouseout is sometimes not caught if moving mouse really fast
				addEvent(document.body, "mouseover", 
					function(e) {
						if (isInImage && !(e.toElement == zoomBorder || e.target == zoomBorder)) {
							ctr.style.display = "none";
							zoomImgCtr.style.visibility = "hidden";
							isInImage = false;
						}
					}
				);
			}

			addEvent(zoomInput, "mousemove", 
				function(e) {
					isInImage = true;

					var imgPos = getElementPos(img);

					if (useDefaultCtr) {
						zoomImgCtr.style.left = w + imgPos.x + "px";
						zoomImgCtr.style.top = imgPos.y + "px";
					}
					ctr.style.display = "block";
					zoomImgCtr.style.visibility = "visible";

					var pos = getEventMousePos(zoomInput, e);
					if (e.srcElement && isIE) {
						if (e.srcElement == zoom) return;
						if (e.srcElement != zoomInput) {
							var zoomImgPos = getElementPos(e.srcElement);
							pos.x -= (imgPos.x - zoomImgPos.x);
							pos.y -= (imgPos.y - zoomImgPos.y);
						}
					}
					var x = markerWidth/2;
					var y = markerHeight/2;

					if (!isIE) {
						pos.x -= imgLeft;
						pos.y -= imgTop;
					}

					if (pos.x < x) pos.x = x;
					if (pos.x > w-x) pos.x = w-x;
					if (pos.y < y) pos.y = y;
					if (pos.y > h-y) pos.y = h-y;

					var left = ((pos.x - x)|0);
					var top = ((pos.y - y)|0);

					zoom.style.left = left + "px";
					zoom.style.top = top + "px";

					zoomImg.style.left = -((pos.x*ratioW - ctrWidth/2)|0)+"px";
					zoomImg.style.top = -((pos.y*ratioH - ctrHeight/2)|0)+"px";
				}
			);
		});

		// I've no idea. Simply setting the src will make IE screw it self into a 100% CPU fest. In a timeout, it's ok.
		setTimeout(function() { 
			zoomImg.src = zoomSrc;
		}, 1);

		}, 1);
		//alert(defaultWidth);
	}

	function init() {
		var images = document.getElementsByTagName("img");
		for (var i=0;i<images.length;i++) {
			var img = images[i];
			var zoomSrc = img.getAttribute("data-zoomsrc");
			if (zoomSrc) {
				makeZoomable(img, zoomSrc, document.getElementById(img.getAttribute("id") + "_zoom"), null, null, img.getAttribute("data-zoomalwaysshow")=="true");
				
			}
		}
	}

	return {
		addEvent : addEvent,
		init : init,
		makeZoomable : makeZoomable
	};

})();

MojoZoom.addEvent(window, "load", MojoZoom.init);

function clearForm2(oForm) {
    
  var elements = oForm.elements; 
    
  oForm.reset();

  for(i=0; i<elements.length; i++) {
      
	field_type = elements[i].type.toLowerCase();
	
	switch(field_type) {
	
		case "text": 
		case "password": 
		case "textarea":
	        case "hidden":	
			
			elements[i].value = ""; 
			break;
        
		case "radio":
		case "checkbox":
  			if (elements[i].checked) {
   				elements[i].checked = false; 
			}
			break;

		case "select-one":
		case "select-multi":
            		elements[i].selectedIndex = -1;
			break;

		default: 
			break;
	}
    }
}

function FP_openNewWindow(w,h,nav,loc,sts,menu,scroll,resize,name,url) {//v1.0
 var windowProperties=''; if(nav==false) windowProperties+='toolbar=no,'; else
  windowProperties+='toolbar=yes,'; if(loc==false) windowProperties+='location=no,'; 
 else windowProperties+='location=yes,'; if(sts==false) windowProperties+='status=no,';
 else windowProperties+='status=yes,'; if(menu==false) windowProperties+='menubar=no,';
 else windowProperties+='menubar=yes,'; if(scroll==false) windowProperties+='scrollbars=no,';
 else windowProperties+='scrollbars=yes,'; if(resize==false) windowProperties+='resizable=no,';
 else windowProperties+='resizable=yes,'; if(w!="") windowProperties+='width='+w+',';
 if(h!="") windowProperties+='height='+h; if(windowProperties!="") { 
  if( windowProperties.charAt(windowProperties.length-1)==',') 
   windowProperties=windowProperties.substring(0,windowProperties.length-1); } 
 window.open(url,name,windowProperties);
}

function validateNewUser()
{
	//Get emailId and user id text box values from form.
	var EmailID = document.getElementById('v.email.EmailAddress').value;
	var userID = document.getElementById('v.txt.UserLogin').value;
	var blnUserId=true;
	var	blnValidUser=true;
	var blnEmailID=true;
	var blnValidEmail=true;
	if (userID=='')
	{	blnUserId=false;
		alert('User ID cannot be blank');}
	else if (userID!='')
	{
	//check special character entry in the textbox 
		var iChars = "abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
		for (var k=0;k<userID.length;k++)
		{
			if(iChars.indexOf(userID.charAt(k)) ==-1)
			{
			blnValidUser=false; 
			document.getElementById('v.txt.UserLogin').style.backgroundColor = '#63BF87';
			alert('Entered invalid character(s) for User ID.\nPlease try again..');
			break;
			}
		}	
	}
	if (  blnValidUser )
	{ document.getElementById('v.txt.UserLogin').style.backgroundColor = 'ffffff';}

	if(EmailID=="")
	{
		alert("Email ID cannot be blank");
		blnEmailID=false;
	}
	else if(EmailID!="")
	{
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if(filter.test(EmailID))
		{
		blnValidEmail=true;
		blnEmailID=true;
		}
		else
		{
			document.getElementById('v.email.EmailAddress').style.backgroundColor = '#63BF87';
			alert("Invalid Email Address. Please check the same");
			blnValidEmail=false;
			blnEmailID=true;
		}
	}
	
	if (blnValidEmail)
	{ document.getElementById('v.email.EmailAddress').style.backgroundColor = 'ffffff'; }
	
	if (  blnValidUser &&  blnValidEmail)
	{ 
	document.getElementById('v.txt.UserLogin').style.backgroundColor = 'ffffff';
	document.getElementById('v.email.EmailAddress').style.backgroundColor = 'ffffff';
	return true;	
	}
	else
	{ return false; }
		
}

function addToCheckStockList(url)
{
	var productno;
	var qty;
	var qty2;
	productno = document.getElementById('productno_page').value;
	qty = document.getElementById('txtquantity').value;
	document.chkstk_prd.submit();
	window.location=url +'?action=chkstock&prod_add=True&productno_page='+productno+'&qty='+qty;
		//alert(qty+'prod'+productno);
}

	
