﻿function SetError()
{
var error = document.getElementById("HiddenError").value; 
alert(error)
return false;
}
function setToRed(msg)
    { 
      
      document.getElementById("msg").innerHTML = msg;    
      document.getElementById("msg").style.fontWeight="bold";
      document.getElementById("msg").style.color="red";                    
      setTimeout ( "setToBlack()", 4000 );      
    }
    function setToBlack ()
    {  
      document.getElementById("msg").innerHTML = "";      
    }
/***********************************************************/
function checkForInvalid(obj)
{
   if( /[^0-9\-]|-{2,}/gi.test(obj.value) )
   {
     alert("Invalid character. enter number")
     obj.focus();
     obj.select();
     return false;
   }
   return true;
}

/*********************************************************/
  function IsNumeric(sText)
  {
   var ValidChars = "0123456789.";//var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
    }
   return IsNumber;   
 } 
 /*********************************************************/
 
function search()
{
if(document.getElementById("txtPriceMin").value != 'Min')
{
 if(!IsNumeric(document.getElementById("txtPriceMin").value))
 {
 document.getElementById("txtPriceMin").focus();
 alert('enter digit in minimum price');
 return false;
 }
}

if(document.getElementById("txtPriceMax").value != 'Max')
{
 if(!IsNumeric(document.getElementById("txtPriceMax").value))
 {
 document.getElementById("txtPriceMax").focus();
 alert('enter digit in maximum price');
 return false;
 }
}
}//end of function
/****************************************************/
function Login_check()
{
if(document .getElementById ("txtUserName").value =='')
{
alert("You must enter a username ");
document .getElementById ("txtUserName").focus();
return false;
}
if(document .getElementById ("txtpassword").value =='')
{
alert("You must enter a password ");
document .getElementById ("txtpassword").focus();
return false;
}
}//end of function
/****************************************************/
function Registration_check()
{
if(document .getElementById ("txtUserName").value =='')
{
alert("You must enter a username ");
document .getElementById ("txtUserName").focus();
return false;
}

if(document .getElementById ("txtPassword").value =='')
{
alert("You must enter a password ");
document .getElementById ("txtPassword").focus();
return false;
}

if(document .getElementById ("txtVPassword").value =='')
{
alert("You must enter the password a second time ");
document .getElementById ("txtVPassword").focus();
return false;
}

if(document .getElementById ("txtVPassword").value !=document .getElementById ("txtPassword").value)
{
alert("The passwords you entered did not match ");
document .getElementById ("txtVPassword").focus();
return false;
}
if(document .getElementById ("txtName").value =='')
{
alert("You must enter your full name ");
document .getElementById ("txtName").focus();
return false;
}
var emailCode=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(document .getElementById ("txtEmail").value =='')
{
alert("You must enter an email address ");
document .getElementById ("txtEmail").focus();
return false;
}
else if(document.getElementById("txtEmail").value.search(emailCode)==-1)
{
alert("Invalid email address ");
document .getElementById ("txtEmail").focus();
return false;
}

}//end of function
/*******************************************************/

