function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='Email Box must contain an e-mail address.\n';
        else {p=val.indexOf('.');
        if (p<1 || p==(val.length-1)) errors+='Email Box must contain an e-mail address.\n';}
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+=nm+' Box must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+=nm+' Box must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') {if (test.indexOf('isEmail')!=-1);
    
	else
	if(nm=="YName")
	{
	nm="Your Name";
	}
	if(nm=="FName")
	{
	nm="Friend Name";
	}
	if(nm=="FEmail")
	{
	nm="Friend Email";
	}

	 if(nm=="subject")
	{
	nm="Subject";
	}
	


 errors +=nm+' can not be blank.\n'; }}
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_validateFormLetter() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormLetter.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById('EMail');
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='Email Box must contain an e-mail address.\n';
        else {p=val.indexOf('.');
        if (p<1 || p==(val.length-1)) errors+='Email Box must contain an e-mail address.\n';}
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+=nm+' Box must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+=nm+' Box must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') {if (test.indexOf('isEmail')!=-1)errors += 'Email can not be blank.\n'; 
	else errors +=nm+' can not be blank.\n'; }}
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValueLetter = (errors == '');
}

function centerWindow(fname) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;
    var xOffset = (xMax - 490)/2, yOffset = (yMax - 190)/2;	
    MM_openBrWindowX(fname,'info','width=400,height=150,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}

function MM_openBrWindowX(theURL,winName,features) { //v2.0
  mywin=window.open(theURL,winName,features);  
  if (mywin.opener==null)
      mywin.opener=self;  
  self.close();
}

function centerWindowX(fname) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;
    var xOffset = (xMax - 490)/2, yOffset = (yMax - 190)/2;	
    MM_openBrWindow(fname,'info','width=400,height=150,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}

function MM_openBrWindow(theURL,winName,features) { 
     window.open(theURL,winName,features);}


function submitDiscount(){   
    MM_validateForm('DEmail','','RisEmail');
   if (document.MM_returnValue){ 
   		val=document.getDiscount.DEMail.value
       	centerWindowX('submit.asp?Email='+val+'&mode=discount');
       	document.getDiscount.DEMail.value=''}}
       	
function DisAllowAlphabets()
  {     
var isNS4 = (navigator.appName=="Netscape")?1:0;
if(!isNS4){
	if(event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;}
else{if((event.which < 48 || event.which > 57) && !(event.which == 8)){ return false;}}
}

function DisAllowNumbers(){
      if ((window.event.keyCode >= 48 && window.event.keyCode <= 57) || window.event.keyCode==39 || window.event.keyCode==34 || window.event.keyCode==60 || window.event.keyCode==62 || window.event.keyCode==63 || window.event.keyCode==124 || window.event.keyCode==45 || window.event.keyCode==43 || window.event.keyCode==58 || window.event.keyCode==40 || window.event.keyCode==41) {
           window.event.returnValue=false; }
        else if(window.event.keyCode == 32){
          window.event.returnValue=true;}
        }
        
        
 function AllowAmount(){
 			val=MM_findObj('Amount'); val=val.value; 				
 			if (window.event.keyCode == 46){ 				
 				if (val.indexOf('.')!=-1) window.event.returnValue=false;	
 				else window.event.returnValue=true; }	
      		else if (window.event.keyCode >= 48 && window.event.keyCode <= 57) {
      			if ((val.indexOf('.') >=1) && (val.indexOf('.')==(val.length-3))) window.event.returnValue=false;
          		else window.event.returnValue=true;}      
        	else window.event.returnValue=false;  }
        	
        	
  function AllowGCAmount(txt){
 			val=MM_findObj(txt); val=val.value; 				
 			if (window.event.keyCode == 46){ 				
 				if (val.indexOf('.')!=-1) window.event.returnValue=false;	
 				else window.event.returnValue=true; }	
      		else if (window.event.keyCode >= 48 && window.event.keyCode <= 57) {
      			if ((val.indexOf('.') >=1) && (val.indexOf('.')==(val.length-3))) window.event.returnValue=false;
          		else window.event.returnValue=true;}      
        	else window.event.returnValue=false;  }
       	
	   
function submitLetter()
{
   if(document.newsletter.EMail.value=="")
   {alert("Please Enter Email ID");
   	document.newsletter.EMail.focus();
   	return false;}
   else if (!checkmail(document.newsletter.EMail.value))
   {document.newsletter.EMail.select();
   	return false;}
   else
   {val=document.newsletter.EMail.value; 
    centerWindowX('submit.asp?Email='+val+'&mode=letter');
    document.newsletter.EMail.value='';}
   return false; 
}
	   
	   
function submitLetterindex(){  
    if(document.newsletter.EMail.value=="")
   		{alert("Please Enter Email ID");
   		document.newsletter.EMail.focus();}
    else if (checkmail(document.newsletter.EMail.value)){
       val=document.newsletter.EMail.value 
       centerWindowX('../pages/submit.asp?Email='+val+'&mode=letter');
       document.newsletter.EMail.value=''}}
       
function submitLetterindexasp(){  
    if(document.newsletter.EMail.value=="")
   		{alert("Please Enter Email ID");
   		document.newsletter.EMail.focus();}
    else if (checkmail(document.newsletter.EMail.value)){
       val=document.newsletter.EMail.value 
       centerWindowX('submit.asp?Email='+val+'&mode=letter');
       document.newsletter.EMail.value=''}}

       
function submitLetterindex2(){  
    if(document.newsletter2.EMailp.value=="")
   		{alert("Please Enter Email ID");
   		document.newsletter2.EMailp.focus();}
    else if (checkmail(document.newsletter2.EMailp.value)){
       val2=document.newsletter2.EMailp.value 
       centerWindowX('submit.asp?Email='+val2+'&mode=letter');
       document.newsletter2.EMailp.value=''}}
	   
	   	   
function submitsearch(){
 var val=false
 var valnew
 var str
   str=document.form3.info.value; val=validateData(str,'required,max=100,alnum','Embroidery Description')
   if (val==true)
   	{str=document.form3.EMail.value; val=validateData(str,'required,max=50,email','Your Email ID')
   if (val==true)
   	{valnew=document.form3.EMail.value; 
   	 valnew=valnew + '.;'+ document.form3.info.value; 
   	 centerWindowX('submit.asp?val='+valnew+'&mode=searchinfo');
   	 document.form3.reset();}
   	else
   	{document.form3.EMail.focus();}}
	else
	{document.form3.info.focus();}} 


function checkmail(str){
   		var at="@"        
		var dot="."
		var temp;
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var invalidchar=" \"([{}])!#$%^&*';:,/\\?|+`~<>=~"
		if (str.indexOf(at)==-1){
			alert("Please Enter a valid Email ID.");
		   	return false }
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
		   alert("Please Enter a valid Email ID.")
		   return false	}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
		    alert("Please Enter a valid Email ID.")
		    return false }
		if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please Enter a valid Email ID.")
		    return false }
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please Enter a valid Email ID.")
		    return false }
		if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please Enter a valid Email ID.")
		    return false }		
		for (i=0; i<(invalidchar.length-1); i++){
		      temp=invalidchar.substring(i,i+1);		      
		      if (str.indexOf(temp)!=-1){
		         alert("Please Enter a valid Email ID.")
		         return false} 
	 	}		 		
