function isDate(Dt)
{
  if(isNaN(Dt.substr(0,4)-0)||!(Dt.substr(5,2)-0)||(Dt.substr(5,2)-0>12)||isNaN(Dt.substr(5,2)-0)||!(Dt.substr(8,2)-0)||(Dt.substr(8,2)-0>31)||isNaN(Dt.substr(8,2)-0)||(Dt.substr(8,2)-0>30 && (Dt.substr(5,2)-0==4 || Dt.substr(5,2)-0==6 || Dt.substr(5,2)-0==9 ||Dt.substr(5,2)-0==11))||(Dt.substr(5,2)-0==2 && (Dt.substr(0,4)-0)%4==0 && Dt.substr(8,2)-0>29)||(Dt.substr(5,2)-0==2 && (Dt.substr(0,4)-0)%4!=0 && Dt.substr(8,2)-0>28)||Dt.substr(4,1)!="-"||Dt.substr(7,1)!="-")
  {
      return false;
  }
  else
  {
      return true
  }
}

function isEmail(Ml)
{
  if(!Ml){return true}
  if(Ml.indexOf("@")<=0 || Ml.indexOf("@")==Ml.length-1 || Ml.indexOf(".")<=0 || Ml.indexOf(".")==Ml.length-1 || Ml.indexOf("..")!=-1 || Ml.indexOf("@@")!=-1 || Ml.indexOf("@.")!=-1 || Ml.indexOf(".@")!=-1)
  {
      return false
  }
  else
  {
      return true
  }
}

function Trim (s){return LTrim(RTrim(' '+s));}
function LTrim (s)
{
    if(!s){return '';}
    while(s.charAt(0)==' ')
        s = s.substring(1,s.length);
    return s;
}

function sort(x,y)
{
 var frm=document.forms['search'];
 frm.sort.value=x;
 frm.type.value=y;
 frm.search.value=1;
 frm.submit();
}
function dateString(oneDate) 
{
	var theDay = dayNames[oneDate.getDay() + 1]
	var theMonth = monthNames[oneDate.getMonth() + 1]
	var theYear = oneDate.getFullYear()
	return theDay +" "+ theMonth + " " + oneDate.getDate() + ", " + theYear
}

 function doBlink() {
  var blink = document.all.tags("BLINK")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
  if (document.all)
    setInterval("doBlink()",1000)
}
window.onload = startBlink;

function RTrim (s)
{
    if(!s || s==' '){return '';}
    if (s.length > 1)
    {
        while(s.charAt(s.length-1)==' ')
            s = s.substring(0,s.length-2);
        return s;
    }
}


function Chk(frm)
{
	if(!frm.user_id.value || frm.user_id.value<=0)
    {
     if(confirm("Sorry !! You have not loged in.\nThis is login restricted section"))
     {
	    frm.action='index.php';
	    frm.submit();	
	 }
	  return false;
    }
    return true
 }   
function showval(x)
{
  eval("getValue("+ x +")");
}
function GetSubject(x)
{
    
	var frm=document.forms["link"];
	frm.subject.value=x;
 	frm.action='professors_rating.php'
	frm.submit();
}

function ValidSet(frm)
{
	var txt="";
   
    if(!frm.site_title.value)
	{   
	   txt+="     Site Title should not be blank.\n";
	}
	if(!frm.admin_mail.value)
	{
	   txt+="     Admin Email Address should not be blank.\n";
	}
	if(!frm.meta_keys.value) 
	{
	   txt+="     Meta Keys should not be blank.\n";
	}
	if(!frm.meta_desc.value) 
	{
	   txt+="     Meta Description should not be blank.\n";
 	}
	if(txt)
	{
   	  alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	  return false
	}
    return true	
}