function Change_check()
{
if(document .getElementById ("txtName").value =='')
{
alert("You must enter your full name ");
document .getElementById ("txtName").focus();
return false;
}
var emailCode=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(document .getElementById ("txtEmail").value =='')
{
alert("You must enter an email address ");
document .getElementById ("txtEmail").focus();
return false;
}
else if(document.getElementById("txtEmail").value.search(emailCode)==-1)
{
alert("Invalid email address ");
document .getElementById ("txtEmail").focus();
return false;
}
if(document .getElementById ("txtPassword").value =='')
{
alert("You must enter your password ");
document .getElementById ("txtPassword").focus();
return false;
}
}//end of functions
/*******************************************************/
function Password_check()
{
if(document .getElementById ("txtCPassword").value =='')
{
alert("You must enter your current password ");
document .getElementById ("txtCPassword").focus();
return false;
}

if(document .getElementById ("txtNPassword").value =='')
{
alert("You must enter your new password ");
document .getElementById ("txtNPassword").focus();
return false;
}
if(document .getElementById ("txtVPassword").value =='')
{
alert("You must enter your new password again");
document .getElementById ("txtVPassword").focus();
return false;
}

if(document .getElementById ("txtVPassword").value !=document .getElementById ("txtNPassword").value)
{
alert("The new passwords you entered did not match ");
document .getElementById ("txtNPassword").focus();
return false;
}

}
/***********************************************/
function Form_Check()
{
var str = "";
var Name =1;
if(document.getElementById("txtName").value=='')
{
str +="\n Enter Name ";
Name =0;
}

var Email = 1;
var emailCode=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(document.getElementById("txtEmail").value=='')
{
str +="\n Enter Email ";
Email = 0;
}
else if(document.getElementById("txtEmail").value.search(emailCode)==-1)
{
str +="\n Invalid Email";
Email =0;
}

var Phone =1;
if(document.getElementById("txtPhone").value=='')
{
str +="\n Enter Telephone Number ";
Phone =0;
}

var Message =1;
if(document.getElementById("txtMessage").value.length >500)
{
str +="\n Max 500 characters allow in message box";
Message =0;
}
//////////////
if(Message ==0)
{
document.getElementById("txtMessage").style.backgroundColor ='#ffffd0';
document.getElementById("txtMessage").focus();
}
else
{
document.getElementById("txtMessage").style.backgroundColor ='';
}
if(Phone ==0)
{
document.getElementById("txtPhone").style.backgroundColor ='#ffffd0';
document.getElementById("txtPhone").focus();
}
else
{
document.getElementById("txtPhone").style.backgroundColor ='';
}

if(Email ==0)
{
document.getElementById("txtEmail").style.backgroundColor ='#ffffd0';
document.getElementById("txtEmail").focus();
}
else
{
document.getElementById("txtEmail").style.backgroundColor ='';
}
if(Name ==0)
{
document.getElementById("txtName").style.backgroundColor ='#ffffd0';
document.getElementById("txtName").focus();
}
else
{
document.getElementById("txtName").style.backgroundColor ='';
}

if(str != '')
{
alert(str);
return false;
}
}
/***********************************/

 /*****************************************/   
 
 function SendMailcheck()
{
var str = "";
var Name =1;
if(document.getElementById("txtName").value=='')
{
str +="\n Enter Name ";
Name =0;
}

var Email = 1;
var emailCode=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(document.getElementById("txtEmail").value=='')
{
str +="\n Enter Email ";
Email = 0;
}
else if(document.getElementById("txtEmail").value.search(emailCode)==-1)
{
str +="\n Invalid Email";
Email =0;
}

var Phone =1;
if(document.getElementById("txtPhone").value=='')
{
str +="\n Enter Telephone Number ";
Phone =0;
}

var Message =1;
if(document.getElementById("txtMessage").value.length >500)
{
str +="\n Max 500 characters allow in message box";
Message =0;
}
//////////////
if(Message ==0)
{
document.getElementById("txtMessage").style.backgroundColor ='#ffffd0';
document.getElementById("txtMessage").focus();
}
else
{
document.getElementById("txtMessage").style.backgroundColor ='';
}
if(Phone ==0)
{
document.getElementById("txtPhone").style.backgroundColor ='#ffffd0';
document.getElementById("txtPhone").focus();
}
else
{
document.getElementById("txtPhone").style.backgroundColor ='';
}

if(Email ==0)
{
document.getElementById("txtEmail").style.backgroundColor ='#ffffd0';
document.getElementById("txtEmail").focus();
}
else
{
document.getElementById("txtEmail").style.backgroundColor ='';
}
if(Name ==0)
{
document.getElementById("txtName").style.backgroundColor ='#ffffd0';
document.getElementById("txtName").focus();
}
else
{
document.getElementById("txtName").style.backgroundColor ='';
}

if(str != '')
{
alert(str);
return false;
}
}//end of function
/*****************************/