return true; }  

			
function checkWholeForm(Lform){
 	var val=false
 	var str
   	str=Lform.loginname.value; 
   	val=validateData(str,'required,max=50,email','Email ID')   	
   	if (val==true){
	  str=Lform.password.value; 
	  val=validateData(str,'required,alnum','Your Password')
   	  if (val==true){
         Lform.submit(); }
      else {
	     Lform.password.focus(); 
	     return false; } }		
    else {
	  Lform.loginname.focus();
	  return false; }
   }    
    
function checkMeasurement(){
 var val=false
 var str
   str=document.mform.loginname.value; val=validateData(str,'required,max=50,email','Email ID')
   if (val==true)
	{str=document.mform.password.value; val=validateData(str,'required,alnum','Your Password')
   if (val==true)
    {document.mform.submit();}
    else
	{document.mform.password.focus();}}		
    else
	{document.mform.loginname.focus();}}    
    
function checkUsername (strng){
	 var error = "";
	 if (strng == "") {
	    error = "Please Enter Email ID.\n";}
	 else if (strng.length > 50) {
	    error = "The Email ID is the wrong length.\n";}	     
	 else if(strng!=""){ 	
	     var check =checkmail(strng)  
	     if (check!=true){
	      	 return false;}
		 return true;}
	 if (error != "") {alert(error);return false;}
	}
	
	
function checkPassword (strng) {
 var error = "";
 if (strng == "") {
    error = "Please Enter Password.\n";}
    var illegalChars ="!@#$%^&*()+=-[]\\;,./{}|\":<>?"; // allow only letters and numbers
    if (strng.length > 20) {
       error = "The Password is the wrong length.\n";}
    else if (illegalChars.test(strng)) {
      error = "The Password contains illegal characters.\n";}
      if (error != "") {
         alert(error);
        return false; }
	return true;  }  

