/* ================================================================
File Name: Scripts.js
Client: Chateau on the Lake
Developers: Carl Satterwhite,
Company Name: First Marketing Group, Int'l
===================================================================
Chateau on the Lake: Global Scripts  -  Date: 07/19/2006
================================================================ */

// Preload Images - Swap Images On Rollovers

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Jump Menu
 
function MM_jumpMenu(targ,selObj,restore){ //v3.0 
   
  
  if(selObj.options[selObj.selectedIndex].value == 'ESalesKit.cfm'){ 
  	eval(targ+".location='pdf/ChateauMeetings2009.pdf'"); 
  }else{
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  }
  
  if (restore) selObj.selectedIndex=0;
}


// EmailSignUp Script

function  _CF_checkEmailSignUp(_CF_this)
    {
        //reset on submit
        _CF_error_exists = false;
        _CF_error_messages = new Array();
        _CF_error_fields = new Object();
        _CF_FirstErrorField = null;

        //form element FirstName required check
        if( !_CF_hasValue(_CF_this['FirstName'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "FirstName", _CF_this['FirstName'].value, "Error in FirstName text.");
            _CF_error_exists = true;
        }

        //form element LastName required check
        if( !_CF_hasValue(_CF_this['LastName'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "LastName", _CF_this['LastName'].value, "Error in LastName text.");
            _CF_error_exists = true;
        }

         if( _CF_hasValue(_CF_this['Email'], "TEXT", false ) )
        {
            //form element Email 'EMAIL' validation checks
            if (!_CF_checkEmail(_CF_this['Email'].value, true))
            {
                _CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Please Enter your Email Address.");
                _CF_error_exists = true;
            }

        }else {
            _CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Please Enter your Email Address.");
            _CF_error_exists = true;
        }


        //display error messages and return success
        if( _CF_error_exists )
        {
            if( _CF_error_messages.length > 0 )
            {
                // show alert() message
                _CF_onErrorAlert(_CF_error_messages);
                // set focus to first form error, if the field supports js focus().
                if( _CF_this[_CF_FirstErrorField].type == "text" )
                { _CF_this[_CF_FirstErrorField].focus(); }

            }
            return false;
        }else {
            return true;
        }
    }
	
// Contact Us Form Validation //
///////////////////////////////////////////////////
	function  _CF_checkContactUs(_CF_this)
    {
        //reset on submit
        _CF_error_exists = false;
        _CF_error_messages = new Array();
        _CF_error_fields = new Object();
        _CF_FirstErrorField = null;

        //form element FirstName required check
        if( !_CF_hasValue(_CF_this['FirstName'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "FirstName", _CF_this['FirstName'].value, "Please Enter your First Name.");
            _CF_error_exists = true;
        }

        //form element LastName required check
        if( !_CF_hasValue(_CF_this['LastName'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "LastName", _CF_this['LastName'].value, "Please Enter your Last Name.");
            _CF_error_exists = true;
        }

        //form element Email required check
        if( _CF_hasValue(_CF_this['Email'], "TEXT", false ) )
        {
            //form element Email 'EMAIL' validation checks
            if (!_CF_checkEmail(_CF_this['Email'].value, true))
            {
                _CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Please Enter your Email Address.");
                _CF_error_exists = true;
            }

        }else {
            _CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Please Enter your Email Address.");
            _CF_error_exists = true;
        }

        //form element Phone required check
        if( _CF_hasValue(_CF_this['Phone'], "TEXT", false ) )
        {
            //form element Phone 'TELEPHONE' validation checks
            if (!_CF_checkphone(_CF_this['Phone'].value, true))
            {
                _CF_onError(_CF_this, "Phone", _CF_this['Phone'].value, "Please Enter your Phone Number.");
                _CF_error_exists = true;
            }

        }else {
            _CF_onError(_CF_this, "Phone", _CF_this['Phone'].value, "Please Enter your Phone Number.");
            _CF_error_exists = true;
        }

        //form element Address required check
        if( !_CF_hasValue(_CF_this['Address'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "Address", _CF_this['Address'].value, "Please Enter your Address.");
            _CF_error_exists = true;
        }

        //form element City required check
        if( !_CF_hasValue(_CF_this['City'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "City", _CF_this['City'].value, "Please Enter your City.");
            _CF_error_exists = true;
        }

        //form element State required check
        if( !_CF_hasValue(_CF_this['State'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "State", _CF_this['State'].value, "Please Enter your State.");
            _CF_error_exists = true;
        }

        //form element Zip required check
		var zip = _CF_this['Zip'].value;
		var zipRegExp = /(^\d{5}$)|(^\d{5}-\d{4}$)|(^\D{1}\d{1}\D{1}\s\d{1}\D{1}\d{1}$)/;
        if(!zipRegExp.test(zip))
        {
            _CF_onError(_CF_this, "Zip", _CF_this['Zip'].value, "Please Enter a Zip");
            _CF_error_exists = true;
        }

        //display error messages and return success
        if( _CF_error_exists )
        {
            if( _CF_error_messages.length > 0 )
            {
                // show alert() message
                _CF_onErrorAlert(_CF_error_messages);
                // set focus to first form error, if the field supports js focus().
                if( _CF_this[_CF_FirstErrorField].type == "text" )
                { _CF_this[_CF_FirstErrorField].focus(); }

            }
            return false;
        }else {
            return true;
        }
    }
	
//SmallForm Validation	
	 function  _CF_checkSmallForm(_CF_this)
    {
        //reset on submit
        _CF_error_exists = false;
        _CF_error_messages = new Array();
        _CF_error_fields = new Object();
        _CF_FirstErrorField = null;

        //form element FirstName required check
        if( !_CF_hasValue(_CF_this['FirstName'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "FirstName", _CF_this['FirstName'].value, "Please Enter your First Name.");
            _CF_error_exists = true;
        }

        //form element LastName required check
        if( !_CF_hasValue(_CF_this['LastName'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "LastName", _CF_this['LastName'].value, "Please Enter your Last Name.");
            _CF_error_exists = true;
        }

        //form element Email required check
        if( _CF_hasValue(_CF_this['Email'], "TEXT", false ) )
        {
            //form element Email 'EMAIL' validation checks
            if (!_CF_checkEmail(_CF_this['Email'].value, true))
            {
                _CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Please Enter your Email Address.");
                _CF_error_exists = true;
            }

        }else {
            _CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Please Enter your Email Address.");
            _CF_error_exists = true;
        }


        //display error messages and return success
        if( _CF_error_exists )
        {
            if( _CF_error_messages.length > 0 )
            {
                // show alert() message
                _CF_onErrorAlert(_CF_error_messages);
                // set focus to first form error, if the field supports js focus().
                if( _CF_this[_CF_FirstErrorField].type == "text" )
                { _CF_this[_CF_FirstErrorField].focus(); }

            }
            return false;
        }else {
            return true;
        }
    }
	
//Packages Validation////////////////////////////////
/////////////////////////////////////////////////////
	function  _CF_checkPackageForm(_CF_this)
    {
        //reset on submit
        _CF_error_exists = false;
        _CF_error_messages = new Array();
        _CF_error_fields = new Object();
        _CF_FirstErrorField = null;

        //form element FirstName required check
        if( !_CF_hasValue(_CF_this['FirstName'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "FirstName", _CF_this['FirstName'].value, "Error in FirstName text.");
            _CF_error_exists = true;
        }

        //form element Email required check
        if( _CF_hasValue(_CF_this['Email'], "TEXT", false ) )
        {
            //form element Email 'EMAIL' validation checks
            if (!_CF_checkEmail(_CF_this['Email'].value, true))
            {
                _CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Error in Email text.");
                _CF_error_exists = true;
            }

        }else {
            _CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Error in Email text.");
            _CF_error_exists = true;
        }

        //form element Phone required check
        if( _CF_hasValue(_CF_this['Phone'], "TEXT", false ) )
        {
            //form element Phone 'TELEPHONE' validation checks
            if (!_CF_checkphone(_CF_this['Phone'].value, true))
            {
                _CF_onError(_CF_this, "Phone", _CF_this['Phone'].value, "Error in Phone text.");
                _CF_error_exists = true;
            }

        }else {
            _CF_onError(_CF_this, "Phone", _CF_this['Phone'].value, "Error in Phone text.");
            _CF_error_exists = true;
        }

        //form element Address required check
        if( !_CF_hasValue(_CF_this['Address'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "Address", _CF_this['Address'].value, "Error in Address text.");
            _CF_error_exists = true;
        }

        //form element City required check
        if( !_CF_hasValue(_CF_this['City'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "City", _CF_this['City'].value, "Error in City text.");
            _CF_error_exists = true;
        }

        //form element State required check
        if( !_CF_hasValue(_CF_this['State'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "State", _CF_this['State'].value, "Error in State text.");
            _CF_error_exists = true;
        }

        //form element Zip required check
        if( _CF_hasValue(_CF_this['Zip'], "TEXT", false ) )
        {
            //form element Zip 'ZIPCODE' validation checks
            if (!_CF_checkzip(_CF_this['Zip'].value, true))
            {
                _CF_onError(_CF_this, "Zip", _CF_this['Zip'].value, "Error in Zip text.");
                _CF_error_exists = true;
            }

        }else {
            _CF_onError(_CF_this, "Zip", _CF_this['Zip'].value, "Error in Zip text.");
            _CF_error_exists = true;
        }

        //form element From required check
        if( !_CF_hasValue(_CF_this['From'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "From", _CF_this['From'].value, "Error in From text.");
            _CF_error_exists = true;
        }

        //form element To required check
        if( !_CF_hasValue(_CF_this['To'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "To", _CF_this['To'].value, "Error in To text.");
            _CF_error_exists = true;
        }


        //display error messages and return success
        if( _CF_error_exists )
        {
            if( _CF_error_messages.length > 0 )
            {
                // show alert() message
                _CF_onErrorAlert(_CF_error_messages);
                // set focus to first form error, if the field supports js focus().
                if( _CF_this[_CF_FirstErrorField].type == "text" )
                { _CF_this[_CF_FirstErrorField].focus(); }

            }
            return false;
        }else {
            return true;
        }
    }
	
//Career Form Validation/////////////////////////////////
/////////////////////////////////////////////////////////	
	function  _CF_checkCareersForm(_CF_this)
    {
        //reset on submit
        _CF_error_exists = false;
        _CF_error_messages = new Array();
        _CF_error_fields = new Object();
        _CF_FirstErrorField = null;

        //form element FirstName required check
        if( !_CF_hasValue(_CF_this['FirstName'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "FirstName", _CF_this['FirstName'].value, "Error in FirstName text.");
            _CF_error_exists = true;
        }

        //form element LastName required check
        if( !_CF_hasValue(_CF_this['LastName'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "LastName", _CF_this['LastName'].value, "Error in LastName text.");
            _CF_error_exists = true;
        }

        //form element Email required check
        if( _CF_hasValue(_CF_this['Email'], "TEXT", false ) )
        {
            //form element Email 'EMAIL' validation checks
            if (!_CF_checkEmail(_CF_this['Email'].value, true))
            {
                _CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Error in Email text.");
                _CF_error_exists = true;
            }

        }else {
            _CF_onError(_CF_this, "Email", _CF_this['Email'].value, "Error in Email text.");
            _CF_error_exists = true;
        }

        //form element Phone required check
        if( _CF_hasValue(_CF_this['Phone'], "TEXT", false ) )
        {
            //form element Phone 'TELEPHONE' validation checks
            if (!_CF_checkphone(_CF_this['Phone'].value, true))
            {
                _CF_onError(_CF_this, "Phone", _CF_this['Phone'].value, "Error in Phone text.");
                _CF_error_exists = true;
            }

        }else {
            _CF_onError(_CF_this, "Phone", _CF_this['Phone'].value, "Error in Phone text.");
            _CF_error_exists = true;
        }

        //form element Address required check
        if( !_CF_hasValue(_CF_this['Address'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "Address", _CF_this['Address'].value, "Error in Address text.");
            _CF_error_exists = true;
        }

        //form element City required check
        if( !_CF_hasValue(_CF_this['City'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "City", _CF_this['City'].value, "Error in City text.");
            _CF_error_exists = true;
        }

        //form element State required check
        if( !_CF_hasValue(_CF_this['State'], "TEXT", false ) )
        {
            _CF_onError(_CF_this, "State", _CF_this['State'].value, "Error in State text.");
            _CF_error_exists = true;
        }

        //form element Zip required check
        if( _CF_hasValue(_CF_this['Zip'], "TEXT", false ) )
        {
            //form element Zip 'ZIPCODE' validation checks
            if (!_CF_checkzip(_CF_this['Zip'].value, true))
            {
                _CF_onError(_CF_this, "Zip", _CF_this['Zip'].value, "Error in Zip text.");
                _CF_error_exists = true;
            }

        }else {
            _CF_onError(_CF_this, "Zip", _CF_this['Zip'].value, "Error in Zip text.");
            _CF_error_exists = true;
        }


        //display error messages and return success
        if( _CF_error_exists )
        {
            if( _CF_error_messages.length > 0 )
            {
                // show alert() message
                _CF_onErrorAlert(_CF_error_messages);
                // set focus to first form error, if the field supports js focus().
                if( _CF_this[_CF_FirstErrorField].type == "text" )
                { _CF_this[_CF_FirstErrorField].focus(); }

            }
            return false;
        }else {
            return true;
        }
    }
	