function ValidCon(frm)
{
    var txt="";
	
	if(!frm.name.value)
	{
		txt+="     Name should not be empty.\n"
	}
	if(!Trim(frm.email.value) || !isEmail(frm.email.value))
	{
	   txt+="     Enter valid email address.\n"
       
 	}
	if(!frm.message.value)
	{
		txt+="     You did not put any message.\n"
	}  
   	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	
}
function ValidPass(frm)
{
    var txt="";   
    if(!frm.pass.value || frm.pass.value.length<4) 
	{
	   txt+="     Password should not be blank or password less than 4 chars.\n"
	}	
 	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidCat(frm)
{
    var txt="";   
    if(!frm.cat_name.value) 
	{
	   txt+="     Category Name should not be blank.\n"
	}	
 	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidSubcat(frm)
{
    var txt="";   
    if(!frm.sub_cat_name.value) 
	{
	   txt+="     Sub Category Name Name should not be blank.\n"
	}	
 	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidEditor(frm)
{
    var txt="";   
    if(!frm.cont_title.value) 
	{
	   txt+="     Title should not be blank.\n"
	}	
 	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidFpass(frm)
{
    var txt="";   
	
    if(!Trim(frm.admin_mail.value) || !isEmail(frm.admin_mail.value))
	{
	   txt+="     Enter valid email address\n"
       
 	}
 	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function ValidAlogin(frm)
{
    var txt="";   
	
    if(!Trim(frm.pass.value))
	{
	   txt+="     Password should not be blank.\n"
       
 	}
 	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}

function isValidNumber(inpString) {
   return /^[-+]?\d+(\.\d+)?$/.test(inpString);
}

function ValidCart(frm)
{
	var txt="";
   
    if((!frm.qty.value) || !isValidNumber(frm.qty.value) || (frm.qty.value =="0"))
	{   
	   txt+="     Qty should not be empty.\n";
	}			
	if(txt)
	{
   	  alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	  return false
	}
    return true	
}
function ValidchkName(frm)
{
    var txt="";  
	
	if((!frm.username.value) || (frm.username.value =="Nombre"))
	{   
	   txt+="     Name should not be empty.\n";
	}
    if(!Trim(frm.email.value) || !isEmail(frm.email.value))
	{
	   txt+="     Enter valid email address\n"
       
 	}
 	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}


function CheckForms(frm)
{
	var txt="";
	if(!frm.card_holder_name.value)
	{
		txt+="     Card Holder Name should not be empty\n"
	}
	if(!frm.card_number.value)
	{
		txt+="     Credit Card Number should not be empty\n"
	}
	if(!frm.card_code.value)
	{
		txt+="     Credit Card Code should not be empty\n"
	}
	if(!frm.ship_first_name.value)
	{
		txt+="     First Name should not be empty\n"
	}
    if(!frm.ship_last_name.value)
	{
		txt+="     Last Name should not be empty\n"
	}
	
	if(!frm.ship_email.value || !isEmail(frm.ship_email.value))
	{
		txt+="     Invalid Email Id\n";
	}
	
    if(frm.ship_phone_number.value=="")
    {
		txt+="     You did not put any phone number \n"
	}  
    
	if(frm.ship_address.value=="")
	{
		txt+="     Address should not be empty \n"
	}
	if(frm.ship_city.value=="")
	{
		txt+="     City should not be empty \n"
	}
    /*if(frm.ship_country.value=="")
	{
		txt+="     Please select your country name \n"
	}*/
	if(frm.ship_postal_code.value=="")
	{
		txt+="     Postal Code should not be empty\n"
	}
	if(!frm.terms_condition.checked)
	{
		txt+="     Please Check the checkbox to indicate that you agreed terms and conditions.\n"
	}	
    
   	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	
}

function GetValue()
{
  var frm=document.forms['form1'];
  if(!frm.email.value)
  {
      frm.email.value=frm.ship_email.value;  
      frm.bill_first_name.value=frm.ship_first_name.value;
	  frm.bill_last_name.value=frm.ship_last_name.value;
	  frm.bill_company.value=frm.ship_company.value;
	  frm.bill_phone_areacode.value=frm.ship_phone_areacode.value;
	  frm.bill_phone_number.value=frm.ship_phone_number.value;
	  frm.bill_fax_areacode.value=frm.ship_fax_areacode.value;
	  frm.bill_fax_number.value=frm.ship_phone_number.value;
	  frm.bill_address.value=frm.ship_address.value;
	  frm.bill_city.value=frm.ship_city.value;
	  frm.bill_province.value=frm.ship_province.value;
	  frm.bill_postal_code.value=frm.ship_postal_code.value;
	  frm.bill_postal_code2.value=frm.ship_postal_code2.value;
	  frm.bill_country.value=frm.ship_country.value;
	  frm.bill_suite.value=frm.ship_suite.value;
	  
   }
   else
   {
     frm.email.value="";   
     frm.bill_first_name.value="";
	 frm.bill_last_name.value="";
	 frm.bill_company.value="";
	 frm.bill_phone_areacode.value="";
	 frm.bill_phone_number.value="";
	 frm.bill_fax_areacode.value="";
	 frm.bill_fax_number.value="";
	 frm.bill_address.value="";
	 frm.bill_city.value="";
	 frm.bill_province.value="";
	 frm.bill_postal_code.value="";
  	 frm.bill_postal_code2.value="";	
     frm.bill_country.value="";
	 frm.bill_suite.value="";
  
   }
}  

function ValidProd(frm)
{
    var txt="";  
	
	if(frm.prod_title.value=="")
	{   
	   txt+="     Product Tilte should not be empty.\n";
	}
    if(frm.prod_code.value=="")
	{
	   txt+="     Product Code should not be empty.\n"
       
 	}
	if(frm.cat_id.value=="")
	{
	   txt+="     Please select any category.\n"
       
 	}
 	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	 

}
function checkreg()
{
	var txt="";
   
	   if(!frm.first_name.value) 
	   {
		   txt+="     First Name should not be blank.\n";
	   }
	   if(!frm.last_name.value) 
	   {
		   txt+="     Last Name should not be blank.\n";
	   }	   
	   if(!frm.email.value || !isEmail(frm.email.value))
	   {
	    txt+="     Enter valid email address.\n"       
 	   }	   
	   if(!frm.address.value) 
	   {
		   txt+="     Address should not be blank.\n";
 	   }		 
	   if(!frm.zip.value)
	   {   
		   txt+="     Zip should not be blank.\n";
	   }
	   if(!frm.city.value)
	   {   
		   txt+="     City should not be blank.\n";
	   }	   
	  
	   if(!frm.state.value)
	   {   
		   txt+="      Street Address1 should not be blank.\n";
	   }
	   
	   if(!frm.country.value)
	   {   
		   txt+="    Please select your country.\n";
	   }
	   
	   if(!frm.password.value)
	   {   
		   txt+="     Password should not be blank.\n";
	   }	    
	   if(!frm.condition.checked)
	   {   
		   txt+="    You did not agree with our Terms and Conditions.\n";
	   }
	  
 	   if(txt)
	   {
   		  alert("Sorry. The following errors have occurred :\n\n"+ txt +"\n     Please Check");
  	 	  return false
	   }
       return true	
}
function toggle(obj, s, n, d, l){
  obj.bigimage.src = s;
  window.name1.innerHTML = n;
  window.desc1.innerHTML = d;
  window.imglink.href=l;
}

function checkjoin()
{
	var txt="";
   
	   if(!frm.first_name.value) 
	   {
		   txt+="     First Name should not be blank.\n";
	   }
	   if(!frm.last_name.value) 
	   {
		   txt+="     Last Name should not be blank.\n";
	   }
	  	if(!frm.email.value || !isEmail(frm.email.value))
	  {
	   txt+="     Enter valid email address.\n"
       
 	  }
	   if(!frm.username.value) 
	   {
		   txt+="     User Name Type should not be blank.\n";
 	   }	 
	   
	   
	   
	   if(!frm.city.value)
	   {   
		   txt+="     City/Town should not be blank.\n";
	   }
	   
	   if(!frm.address.value)
	   {   
		   txt+="    Address should not be blank.\n";
	   }
	      
	  if(!frm.zip.value)
	   {   
		   txt+="     Zip Code should not be blank.\n";
	   }
	   
	   if(!frm.country.value)
	   {   
		   txt+="     Please select your country name.\n";
	   }
	  
	   
	   if(!frm.password.value)
	   {   
		   txt+="     Password should not be blank.\n";
	   }
	    
	    if(!frm.condition1.checked)
	   {   
		   txt+="     You did not agree with our Terms and Conditions.\n";
	   }
	  
 	   if(txt)
	   {
   		  alert("Sorry. The following errors have been occurred :\n\n"+ txt +"\n     Please Check");
  	 	  return false
	   }
       return true	
}

function ValidSupport(frm)
			{
				var txt="";
				
				
				if(!frm.email.value || !isEmail(frm.email.value))
				{
				   txt+="     Enter valid Email Address.\n"
				   
				}
				
				 
				if(txt)
				{
					alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
					return false
				}
				return true	
			}
			
function ValidContact(frm)
{
    var txt="";
	
	if(!frm.first_name.value)
	{
		txt+="     First Name should not be empty.\n"
	}
	if(!frm.last_name.value)
	{
		txt+="     Last Name should not be empty.\n"
	}	
	
	if(!frm.email.value || !isEmail(frm.email.value))
	{
	   txt+="     Enter valid email address.\n"
       
 	}
	 
	if(!frm.message.value)
	{
		txt+="     You did not put any message.\n"
	} 
   	if(txt)
	{
   		alert("Sorry. The following errors have been occured :\n\n"+ txt +"\n     Please Check");
  	 	return false
	}
    return true	
}