function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
cntfield.value = maxlimit - field.value.length;
}



function validatecomment(str)
{
var comm
comm=str
if(comm!="")
{
return true;
}
else
{
alert("Comments can not Blank");
return false;


}

}

function checkSareeLarge(){
var val=false
var str
	str=document.form2.Name.value
	val=validateData(str,'required,max=30,alpha','Name')
	if (val==true)
	{
		str=document.form2.mail.value;  
		val=validateData(str,'required,max=50,email','Email ID')
		if (val==true)
		{
			str=document.form2.Comments.value;  
			val=validatecomment(str);
			if (val==true)
			{ return true;}
	else
	{ document.form2.Comments.focus();}}
	else
	{ document.form2.mail.focus();} 
	} 
	else
	{ document.form2.Name.focus();}
	return val;}

function checkNewuserForm(NUform) {
 var val=false
 var str
   str=NUform.FName.value
   val=validateData(str,'required,max=30,alpha','First Name')
   if (val==true)
    {str=NUform.lname.value;  val=validateData(str,'max=30,alpha','Last Name')
   if (val==true)
	{str=NUform.YEmail.value; val=validateData(str,'required,max=50,email','Email ID')
   if (val==true)
   	{if (str!=NUform.CEmail.value)
   		{alert('Confirm Email ID does not match Email ID');
   		 NUform.CEmail.focus();
   		 return false;}
	   else	
	   	{return true;}
	}
   	else
   	{NUform.YEmail.focus();
   	 return false;}}
	else
	{NUform.lname.focus();
	 return false;}}		
    else
	{NUform.FName.focus();
	 return false;}} 
     
    
 function checkFirstname (strng) {
 		var error = "";
 		if (strng == "") {
    		error = "Please Enter Your First Name.\n";	}
 		if (strng.length > 30) {
    		error = "First Name can be maximum of 30 characters.\n";}
		else if (strng!="") {
        	var illegalChars = "!@#$%^&*()+=-[]\\;,./{}|\":<>?";
           	if (illegalChars.test(strng)) {
    	   	error = "The First Name contains illegal characters.\n"; } }
		if (error != "") {
            alert(error);
            return false;}        
		return true; }   
		
		
  function checkEmail (strng) {
  	if (strng == ""){
  		error = "Please Enter Your E-mail.";
  		 if (error != "") {alert(error);return false; } }
  	else if(strng!=""){	
	 	 var check =checkmail(strng)  
	     if (check!=true){return false;} }	
    return true;  }
    
    
   function checkConfirmEmail (strng){
		if (strng == ""){
			error= "Please Enter Your Confirm E-mail.";
			if (error != "") {alert(error);return false; } }
		else if(strng!=""){
			var check=checkmail(strng)
			if (check!=true){
				return false;} }
		return true; }
	
  
function checkFullname (strng) {
 		var error = "";
 		if (strng == "") {error = "Please Enter Your Name.\n";}
 		if (strng.length > 30) {error = "Name can be maximum of 30 characters.\n";}
		if (error != ""){
			alert(error);
			return false;}
        return true; }   

function checkMessage (strng)
	{
		var error = "";
		if (strng == "") {error = "Please Enter Your Message.\n";}
 		if (strng.length > 250){error = "Message can be maximum of 250 charecters.\n";}	
 		if (error != "")
    	 {
            alert(error);
            return false;
          }
	return true;}
	
function validateForm(form1) {
    var why = true;
    why = checkFullname(this.document.form1.fullname.value);
    if (why != true) 
    {
    	 this.document.form1.fullname.focus();
         return false;
    }
    why = checkEmail(this.document.form1.qemail.value);
    if (why != true) 
    {
    	 this.document.form1.qemail.focus();
    	 this.document.form1.qemail.select();
         return false;
    }
    why = checkMessage(this.document.form1.message.value);
    if (why != true) 
    {
         this.document.form1.message.focus();
         return false;
    }
   return true;
 }
 
  

