// JavaScript Document
function validate_subscirbe(s){
	if(trim(s.email.value)==""){
		alert("Please enter your email id")
		s.email.focus()
		return false
	} else {
		
			st=s.email.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.email.focus();
					return false;
			}
	}
	var w = window.open('about:blank','Popup_Window','width=300,height=150,status=0,resizable=0,toolbar=no,menubar=no,top=150,left=300,scrollbars=yes'); 
	s.target = 'Popup_Window'; 
}

img_counter1=1
img_counter2=1
img_counter3=1
img_counter4=1
img_counter5=1
img_counter6=1
img_counter7=1
img_counter8=1
img_counter9=1
img_counter10=1
img_counter11=1
img_counter12=1
function img_rotator()
{

}
setInterval('img_rotator()',5000)
function window_popup(img)
{
	window.open("show_image.asp?img=" + img , "Image" , "address=no,menubar=no,location=no,scrollbars=yes")
}
function window_popup_yes(img)
{
	//alert("hi")
	window.open("show_image.asp?img=" + img , "Image" , "address=no,menubar=no,location=no,scrollbars=yes,width=600,height=500")
}
function window_popup1()
{
	window.open("show_pattern.asp", "Image" , "address=no,menubar=no,location=no,scrollbars=yes")
}
function window_popup2(ss)
{
	ssq=ss.value
	ssq1=ssq.split("-")
	window.open("preview_pattern.asp?nm="+ssq1[1], "Image" , "address=no,menubar=no,location=no,scrollbars=yes;width=600;height=500")
}
function open_quote(number,breed){
	
	window.open("send_quote.asp?breed="+breed+"&number="+number, "Image" , "address=no,menubar=no,location=no,scrollbars=yes,width=700,height=500")
}

		function getOffsetLeft (el) {
 //alert(el.pageX);
 var ol = el.offsetLeft;

  while ((el = el.offsetParent) != null)
    ol += el.offsetLeft;
  
  return ol;
}
function getOffsetTop (el) {
  var ot = el.offsetTop;
  while((el = el.offsetParent) != null)
   ot += el.offsetTop;
  return ot;
}
		var go=true
		function show_menu(id,hide,td,me_st)
		{
			//alert(td);
			var tableLeft = getOffsetLeft(td);
			var tableTop = getOffsetTop(td);
			//alert(tableLeft);
			//alert(tableTop);
			//alert(td.width)
			if(hide)
			{
				if(id!="") document.getElementById(id).style.visibility='hidden'
				td.style.backgroundColor="#cccc99"
				td.style.color="#336633"
				td.style.cursor=""
				
					td.style.backgroundImage="url(http://www.camoralls.com/cambutton2.gif)"
				
			}
			else
			{
				if(id!="") 
				{
				document.getElementById(id).style.visibility=''
				
				if(me_st=='H' || me_st=='h')
				{
						
					document.getElementById(id).style.left=parseInt(tableLeft);    //parseInt(tableLeft)+document.getElementById(id).style.left;
				
					//document.getElementById(id).style.top=parseInt(tableTop)+3;//+parseInt(td.height/2);
				}
				if(me_st=='V' || me_st=='v')
				{
						document.getElementById(id).style.left=parseInt(tableLeft)+parseInt(td.width)-20;
						document.getElementById(id).style.top=parseInt(tableTop)+3;
					//alert("Horizontal");
					//document.getElementById(id).style.left=parseInt(tableLeft)-2;
					//document.getElementById(id).style.top=parseInt(tableTop)+parseInt(td.height);
					//document.getElementById(id).style.width=parseInt(td.width);
				}
				}
					td.style.backgroundColor="#ffffff"
					td.style.color="#660000"
					td.style.cursor="hand"
				//alert(td.style.width);	
				
			}
		}
	
		function sub_menu_style(td,M)
		{
			if(M=='over')
			{
				td.style.cursor="hand"
				td.style.backgroundColor="#adc0da"
				td.style.color="#800000"
				
		
			}
			else
			{
				td.style.cursor=""
				td.style.backgroundColor="#adc0da"
				td.style.color="#000080"	
				
					td.style.backgroundImage="url(http://www.camoralls.com/cambutton2.gif)"
					
			}
		}

		function sub_menu_click(pageid,prod_page,categoryid,subcategoryid)
		{
		if(go==false) return false
			go=false
			if (prod_page==1)
			{
              document.location="http://" + "www.camoralls.com/" + "product_detailedview.asp?category="+categoryid+"&subid="+subcategoryid+"&pageid="+pageid
		    }
			else
			{
			document.location="http://" + "www.camoralls.com/" + "default.asp?page_no="+pageid
		   }
		}

