// JavaScript Document
function Trim(str)
{
	//trim leding spaces
	while(true)
	{
		if(str.charAt(0) == ' ')
			str = str.substr(1);
		else
			break;
	}
	
	//trim trailing spaces
	while(true)
	{
		if(str.charAt(str.length-1) == ' ')
			str = str.substr(0,str.length-1);
		else
			break;
	}
	return(str);	
}

//ajax common function
function GetXmlHttpObject()
{
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

//Check mail
function checkmail(val)
{
	if (Trim(val)!='')
	{
		var s1;
		var k,j;
		j=0;
		var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
		s1 = val.split(",");
		for (k=0;k<s1.length;k++)
		{
			var returnval=emailfilter.test(s1[k])
			if (returnval==false)		
			{
				j=j+1;
			}
		}
		if(j>=1)
		{
				return false;
		}
		if(j==0)
		{
			return true;
		}
	}
}


function fun_homepage(pagename)
{
	window.location.href=pagename;
}
function fun_viewpage(val,page)
{
		for(i=1;i<=8;i++)
		{
			var div="div"+i;
			if (i==val)
			{
				document.getElementById(div).className="selected";
				document.getElementById(div).href=page;
			}
			else
			{document.getElementById(div).className="";}
		}
		
}
/* For Product category page*/
function fun_showprodtab(val,n)
{
	for (j=1;j<=n;j++)
	{
		var cathead="cathead"+j;
		var catimg="catimg"+j;
		if (j==val)
		{
			document.getElementById(catimg).style.display="block";
			document.getElementById(cathead).className="cattab2";
		}
		else if (j!=val)
		{
			document.getElementById(catimg).style.display="none";
			document.getElementById(cathead).className="cattab1";
		}
	}
	document.getElementById('hid_cardno').value=val;
}
function fun_showprodtabskin(val,n)
{
	for (j=1;j<=n;j++)
	{
		var cathead="cathead"+j;
		var catimg="catimg"+j;
		if (j==val)
		{
			document.getElementById(catimg).style.display="block";
			document.getElementById(cathead).className="cattab4";
		}
		else if (j!=val)
		{
			document.getElementById(catimg).style.display="none";
			document.getElementById(cathead).className="cattab3";
		}
	}
	document.getElementById('hid_cardno').value=val;
}
function fun_autoshowprodtab(val,n,prodtyp)
{
	for (j=1;j<=n;j++)
	{
		var cathead="cathead"+j;
		var catimg="catimg"+j;
		if (j==val)
		{
			document.getElementById(catimg).style.display="block";
			if (prodtyp=='skin')
			{document.getElementById(cathead).className="cattab4";}
			else
			{document.getElementById(cathead).className="cattab2";}
		}
		else if (j!=val)
		{
			document.getElementById(catimg).style.display="none";
			if (prodtyp=='skin')
			{document.getElementById(cathead).className="cattab3";}
			else
			{document.getElementById(cathead).className="cattab1";}
		}
	}
	document.getElementById('hidauto').value=1;
	document.getElementById('hid_cardno').value=parseInt(document.getElementById('hid_cardno').value)+1;
	if (prodtyp=='hair')
	{setTimeout ( "fun_slideshowhair()", 10000 );}
	else if (prodtyp=='baby')
	{setTimeout ( "fun_slideshowbaby()", 10000 );}
	else if (prodtyp=='skin')
	{setTimeout ( "fun_slideshowskin()", 10000 );}
	else if (prodtyp=='health')
	{setTimeout ( "fun_slideshowhealth()", 10000 );}
}
function fun_slideshowbaby()
{
	if (document.getElementById('hidauto').value==1)
	{
			if (document.getElementById('hid_cardno').value=="")
			{document.getElementById('hid_cardno').value=1;}
			if (document.getElementById('hid_cardno').value>3)
			{document.getElementById('hid_cardno').value=1;}
			fun_autoshowprodtab(document.getElementById('hid_cardno').value,3,'baby');
	}
}
function fun_slideshowhair()
{
	if (document.getElementById('hidauto').value==1)
	{
			if (document.getElementById('hid_cardno').value=="")
			{document.getElementById('hid_cardno').value=1;}
			if (document.getElementById('hid_cardno').value>3)
			{document.getElementById('hid_cardno').value=1;}
			fun_autoshowprodtab(document.getElementById('hid_cardno').value,3,'hair');
	}
}
function fun_slideshowhealth()
{
	if (document.getElementById('hidauto').value==1)
	{
			if (document.getElementById('hid_cardno').value=="")
			{document.getElementById('hid_cardno').value=1;}
			if (document.getElementById('hid_cardno').value>4)
			{document.getElementById('hid_cardno').value=1;}
			fun_autoshowprodtab(document.getElementById('hid_cardno').value,4,'health');
	}
}
function fun_slideshowskin()
{
	if (document.getElementById('hidauto').value==1)
	{
			if (document.getElementById('hid_cardno').value=="")
			{document.getElementById('hid_cardno').value=1;}
			if (document.getElementById('hid_cardno').value>9)
			{document.getElementById('hid_cardno').value=1;}
			fun_autoshowprodtab(document.getElementById('hid_cardno').value,9,'skin');
	}
}
/* For Product Page*/

function fun_showproductdesc(pname)
{
	var url;
	url=pname+".htm";
	document.form1.action=url;
	document.form1.submit();
}

/*Function for all product page menu*/

function fun_menuallproduct(subval)
{
	var r;
	for (r=1;r<6;r++)
	{
		var submenu="submenu"+r;
		if (r==subval)
		{document.getElementById(submenu).className="selected";}
		else
		{document.getElementById(submenu).className="";}
	}
}


/*Function for save organique feedback*/
function fun_savefeed()
{
	var divid="errormsg";
	var k;
	k=0;
	if (Trim(document.getElementById("firstnametxt").value)=='' && Trim(document.getElementById("lastnametxt").value)=='' )
	{
		document.getElementById(divid).innerHTML="All fields are mandatory. Please fill in the missing fields.";
		k=k+1;
	}
	if (Trim(document.getElementById("mailtxt").value)=='')
	{
		document.getElementById(divid).innerHTML="All fields are mandatory. Please fill in the missing fields.";
		k=k+1;
	}	
	else if (Trim(document.getElementById("mailtxt").value)!='')
	{
		var s=checkmail(Trim(document.getElementById("mailtxt").value));
		if (s==false)
		{k=k+1;document.getElementById(divid).innerHTML="Please enter valid Email Id";}
	}
	if(Trim(document.getElementById("txt_state").value)=="state")
	{
		document.getElementById(divid).innerHTML="All fields are mandatory. Please fill in the missing fields.";
		k=k+1;
	}
	if (Trim(document.getElementById("aoe").value)=='')
	{
		document.getElementById(divid).innerHTML="All fields are mandatory. Please fill in the missing fields.";
		k=k+1;
	}
	if (k==0)
	{
		var rad=rad
		if (document.form1.rad[0].checked==true)
		{document.getElementById("hidchk").value=1;}
		else if (document.form1.rad[1].checked==true)
		{document.getElementById("hidchk").value=0;}
		document.getElementById("hidsave").value="save";
		document.form1.action="tellusorganiqueexperience.asp";
		document.form1.submit();
	}
}
/*Function for save organique feedback*/
function fun_askorg()
{
	var divid="errormsg";
	var k;
	k=0;
	if (Trim(document.getElementById("firstnametxt").value)=='' && Trim(document.getElementById("lastnametxt").value)=='' )
	{
		document.getElementById(divid).innerHTML="All fields are mandatory. Please fill in the missing fields.";
		k=k+1;
	}
	if (Trim(document.getElementById("mailtxt").value)=='')
	{
		document.getElementById(divid).innerHTML="All fields are mandatory. Please fill in the missing fields.";
		k=k+1;
	}	
	else if (Trim(document.getElementById("mailtxt").value)!='')
	{
		var s=checkmail(Trim(document.getElementById("mailtxt").value));
		if (s==false)
		{k=k+1;document.getElementById(divid).innerHTML="Please enter valid Email Id";}
	}
	if(Trim(document.getElementById("subtxt").value)=='')
	{
		document.getElementById(divid).innerHTML="All fields are mandatory. Please fill in the missing fields.";
		k=k+1;
	}
	if (Trim(document.getElementById("aoe").value)=='')
	{
		document.getElementById(divid).innerHTML="All fields are mandatory. Please fill in the missing fields.";
		k=k+1;
	}
	if (k==0)
	{
		document.getElementById("hidsave").value="save";
		document.form1.action="askourorganiquespecialist.asp";
		document.form1.submit();
	}
}
function fun_clrtxt(divid)
{
	document.getElementById(divid).innerHTML="";
}
function subform(para)
{
document.form1.target="_self";
document.form1.action ="myorganiqueexperience.asp?req_pageno="+para;
document.form1.submit();
}

/*Appointment Process*/
function getscheduletimesheet(mval,v)
{
		var xmlHttp=null;
		var url;
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
		  alert ("Your browser does not support AJAX!");
		  return;
		} 
		
		if (mval=="March 12, 2010")
		{
			url="schedule_time12.asp";
			url=url+"?mval="+mval;	
			xmlHttp.onreadystatechange=stateChangedschtime12;
		}
		else if (mval=="March 13, 2010")
		{
			url="schedule_time12.asp";
			url=url+"?mval="+mval;	
			xmlHttp.onreadystatechange=stateChangedschtime12;
		}
		else if (mval=="March 14, 2010")
		{
			url="schedule_time14.asp";
			url=url+"?mval="+mval;	
			xmlHttp.onreadystatechange=stateChangedschtime14;
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
}

function stateChangedschtime12() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		var timesheet;
		timesheet=Trim(xmlHttp.responseText);
		document.getElementById("timediv").innerHTML = timesheet;
	}
}
function stateChangedschtime14() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		var timesheet;
		timesheet=Trim(xmlHttp.responseText);
		parent.window.document.getElementById("timediv").innerHTML = timesheet;
	}
}
function fun_confirmcustomdet(t,m)
{
	    document.getElementById('light').style.display='block';
	    document.getElementById('fade').style.display='block';
		var browserName=navigator.appName; 
		var ver = navigator.appVersion;
		var ver2=ver.split(";");
		 if (browserName=="Microsoft Internet Explorer")
		 {
			 	document.getElementById('fade').style.width="100%";
				document.getElementById('fade').style.height=(parseInt(document.body.clientHeight))+"px";
				document.getElementById('fade').style.top="0px";
				document.getElementById('fade').style.left="0px";
		 }
		 else
		 {
				document.getElementById('fade').style.width=(parseInt(window.outerWidth)-35)+"px";
				document.getElementById('fade').style.height=(parseInt(window.outerHeight)+700)+"px"; 
		 }
		 
		document.getElementById('light').innerHTML="<iframe frameborder='0' scrolling='no' width='645px'  height='425px' style='#width:600px;#height:442px;' src='schedule_customer.asp?t="+t+"&m="+m+"'></iframe>"
}
function fun_closecustomdet()
{
	parent.window.document.getElementById('light').style.display='none';
	parent.window.document.getElementById('fade').style.display='none';	
}
function fun_closecustomdetandshow(m)
{
	getscheduletimesheet(m);
	parent.window.document.getElementById('light').style.display='none';
	parent.window.document.getElementById('fade').style.display='none';	
}
function fun_confirm_appointment(t,m)
{
	var divid="errormsg";
	var k;
	k=0;
	if (Trim(document.getElementById("firstnametxt").value)=='' && Trim(document.getElementById("lastnametxt").value)=='' )
	{
		document.getElementById(divid).innerHTML="All fields are mandatory. Please fill in the missing fields.";
		k=k+1;
	}
	if (Trim(document.getElementById("mailtxt").value)=='')
	{
		document.getElementById(divid).innerHTML="All fields are mandatory. Please fill in the missing fields.";
		k=k+1;
	}	
	else if (Trim(document.getElementById("mailtxt").value)!='')
	{
		var s=checkmail(Trim(document.getElementById("mailtxt").value));
		if (s==false)
		{k=k+1;document.getElementById(divid).innerHTML="Please enter valid Email Id";}
	}
	if(Trim(document.getElementById("comptxt").value)=='')
	{
		document.getElementById(divid).innerHTML="All fields are mandatory. Please fill in the missing fields.";
		k=k+1;
	}
	if (k==0)
	{
		document.getElementById("hidsave").value="save";
		document.form1.action="schedule_customer.asp?t="+t+"&m="+m;
		document.form1.submit();
	}
}
/*product search Process*/
function clrprodtxt()
{
	if (document.getElementById("prodtxt").value=="Search the Organique product here...") 
	{
		document.getElementById("prodtxt").value="";
	}
}
function findprod_fun(val)
{
			if (document.getElementById("prodtxt").value=="Search the Organique product here...") 
			{
				document.getElementById("prodtxt").value="";
			}
			var xmlHttp=null;
			var url;
			xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null)
			{
			  alert ("Your browser does not support AJAX!");
			  return;
			} 
			var pathArray = window.location.pathname.split( '/' );
			if (parseInt(pathArray.length)==3)
			{url="prodsrch.asp";}
			else if (parseInt(pathArray.length)>3)
			{url="../prodsrch.asp";}
			url=url+"?val="+val;
			xmlHttp.onreadystatechange=stateChangedPS;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
	
}
function stateChangedPS() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		var res;
		res=Trim(xmlHttp.responseText);
		document.getElementById('prodres').innerHTML=res;
	}
}