function checkSuggestForm(myform) {
    var why = true;
    var frdvall = "";
    why = checkFullname(myform.YourName.value);
    if (why != true) 
    {
    	 myform.YourName.focus();
         return false;
    }
    why = checkEmail(myform.YourEmail.value);
    if (why != true) 
    {
    	 myform.YourEmail.focus();return false;
    }
    why = checkFriendsEmail(document.frmfriend.FriendEmailone.value);
    if (why != true) 
    {
    	 document.frmfriend.FriendEmailone.focus();return false;
    }
    frdvall = myform.FriendEmailtwo.value;
    if(frdvall != "")
    {
    	why = checkmail(myform.FriendEmailtwo.value);
    	{
    		if (why != true){myform.FriendEmailtwo.select();return false;}   	
	 	}
	 }
	frdvall = myform.FriendEmailthird.value;
    if(frdvall != "")
    {
    	why = checkmail(myform.FriendEmailthird.value);
    	{
    		if (why != true){myform.FriendEmailthird.select();return false;}   	
	 	}
	 }
	frdvall = myform.FriendEmailfour.value;
    if(frdvall != "")
    {
    	why = checkmail(myform.FriendEmailfour.value);
    	{
    		if (why != true){myform.FriendEmailfour.select();return false;}   	
	 	}
	 }
	 frdvall = myform.FriendEmailfive.value;
    if(frdvall != "")
    {
    	why = checkmail(myform.FriendEmailfive.value);
    	{
    		if (why != true){myform.FriendEmailfive.select();return false;}   	
	 	}
	 }				
    return true;
 } 
 
 
function checkFriendsEmail (strng)
  {
  	if (strng == "")
  	{
  		error = "Please Enter At Least One Friends E-mail.";
  		 if (error != "") {
            alert(error);
            return false;}
  	}
  	else if(strng!="")
	 	{	
	 	 	var check =checkmail(strng)  
	     	if (check!=true){return false;}
		}
		return true;}
function checkjunkchar(str, fieldname){
	var invalidchar=" \"([{}])!#$%^&*';:,/\\?|+`~<>=~@.0123456789"
	for (i=0; i<(invalidchar.length-1); i++){
		temp=invalidchar.substring(i,i+1);		      
		if (str.indexOf(temp)!=-1)
		{	alert("Special characters/spaces are not allowed in "+ fieldname +"." ); return false} 
	}		 		
return true; }

function messageval(str)
{
if(str!="")
{
return true
}
	
}	
function contactquery()
{
var val=false
var valnew
var str
		if(document.form1.con_sub.value==0)
		{
		alert("select the Subject")
		val=false
		}
		else
		{
		val=true
		if(val=true)
       str=document.form1.qemail.value;  val=validateData(str,'max=50,email','Email Address') 
   if (val==true)
    {str=document.form1.fullname.value ;val=validateData(str,'required,alpha','Full Name')
  
   if (val==true)
  	{str=document.form1.message.value; val=messageval(str)
   if (val==true)
   	{valnew=document.form1.fullname.value;
     valnew=valnew+'.;'+document.form1.qemail.value;
	 valnew=valnew+'.;'+document.form1.ordernumber.value;
	 valnew=valnew+'.;'+document.form1.message.value;
	  valnew=valnew+'.;'+document.form1.con_sub.value;
	 if(document.form1.concheck.checked==true)
	 {
	valnew=valnew+'.;'+'1';
     }
     else
     valnew=valnew+'.;'+'2';
	 centerWindowX('../pages/submit.asp?val='+valnew+'&mode=contactquery'); 
     document.form1.reset();}
     else
		{document.form1.message.focus();
		alert("Message Can Not Blank")
		return false
		}}	
	
  else
		{document.form1.fullname.focus();}}
		
	
		   else
	
	{document.form1.qemail.focus();}}}
	
function ShowWindow(url, name, height, width, scroll, v){
	val= MM_findObj(v);
	if(navigator.appName=='Microsoft Internet Explorer'){
		height=height+40
		var x=window.showModalDialog(url,name,'dialogHeight:'+height+'px;dialogWidth:'+width+'px;scroll:'+scroll+';border:raised;center:yes;help:no;resizeable:no;status:no;');}
	else{
		var y=window.open(url,name,'height='+height+'px,width='+width+'px,scrollbars='+scroll+',modal=yes,border=raised,align=center,help=no,resizeable=no,status=no');
		var x=y.returnValue; 
		}
		val.selectedIndex=x}

// These two function should be deleted if the Xfunctions.js will be used
function validateData(strValidateStr,command,fieldname) 
{ var newcommand=command.split(",");
  for (var i=0; i < newcommand.length; i++){ 
   var val = validateform(strValidateStr,newcommand[i],fieldname)
   if (val==false){
  	return val;}}
  return val;}