/////////////////////////////////clinet function
function checkNum(str)
	{
		for(i=0;i<str.length;i++)
		{
			c=str.charAt(i);
			b=(((c >= "0") && (c <= "9")) || (c==" "))
			if(b==true)
			   continue;
			else
			   return false;
		}
		return true;
	}
	
	function checkAlphaSp(str)
	{
	
		for(i=0;i<str.length;i++)
		{
			c=str.charAt(i);
			b=(((c >= "0") && (c <= "9")) || ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) || (c==" "))
			if(b==true)
			   continue;
			else
			   return false;
		}
		return true;
	}
	
	

function checkEmail(str)
	{
		if((str.indexOf("@")==-1) || (str.indexOf(".")==-1))
		{
			fstr="Please Enter @ or .";
			return false;
		}
		else
		{
		if((str.indexOf("@") == 0) || (str.indexOf(".") == 0))
		{
			fstr="@ or . Cannot Be first";
			return false;
		}
		if((str.indexOf("@") == (str.length-1)) || (str.indexOf(".") == (str.length-1)))
		{
			fstr="@ or . Cannot Be Last";
			return false;
		}

		if(str.indexOf("@") > str.indexOf("."))
		{
			fstr="@ Should be After .";
			return false;
		}
		if((str.indexOf("@")+1) == str.indexOf("."))
		{
			fstr="@. IS Invalid Email";
			return false;
		}
		}
		var cp=0;					
		for(i=0;i<str.length;i++)
		{
			c=str.charAt(i);
			b=(((c >= "0") && (c <= "9")) || ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) || (c == ".") || (c == "@") || (c == "_"))
			if(c=="@") cp++;
			if(b==true)
			   continue;
			else
			{
				fstr="Cannot include "+c;
				return false;
			}
		}
		if(cp==2)
		{
			fstr="@ cannnot be repetaed";
			return false;

		}
		return true;
	}


function LTrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}

function RTrim(str)
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...
     var i = s.length - 1;       // Get length of string
      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}
