﻿/* isWhitespace (s)                    Check whether string s is empty or whitespace.
   isEmpty(s)						   Check whether string s is empty.	*/

var whitespace = " \t\n\r";
var defaultEmptyOK = false;
var prefix = 'ctl00_ContentPlaceHolder1_';
// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)
{
   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

// Check whether string s is empty.

function isEmpty(s)
{   
	return ((s == null) || (s.length == 0))
}
/*Date Validation*/
function CheckDate(day, month, year) {
        var realDays = 0;
        var isValid = false;        
        //alert(day + ' : ' + month + ' :: ' + year + ' ? ');
        switch (month)
        {
            case 'January':
            case 'March':
            case 'May':
            case 'July':
            case 'August':
            case 'October':
            case 'December':
                realDays = 31;
                break;
                
            case 'February':
                if ( ((year % 4) == 0) || ((year % 100) == 0) )
                {
                    realDays = 29;
                } else {
                    realDays = 28;
                }
                break;
                
            case 'April':
            case 'June':
            case 'September':
            case 'November':
                realDays = 30;
                break;
        }
        
        if (parseInt(day) <= realDays) {
            isValid = true;
        }
        
        if (!isValid) {
        }
    //alert(isValid);
        return isValid;
    }


/*End Date validation*/

function customerSupportcheck(txtID)
{
	if (isWhitespace(document.getElementById(txtID).value) || isEmpty(document.getElementById(txtID).value))
		{
			alert("Please Enter Your Email Address");
			document.getElementById(txtID).focus();
			return false;
		}
	else if (isEmail(document.getElementById(txtID).value) != true)
		{
			alert("Please Enter Your Valid Email Address");
			document.getElementById(txtID).focus();
			return false;
		}
	
	return true;
}
// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c -- in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isEmail (s)
{
   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
	       else return (isEmail.arguments[1] == true);
	   
	    // is s whitespace?
	    if (isWhitespace(s)) return false;
	    
	    // there must be >= 1 character before @, so we
	    // start looking at character position 1 
	    // (i.e. second character)
	    var i = 1;
	    var sLength = s.length;

	    // look for @
	    while ((i < sLength) && (s.charAt(i) != "@"))
	    { i++
	    }

	    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
	    else i += 2;

	    // look for .
	    while ((i < sLength) && (s.charAt(i) != "."))
	    { i++
	    }

	    // there must be at least one character after the .
	    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
	    else return true;
}
function requestinfoheck()
{
	if (document.getElementById(prefix+"information").selectedIndex==0)
		{
			alert("Please select Information you are seeking");
			document.getElementById(prefix+"information").focus();
			return false;
		}
	else if (isWhitespace(document.getElementById(prefix+"first_name").value) || isEmpty(document.getElementById(prefix+"first_name").value))
		{
			alert("Please Enter Your First Name");
			document.getElementById(prefix+"first_name").focus();
			return false;
		}
	else if (isWhitespace(document.getElementById(prefix+"last_name").value) || isEmpty(document.getElementById(prefix+"last_name").value))
		{
			alert("Please Enter Your Last Name");
			document.getElementById(prefix+"last_name").focus();
			return false;
		}
	else if (isWhitespace(document.getElementById(prefix+"name").value) || isEmpty(document.getElementById(prefix+"name").value))
		{
			alert("Please Enter Your Company Name");
			document.getElementById(prefix+"name").focus();
			return false;
		}
	else if (isWhitespace(document.getElementById(prefix+"title").value) || isEmpty(document.getElementById(prefix+"title").value))
		{
			alert("Please Enter Your Job Title");
			document.getElementById(prefix+"title").focus();
			return false;
		}
	else if (isWhitespace(document.getElementById(prefix+"phone").value) || isEmpty(document.getElementById(prefix+"phone").value))
		{
			alert("Please Enter Your Telephone Number");
			document.getElementById(prefix+"phone").focus();
			return false;
		}
	else if (isNaN(document.getElementById(prefix+"phone").value))
		{
			alert("Please Enter Your Valid Telephone Number");
			document.getElementById(prefix+"phone").focus();
			return false;
		}
	else if (isWhitespace(document.getElementById(prefix+"email").value) || isEmpty(document.getElementById(prefix+"email").value))
		{
			alert("Please Enter Your Email Address");
			document.getElementById(prefix+"email").focus();
			return false;
		}
	else if (isEmail(document.getElementById(prefix+"email").value) != true)
		{
			alert("Please Enter Your Valid Email Address");
			document.getElementById(prefix+"email").focus();
			return false;
		}
	else if (isWhitespace(document.getElementById(prefix+"state").value) || isEmpty(document.getElementById(prefix+"state").value))
		{
			alert("Please Enter Your State/Province");
			document.getElementById(prefix+"state").focus();
			return false;
		}
	else if (isWhitespace(document.getElementById(prefix+"zipcode").value) || isEmpty(document.getElementById(prefix+"zipcode").value))
		{
			alert("Please Enter Your Zip/Postal Code");
			document.getElementById(prefix+"zipcode").focus();
			return false;
		}
	else if (isNaN(document.getElementById(prefix+"zipcode").value))
		{
			alert("Please Enter Your Valid Zip/Postal Code");
			document.getElementById(prefix+"zipcode").focus();
			return false;
		}
	else if (document.getElementById(prefix+"country").selectedIndex==0)
		{
			alert("Please select Your Country");
			document.getElementById(prefix+"country").focus();
			return false;
		}
	else if (document.getElementById(prefix+"referred_by").selectedIndex==0)
		{
			alert("Please select How did you hear about Auxano?");
			document.getElementById(prefix+"referred_by").focus();
			return false;
		}
	else if (document.getElementById(prefix+"industry").selectedIndex==0)
		{
			alert("Please select Your Industry");
			document.getElementById(prefix+"industry").focus();
			return false;
		}
	else if (document.getElementById(prefix+"industry").value=="Other" && document.getElementById(prefix+"industry_other").value=="")
		{
			alert("Please Enter Your Industry Name");
			document.getElementById(prefix+"industry_other").focus();
			return false;
		}
	
	return true;
}

function careerCheck()
{
        if (isWhitespace(document.getElementById(prefix+"first_name").value) || isEmpty(document.getElementById(prefix+"first_name").value))
        {
	        alert("Please Enter Your First Name");
	        document.getElementById(prefix+"first_name").focus();
	        return false;
        }
        else if (isWhitespace(document.getElementById(prefix+"last_name").value) || isEmpty(document.getElementById(prefix+"last_name").value))
        {
	        alert("Please Enter Your Last Name");
	        document.getElementById(prefix+"last_name").focus();
	        return false;
        }
        else if (isWhitespace(document.getElementById(prefix+"email").value) || isEmpty(document.getElementById(prefix+"email").value))
        {
	        alert("Please Enter Your Email Address");
	        document.getElementById(prefix+"email").focus();
	        return false;
        }
        else if (isEmail(document.getElementById(prefix+"email").value) != true)
        {
	        alert("Please Enter Your Valid Email Address");
	        document.getElementById(prefix+"email").focus();
	        return false;
        }
        else if (isWhitespace(document.getElementById(prefix+"phone").value) || isEmpty(document.getElementById(prefix+"phone").value))
        {
	        alert("Please Enter Your Telephone Number");
	        document.getElementById(prefix+"phone").focus();
	        return false;
        }
        else if (isNaN(document.getElementById(prefix+"phone").value))
        {
	        alert("Please Enter Your Valid Telephone Number");
	        document.getElementById(prefix+"phone").focus();
	        return false;
        }
        /*Date of Birth Validation*/
        else if (document.getElementById(prefix+"month").selectedIndex==0)
        {
	        alert("Please select Month of Birth");
	        document.getElementById(prefix+"month").focus();
	        return false;
        }
        else if (document.getElementById(prefix+"date").selectedIndex==0)
        {
	        alert("Please select Date of Birth");
	        document.getElementById(prefix+"date").focus();
	        return false;
        }
        else if (document.getElementById(prefix+"year").selectedIndex==0)
        {
	        alert("Please select Year of Birth");
	        document.getElementById(prefix+"year").focus();
	        return false;
        }
        else if (!CheckDate(document.getElementById(prefix+"date").value,document.getElementById(prefix+"month").value,document.getElementById(prefix+"year").value))
        {
	        alert("Please select valid Date");
	        document.getElementById(prefix+"date").focus();
	        return false;
        }
        /*Date of Birth Validation*/
        else if (document.getElementById(prefix+"nationality").selectedIndex==0)
        {
	        alert("Please select Your Nationality");
	        document.getElementById(prefix+"nationality").focus();
	        return false;
        }
        else if (document.getElementById(prefix+"workexp").selectedIndex==0)
        {
	        alert("Please select Your Work Experience");
	        document.getElementById(prefix+"workexp").focus();
	        return false;
        }
        else if (document.getElementById(prefix+"prelocation").selectedIndex==0)
        {
	        alert("Please select Your Preferred Location");
	        document.getElementById(prefix+"prelocation").focus();
	        return false;
        }
        else if (document.getElementById(prefix+"gender").selectedIndex==0)
        {
	        alert("Please select Your Gender");
	        document.getElementById(prefix+"gender").focus();
	        return false;
        }
        else if (document.getElementById(prefix+"qulification").selectedIndex==0)
        {
	        alert("Please select Highest Qualification");
	        document.getElementById(prefix+"qulification").focus();
	        return false;
        }
        else if (document.getElementById(prefix+"position").selectedIndex==0)
        {
	        alert("Please select Position applied for");
	        document.getElementById(prefix+"position").focus();
	        return false;
        }
        else if (document.getElementById(prefix+"position").selectedIndex==0)
        {
	        alert("Please select Position applied for");
	        document.getElementById(prefix+"position").focus();
	        return false;
        }
        else if (document.getElementById(prefix+"referred_by").selectedIndex==0)
        {
	        alert("Please select How did you hear about Auxano?");
	        document.getElementById(prefix+"referred_by").focus();
	        return false;
        }
        return true;
}