function validateform(strValidateStr,command,fieldname)
{ var strError="";  var epos = command.search("="); var  newcommand  = ""; var  cmdvalue = ""; 
  if(epos >= 0){ 
     newcommand  = command.substring(0,epos); 
     cmdvalue = command.substr(epos+1);} 
  else{ 
     newcommand = command;} 
 
  switch(newcommand){ 
    case "req": 
    case "required": 
    { if((strValidateStr.length) == 0){ 
          strError = fieldname + " is a  Required Field"; 
          alert(strError);
          strError="";
          return false;} 
       break;} 
    case "maxlength": 
    case "max": 
    { if (strValidateStr.length > cmdvalue){ 
          strError = fieldname + " : has more than allowed maximum characters  "; 
          strError=strError + "\n[Current length = " + strValidateStr.length + " ]"
          alert(strError);
          strError = "";	
          return false; }
      break;}
    case "minlength": 
    case "min": 
    { if(strValidateStr.length < cmdvalue){ 
          strError = fieldname + " : has less than allowed minimum characters  "; 
          alert(strError + "\n[Current length = " + strValidateStr.length + " ]"); 
          return false;} 
          break;} 
    case "alnum": 
    case "alphanumeric":{ 
      var charpos = strValidateStr.search("[^A-Za-z0-9-/,.  ]"); 
      if(strValidateStr.length > 0  &&  charpos >= 0){ 
          strError = fieldname +" : allows Only alpha-numeric characters  "; 
          alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
          strError="";
          return false;} 
          break;}
    case "num": 
    case "numeric":{ 
      var charpos = strValidateStr.search("[^0-9]"); 
      if(strValidateStr.length > 0 &&  charpos >= 0){ 
          strError = fieldname+" : allows Only numbers ";                
          alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
          strError="";
          return false;} 
          break;} 
    case "alphabetic": 
    case "alpha":{ 
      var charpos = strValidateStr.search("[^A-Za-z ]"); 
      if(strValidateStr.length > 0 &&  charpos >= 0){ 
          strError = fieldname+" : allows Only alphabetic characters  "; 
          alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
          strError="";
          return false;} 
          break;} 
    case "email":{ 
      if(!checkmail(strValidateStr)){ 
          return false;} 
          break;} 
    case "lt": 
    case "lessthan":{ 
      if(isNaN(strValidateStr)){ 
          alert(fieldname+" : Should be a number "); 
          return false;} 
          if ((strValidateStr) >=  eval(cmdvalue)){ 
              strError = fieldname + " : value should be less than "+ cmdvalue;              
              alert(strError); 
              strError="";
              return false;}            
          break;}
    case "gt": 
    case "greaterthan":{ 
      if(isNaN(strValidateStr)){ 
          alert(objValue.name+" : Should be a number "); 
          return false;}
          if(strValidateStr <=  eval(cmdvalue)){ 
              strError = fieldname + " : value should be greater than "+ cmdvalue; 
              alert(strError);
              strError=""; 
              return false;}             
          break;} 
    case "regexp":{ 
      if(!strValidateStr.match(cmdvalue)){ 
          strError = fieldname +" : Invalid characters found "; 
          alert(strError); 
          return false;} 
          break;} 
    case "UT":{ 
      if(strValidateStr.search("UT") < 0 && strValidateStr.search("ut") < 0 && strValidateStr.search("uT") < 0 && strValidateStr.search("Ut") < 0){ 
          strError = fieldname +" : must start with UT"; 
          alert(strError); 
          return false;} 
          break;} 
   } 
 return true;} 
 
 
 // rating functions taken from rating.js
 function initARC(formId,onClassRadio,offClassRadio,onClassCheckbox,offClassCheckbox) {
    var agt=navigator.userAgent.toLowerCase();

    // Browser Detection stuff
    this.major = parseInt(navigator.appVersion);
    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie3    = (this.ie && (this.major < 4));
    this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
	this.iemac  = (this.ie && (agt.indexOf("mac")!=-1));

	if( !(this.iemac || ie3 || ie4) ){
		customiseInputs(formId,onClassRadio,offClassRadio,onClassCheckbox,offClassCheckbox);
	}
}

function addLabelProperties(f){
	if(typeof f.getElementsByTagName == 'undefined') return;
	var labels = f.getElementsByTagName("label"), label, elem, i = j = 0;
	
	while (label = labels[i++]){
		if(typeof label.htmlFor == 'undefined') return;
		elem = document.getElementById(label.htmlFor);
		//elem = f.elements[label.htmlFor]; /* old method */
		
		if(typeof elem == 'undefined'){
			//no label defined, find first sub-input
			var inputs = label.getElementsByTagName("input");
			if(inputs.length==0){
				continue;
			} else {
				elem=inputs[0];
			}
		} else if(typeof elem.label != 'undefined') { // label property already added
			continue;
		} else if(typeof elem.length != 'undefined' && elem.length > 1 && elem.nodeName != 'SELECT'){
			for(j=0; j<elem.length; j++){
				elem.item(j).label = label;
			}
		}
		elem.label = label;
	}
} 

