function IsNumeric(strString) {
    var strValidChars = "0123456789.-";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }
    return blnResult;
}

function isValidEmail(str) {
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function chkempty() {
    //alert("lkjlkjl;k");
    if(document.login.user_name.value=='' || document.login.username.value==' ')
    {
        alert("User Name must not be empty");
        document.login.user_name.focus();
        return false;
    }

    if(document.login.password.value=='' || document.login.password.value==' ')
    {
        alert("Password must not be empty");
        document.login.password.focus();
        return false;
    }
}

function chkempty1() {
    if(document.register.user_name.value=='' || document.register.username.value==' ')
    {
        alert("User Name must not be empty");
        document.register.user_name.focus();
        return false;
    }
}

function openwindow(){
    var username = document.register.user_name.value;
    if(username=="" || username==" ")
    {
        alert("User name can not be blank");
    }
    else
    {
        var url="chkavailabilty.php?username="+username;
        window.open(url,"vin2","toolbar=no,menubar=no,width=300,height=300")
    }
}

function textCounter(field,cntfield,maxlimit) {
    if (field.value.length > maxlimit) // if too long...trim it!
        field.value = field.value.substring(0, maxlimit);
    // otherwise, update 'characters left' counter
    else
        cntfield.value = maxlimit - field.value.length;
}

function IsNumeric(strString){
    //  check for valid numeric strings
    var strValidChars = "0123456789.-";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }
    return blnResult;
}

function isValidEmail(str){
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function hahaha(){
    document.register.abc.disabled=false;
}

function hahaha1(){
    document.register.abc.disabled=true;
}

function tweetThis(val){
   // alert("Score "+val);
    var url = "tweet_score.php?score="+val;
    window.open(url,"Login_to_twitter", "height=370,width=800");
}

function headeradd160x600()
{
    document.write('<scr'+'ipt language="JavaScript">');
    document.write('e9 = new Object(); e9.size = "160x600"; e9.noAd = 1;');
    document.write('</scr'+'ipt> ');
    document.write('<scr'+'ipt language="JavaScript"  src="http://tags.expo9.exponential.com/tags/MapsOfIndia/ROS/tags.js">');
    document.write('</scr'+'ipt> ');
}

function Validate(form)
  {
	var tag =/([\<])([^\>]{1,})*([\>])/i;
	var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var ck_name = /^[A-Za-z ]+$/;

	var user_name = form.user_name.value;
	var password = form.password.value;
	var name = form.name.value;
	var address = form.address.value;
	var city = form.city.value;
	var postal_code = form.postal_code.value;
	var state = form.state.value;
	var phone_no = form.phone_no.value;
	var email_id = form.email_id.value;
	var description = form.description.value;

    
	var errors = [];

 if(user_name == ''){
 errors[errors.length] = "Enter Username.";
 }
 if (tag.test(user_name)) {
 errors[errors.length] = "Please Check the Script tags in user name .";
 }
 if(password == '' || password.length < 6){
 errors[errors.length] = "Enter Password more than 6 char.";
 }
 if(name == '' || !ck_name.test(name)){
 errors[errors.length] = "Enter Name and Only Alphabets Allowed.";
 }
 if (tag.test(name)) {
  errors[errors.length] = "Please Check the Script tags in name .";
 }
 if(address == ''){
 errors[errors.length] = "Enter Address.";
 }
 if (tag.test(address)) {
  errors[errors.length] = "Please Check the Script tags in Adress .";
 }
 if(city == ''){
 errors[errors.length] = "Enter City.";
 }
 if (tag.test(city)) {
  errors[errors.length] = "Please Check the Script tags in city .";
 }
 if (tag.test(postal_code)) {
  errors[errors.length] = "Please Check the Script tags in postal code .";
 }
 if (tag.test(state)) {
  errors[errors.length] = "Please Check the Script tags in state .";
 }
 if(phone_no == ''){
 errors[errors.length] = "Enter Phone no.";
 }
 if (tag.test(phone_no)) {
  errors[errors.length] = "Please Check the Script tags in Phone No .";
 }
 if(email_id == '' || !ck_email.test(email_id)){
 errors[errors.length] = "Enter Valid Email.";
 }
if (tag.test(email_id)) {
  errors[errors.length] = "Please Check the Script tags in Email Id .";
 }
 if(description == ''){
 errors[errors.length] = "Enter Description.";
 }
 if (tag.test(description)) {
  errors[errors.length] = "Please Check the Script tags in description .";
 }
 if(description == ''){
 errors[errors.length] = "Enter Description.";
 }

if (errors.length > 0) {

  reportErrors(errors);
  return false;
 }
  return true;
}


function reportErrors(errors){
 var msg = "Please Enter Valide Data...\n";
 for (var i = 0; i<errors.length; i++) {
 var numError = i + 1;
  msg += "\n" + numError + ". " + errors[i];
}
 alert(msg);
}

	