function popUpWindow(URLStr, left, top, width, height)
{
   popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
function validate_emailform(s)
{
	if(trim(s.y_name.value)=="")
	{
		alert("Please Enter Your Name")
		s.y_name.focus()
		return false
	}
	if(trim(s.y_email.value)=="")
	{
		alert("Please Enter Your Email Address")
		s.y_email.focus()
		return false
	}
	else
	{
			st=s.y_email.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.y_email.focus();
					return false;
			}
	}
	if(trim(s.f_name.value)=="")
	{
		alert("Please Enter Your Friend Name")
		s.f_name.focus()
		return false
	}
	if(trim(s.f_email.value)=="")
	{
		alert("Please Enter Your Friend Email Address")
		s.f_email.focus()
		return false
	}
	else
	{
			st=s.f_email.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.f_email.focus();
					return false;
			}
	}
}
function trim(str)
{
   return RTrim(LTrim(str));
}
function check_validate(s)
{
	if (s.slno!=null)
	{
		i_count=s.slno.length
		if(i_count>1)
		{
			
			for(i=0;i<i_count;i++)
			{
				
				if(trim(s.slno[i].value)=="")
				{
					alert("Pelase Enter Value")
					s.slno[i].focus()
					return false
				}
			}
		}
		else
		{
			if(trim(s.slno.value)=="")
			{
				alert("Pelase Enter Value")
				s.slno.focus()
				return false
			}
		}
	}
	
	return true
}
function shipping_validate(a1)
{
	if(trim(a1.f_name.value)=="")
	{	
		alert("Please Enter First Name")
		a1.f_name.focus()
		return false	
	}
	if(trim(a1.l_name.value)=="")
	{	
		alert("Please Enter Last Name")
		a1.l_name.focus()
		return false	
	}
	if(trim(a1.address.value)=="")
	{	
		alert("Please Enter Address")
		a1.address.focus()
		return false	
	}
	if(trim(a1.city.value)=="")
	{	
		alert("Please Enter Address")
		a1.city.focus()
		return false	
	}
	if(trim(a1.state.value)=="")
	{	
		alert("Please Select A State")
		a1.state.focus()
		return false	
	}
	else if(trim(a1.state.value)=="other")
	{
		alert("Please Enter State Name")
		a1.stae_other.focus()
		return false
	}
	if(trim(a1.country.value)=="")
	{	
		alert("Please Select A Country")
		a1.country.focus()
		return false	
	}
	if(trim(a1.postal_code.value)=="")
	{	
		alert("Please Enter Postal Code")
		a1.postal_code.focus()
		return false	
	}
	if(trim(a1.phone.value)=="")
	{	
		alert("Please Enter Postal Code")
		a1.phone.focus()
		return false	
	}
	if(trim(a1.email.value)!="")
	{
		st=a1.email.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					a1.email.focus();
					return false;
			}
	}
}
function validate_update(a1)
{
	i_count=a1.qt.length
	if (i_count>1)
	{
		for(i=0;i<i_count;i++)
		{
			str=a1.qt[i].value
			if (trim(str)=="")
			{
				alert("Please Enter Quantity")
				a1.qt[i].focus()
				return false
			}
			if (str.indexOf(".")>0)
			{
				alert("Please Enter Integer Values Only")
				a1.qt[i].focus()
				return false
			}
			if (eval(str)<=0)
			{
				alert("Please Enter Valid Quantity Value")
				a1.qt[i].focus()
				return false
			}
		}
	}
	else
	{
		str=a1.qt.value
		if (trim(str)=="")
		{
			alert("Please Enter Quantity")
			a1.qt.focus()
			return false
		}
		if (str.indexOf(".")>0)
		{
			alert("Please Enter Numeric Values Only")
			a1.qt.focus()
			return false
		}
		if (eval(str)<=0)
		{
			alert("Please Enter Valid Quantity Value")
			a1.qt.focus()
			return false
		}
	}
	a1.action="add_tocart.asp"
	a1.submit()

}

	function check_fields(s)
	{
		if(s.f_name2.value=="")
		{
			alert("Please Enter First Name")
			s.f_name.focus()
			return false
		}
		if(s.l_name2.value=="")
		{
			alert("Please Enter Last Name")
			s.l_name.focus()
			return false
		}
		
		if(s.ACCT.value=="")
		{
			alert("Please Enter Card Number")
			s.ACCT.focus()
			return false
		}
		else
		{
			s1=s.ACCT.value
			if (s1.length<10)
			{
				alert("Enter a valid Credit Card No.")
				s.ACCT.focus()
				return false
			}
		}
		if(s.EXMON.value=="")
		{
			alert("Please Enter Exp. Month")
			s.EXMON.focus()
			return false
		}
		if(s.EXYEAR.value=="")
		{
			alert("Please Enter Exp. Year")
			s.EXYEAR.focus()
			return false
		}		

	}
	
function validate_contact(s){
	if(trim(s.firstname.value)==""){
		alert("Please enter first name")
		s.firstname.focus()
		return false
	}
	if(trim(s.lastname.value)==""){
		alert("Please enter last name")
		s.lastname.focus()
		return false
	}
	if(trim(s.contact.value)==""){
		alert("Please enter contact details")
		s.contact.focus()
		return false
	}
	if(trim(s.type.value)==""){
		alert("Please select enquiry type ")
		s.type.focus()
		return false
	}
	if(trim(s.howhear.value)==""){
		alert("Please select how did you hear about us")
		s.howhear.focus()
		return false
	}
	if(trim(s.comments.value)==""){
		alert("Please describe your requirement")
		s.comments.focus()
		return false
	}
}

function validate_reffer(s){
	if(trim(s.yname.value)==""){
		alert("Please enter your name")
		s.yname.focus()
		return false
	}
	if(trim(s.yemail.value)==""){
		alert("Please enter your email")
		s.yemail.focus()
		return false
	} else {
	
			st=s.yemail.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.yemail.focus();
					return false;
			}
	}
	if(trim(s.fname.value)==""){
		alert("Please enter your friend name")
		s.fname.focus()
		return false
	}
	if(trim(s.femail.value)==""){
		alert("Please enter your friend email")
		s.femail.focus()
		return false
	} else {
	
			st=s.femail.value;
			if(checkEmail(st)==false)
			{
					alert("Invalid Email Id \n"+st);
					s.femail.focus();
					return false;
			}
	}
	if(trim(s.msg.value)==""){
		alert("Please enter your message")
		s.msg.focus()
		return false
	}
}