function toggleLabelStyle(formId, label, onClass, offClass){
	if(!document.getElementById || !label) return;
		
	var form = document.getElementById(formId); //label.form;
	var ratingval=new Array("I don't like it"," It's OK ","It's Good","I like it","I love it");	
	var form = document.getElementById(formId); //label.form;
	if(!form) return;
	
	//find radio associated with label (if in htmlFor form)
	if(label.htmlFor) {
		var e = document.getElementById(label.htmlFor);
		
		if(e.type=="checkbox"){
			e.label.className = (e.label.className==onClass) ? offClass : onClass;
			e.checked = (e.label.className==onClass);
		} else if(e.type=="radio"){
			var radioGroup = form.elements[e.name];
			if(!radioGroup) return;

			var rating = (e.id.length==7) ? e.id.substring(e.id.length-1, e.id.length) : e.id.substring(e.id.length-2, e.id.length);
			var cont=document.getElementById("content")
			if (cont)	cont.innerHTML=ratingval[rating-1];
			
			
			for(var i=0; i<radioGroup.length; i++){
				if(radioGroup[i].label){
					// REMOVED -- radioGroup[i].label.className = ((radioGroup[i].checked=(radioGroup[i].id == e.id)) && radioGroup[i].label) ? onClass : offClass;
					radioGroup[i].label.className = (rating > i) ? onClass : offClass;
					radioGroup[i].checked=(radioGroup[i].id == e.id);
				}
			}
		}
	}
}

function customiseInputs(formId, onClassRadio, offClassRadio, onClassCheckbox, offClassCheckbox) {
	if(!document.getElementById) return;
	var prettyForm = document.getElementById(formId);
	if(!prettyForm) return;
	prettyForm.onreset = function() { customiseInputs(formId, onClassRadio, offClassRadio, onClassCheckbox, offClassCheckbox); }
	addLabelProperties(prettyForm);
	var inputs = prettyForm.getElementsByTagName('input');
	for (var i=0; i < inputs.length; i++) {
		if( (inputs[i].type=="radio") && inputs[i].label && onClassRadio && offClassRadio){
			//hide element
			inputs[i].style.position="absolute"; inputs[i].style.left = "-1000px";
			//initialise element
			inputs[i].label.className=offClassRadio;
			//when the label is clicked, call toggleLabelStyle and toggle the label
			inputs[i].label.onclick = function (){ toggleLabelStyle(formId, this, onClassRadio, offClassRadio); };
			//enable keyboard navigation
			inputs[i].onclick = function (){ toggleLabelStyle(formId, this.label, onClassRadio, offClassRadio); };
			//if the radio was checked by default change this label's style to checked
			if(inputs[i].defaultChecked || inputs[i].checked){ toggleLabelStyle(formId, inputs[i].label, onClassRadio, offClassRadio); }
		}
		if( (inputs[i].type=="checkbox") || (inputs[i].type=="radio") && inputs[i].label ){
			//Attach keyboard navigation
			if(!this.ie){ 
				inputs[i].label.style.margin = "1px";
				inputs[i].onfocus = function (){ this.label.style.border = "1px dotted #333"; this.label.style.margin="0px"; return false; };
				inputs[i].onblur  = function (){ this.label.style.border = "none"; this.label.style.margin="1px"; return false; };
			}
		}
	}
}


  function CheckVal(val)
  {
  var check
  check=val
  if(val=='prdinfo'){
  if (document.form2.prdinfo.checked==true)
	  document.form2.prdinfo.value="Yes"
  else
	  document.form2.prdinfo.value="No"
  }
  if(val=='typos'){
  if (document.form2.typos.checked==true)
	  document.form2.typos.value="Yes"
  else
	  document.form2.typos.value="No"
  }
  if(val=='loadtime'){
  if (document.form2.loadtime.checked==true)
	  document.form2.loadtime.value="Yes"
  else
	  document.form2.loadtime.value="No"
  }
  if(val=='todaydeals'){
  if (document.form2.todaydeals.checked ==true)
	  document.form2.todaydeals.value="Yes"
  else
	  document.form2.todaydeals.value="No"
  }
}



function ShowHelp(event,title,txt,w,h) {
	var p=window.createPopup()
	var pbody=p.document.body
	pbody.style.border="solid lightblue 1px"	
	var text="<table border=0 cellpedding=0 cellspacing=0><tr bgcolor='#336799' height=20>"
	text=text +"<td style='font-family:Verdana;font-size:9pt;text-align:center;color:#ffffff'><b>"+ title +"</b></td></tr>"
	text=text+"<tr backgound='#eeeeee'><td style='padding-left:6 ;padding-right:6; padding-top:4; text-align:justify;'>"
	text=text+"<span style='font-family:Verdana;font-size:9pt;'>"
	text=text + txt  // Main message which will be display on screen
	text=text +"</span></td></tr></table>"
	pbody.innerHTML=text
	p.show(495,150,w,h,document.body)
	}




//string a=new array(50);
function ShowHelp1(event,title,a,lena,b,lenb,lan,w,h) {
	
	splita=a.split(";")
	splitb=b.split(";")
	
	//var lan;
	//if (lena >= lenb) {lan=lena;} 
	//else {lan=lenb;}
	
	var p=window.createPopup()
	var pbody=p.document.body
	pbody.style.border="solid #B6B4B4 1px"	
	var text="<table border=0 cellpedding=0 cellspacing=0 width="+w+" ><tr bgcolor='#336799' height=20>"
	text=text +"<td width="+w+" colspan=4 style='font-family:Verdana;font-size:9pt;text-align:center; background: #eaeaea; color: #666666;'><b>"+ title +"</b></td></tr>"
	
	for (var i=0; i<lan; i=i+2)
	{
	
	text=text+"<tr backgound='#eeeeee'>"
	if (i<lena)
		{
		text=text+"<td style='padding-left:6 ; padding-top:4; text-align:left;'>"
		text=text+"<span style='font-family:Verdana;font-size:8pt;line-height:15px' class='smalltext' onclick=MM_openBrWindowX('http://www.yahoo.com','vks','status=no') >"+ splita[i]+"</span></td>"
		//text=text+'<span style='font-family:Verdana;font-size:8pt;line-height:15px' class='smalltext' onclick='document.popup.submit();'>'+ splita[i] +'</span></td>'

		text=text +"<td style='padding-right:6; padding-top:4; text-align:left;'>"
		
		text=text+"<span style='font-family:Verdana;font-size:8pt;line-height:15px' class='smalltext'>"+ splita[i+1] +"</span></td>"
		}
	
	if(i<lenb)
		{
		text=text+"<td style='padding-left:6 ; padding-top:4; text-align:left;'>"
		text=text+"<span style='font-family:Verdana;font-size:8pt;line-height:15px' class='smalltext'>"+ splitb[i] +"</span></td>"
		text=text +"<td style='padding-right:6; padding-top:4; text-align:left;'>"
		text=text+"<span style='font-family:Verdana;font-size:8pt;line-height:15px' class='smalltext'>"+ splitb[i+1] +"</span></td>"
		}
	else
		{
		text=text+"<td style='padding-left:6 ; padding-top:4; text-align:left;'>"
		text=text+"<span style='font-family:Verdana;font-size:8pt;line-height:15px' class='smalltext'>&nbsp;</span></td>"
		text=text +"<td style='padding-right:6; padding-top:4; text-align:left;'>"
		text=text+"<span style='font-family:Verdana;font-size:8pt;line-height:15px' class='smalltext'>&nbsp;</span></td>"
		}
	text=text+"</tr>"	
	}
	
 // Main message which will be display on screen
	text=text +"</table>"
	pbody.innerHTML=text
	p.show(179,150,w,h,document.body)
	//p.show((event.x)+50,(event.y),w,h,document.body)
	}



function searchmap()

{
document.search.action="search.asp"
}




//ajax  header customer signin


 var xmlheaderobj;

function showhead ()
{ 
xmlheaderobj=GetXmlHttpObjheader();


if (xmlheaderobj==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
var url="customersignin.asp";
xmlheaderobj.onreadystatechange=stateChangedheader;

xmlheaderobj.open("GET",url,true);
xmlheaderobj.send(null);

}

function stateChangedheader() 
{ 
if (xmlheaderobj.readyState==4)
	{ 
     document.getElementById("signcust").innerHTML=xmlheaderobj.responseText;
       if (xmlheaderobj.responseText !="" )
       	 {	document.getElementById("signcust").className="redprice";
      	 	document.getElementById("signcust").style.paddingLeft=0 ;}
	   else
	     {}
	   
	}
}
 
function GetXmlHttpObjheader()
{
var xmlhead=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlhead=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlhead=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlhead=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlhead;
}


//
function make_blank(keyword)
{
if (keyword=="hide")
	{
	if (document.search.q.value=="Enter Keyword or Item Code")
		{
			document.search.q.value="";
		}
	}
else if (keyword=="show")
	{
	if (document.search.q.value=="")
		{
			document.search.q.value="Enter Keyword or Item Code";
		}
	}
}


function make_blankemail(dis)
{

	if (dis=="hide")
	{
	if (document.newsletter2.EMailp.value=="enter your email address")
	{
	document.newsletter2.EMailp.value="";	
	}
	}
	else if (dis=="show")
	{
	 if (document.newsletter2.EMailp.value=="")
	{
	document.newsletter2.EMailp.value="enter your email address";	
	}}

	
}



function contactqueryb2b()
{
var valnew
var why = true;
if (document.form1.message.value=="")
{
alert("Message Can Not Blank")
document.form1.message.focus();
return false;

}
else if (document.form1.fullname.value=="")
{
alert("Contact Person Name Can Not Blank")
document.form1.fullname.focus();
return false;
}
else if (document.form1.qemail.value=="")
{
alert("E-Mail Address Can Not Blank")
document.form1.qemail.focus();
return false;
}
else if (document.form1.phone.value=="")
{
alert("Phone Number Can Not Blank")
document.form1.phone.focus();
return false;
}
else if (document.form1.Countryname.selectedIndex=="")
{
alert("Country Name Can Not Blank")
document.form1.Countryname.focus();
return false;
}

else if (document.form1.qemail.value != "")
    {
    	why = checkmail(document.form1.qemail.value );
    		if (why != true)
    		{
    		document.form1.qemail.focus();
    		return false;
    		}   	
	 }
 
 valnew=document.form1.message.value;
 valnew=valnew+'.;'+document.form1.companyname.value;
 valnew=valnew+'.;'+document.form1.fullname.value;
 valnew=valnew+'.;'+document.form1.qemail.value;
 valnew=valnew+'.;'+document.form1.phone.value;
 valnew=valnew+'.;'+document.form1.address.value;
 valnew=valnew+'.;'+document.form1.city.value;
 valnew=valnew+'.;'+document.form1.Countryname.value;
 centerWindowX('http://www.utsavsarees.com/pages/submit.asp?val='+valnew+'&mode=contactqueryb2b'); 
 document.form1.reset();
 

}


var y;
var i;
var z;
var timerID = 0;
function showNewlyAdded(x,countNewlyadded)
{
z=countNewlyadded;
for(i=1;i<=countNewlyadded;i++)
{
document.getElementById('Div'+i).style.display="none";
}
document.getElementById('Div'+x).style.display="";
if (x==countNewlyadded)
	{y=1;}
else
	{y=x+1;}
clearTimeout(timerID);
timerID=0;
timerID = setTimeout("showNewlyAdded(y,z)", 1500);
}



function changebuttoncolor(e, mouse) // change button color
{

var color="";
if (mouse == "OVER")
{
color="#C13100";
}
else
{
color="#CC6600";
}
var el=window.event? event.srcElement: e.target
if (el.tagName=="INPUT"&&el.type=="submit" || el.tagName=="INPUT"&&el.type=="button" )
el.style.backgroundColor=color
}



function verifysearchkeyword()
{

var keyword="";
keyword = document.search.q.value;

        if (keyword=="" || keyword=="Enter Keyword or Item Code")
        {

        alert("Please enter keyword for search!");

        }
        else
        {
      
                window.location.href('../pages/search.asp?q='+keyword);
                            
        }

}


function verifysearchkeywords(pageloc)
{

var keyword="";
keyword = document.search.q.value;

        if (keyword=="" || keyword=="Enter Keyword or Item Code")
        {

        alert("Please enter keyword for search!");

        }
        else
        {
            if(pageloc=='search') {   window.location.href='../pages/search.asp?q='+keyword ;}
            else if(pageloc=='adsearch') {   window.location.href='../pages/advancedsearch.asp?q='+keyword ;}
            else if(pageloc=='tag') {   window.location.href='../pages/tagging.asp?q='+keyword ;}
        }

}




function verifysearchkeywordindex()
{

var keyword="";
keyword = document.search.q.value;

        if (keyword=="" || keyword=="Enter Keyword or Item Code")
        {

        alert("Please enter keyword for search!");

        }
        else
        {
      
                window.location.href('../../pages/search.asp?q='+keyword);
                            
        }

}


function verifysearchkeywordsindex(pageloc)
{

var keyword="";
keyword = document.search.q.value;

        if (keyword=="" || keyword=="Enter Keyword or Item Code")
        {

        alert("Please enter keyword for search!");

        }
        else
        {
            if(pageloc=='search') {   window.location.href='../../pages/search.asp?q='+keyword ;}
            else if(pageloc=='adsearch') {   window.location.href='../../pages/advancedsearch.asp?q='+keyword ;}
            else if(pageloc=='tag') {   window.location.href='../../pages/tagging.asp?q='+keyword ;}
        }

}





