 /* 
 ' $Header: /WebSites/library/javascript/general/VOHomePage.js 2     4/15/09 7:14p Sampsonm $
 ' $Workfile: VOHomePage.js $ 
 ' $Author: Sampsonm $ 
 ' $Date: 4/15/09 7:14p $ 
 ' $Revision: 2 $ 
 ' 
 ' created by: Mccusker.
 ' 
 ' description: Javascript functions used on VO home page
 ' 
 */
    
    var mb = new MessageBuffer();
    var fieldGroup = new Group('CruiseForm', 'One or more errors has been detected in the customer info form.');

    function initPage() {
        //---add field validators to group
        fieldGroup.addField('SearchForm.shoppingZipCode', 'lblZip', 'ROWINDEX_POS_ZIPCODE' , 'ROWINDEX_NEG_INVALIDZIPCODE', 'Please enter a valid U.S. zip code.<br />');       
    }
    
    function doSubmit() {
        mb.init();
        fieldGroup.resetLabels();      

        //---this command will run validation and populate the globally scoped
        //-  message buffer
        fieldGroup.validateGroup();
        
        if(mb.count > 0) {
            dispatchMessages(mb);
            window.scroll(0,0);
            return false;
        } else {
           // EntirePage.style.display = 'none';
           // WaitPage.style.display = 'block';
          // doc = window.document;
           // SubmitFormSP(doc);
            return true;
        }
    }        


    function goDestinationList(){       
        var gateway = escape(document.SearchForm.gateway.options[document.SearchForm.gateway.selectedIndex].value);
        var gatewaycode = "";       
        if (gateway.length > 3) gatewaycode = gateway.substring(0,3).toUpperCase();
        var queryString = "&gatewaycodeadd=" + gatewaycode;
        location.href = "/s/v/destinationlist.asp?p=p" + queryString;
    }  
	function showDiv(as_name) {
        var el = document.getElementById(as_name);
        
        if(el) {
            el.style.display = "block";
            el.style.visibility = "visible";
        }
    }
    
    function hideDiv(as_name) {
        var el = document.getElementById(as_name);

        if(el) {
            el.style.display = "none";
            el.style.visibility = "hidden";
        }
    }
	function emailSignupValidate(){
    		if (document.EmailForm.email.value == ""){
    			alert ("Your email address is a required field.");
    			document.EmailForm.email.focus();
                return false;
    		}else if (!ValidEmail(document.EmailForm.email)){
    			alert ("Please enter a Valid Email Address.\r(e.g., yourname@provider.com)")
    			document.EmailForm.email.select();		
                return false;
            }else if (document.EmailForm.zip.value == ""){
    			alert ("Your zip code is a required field.")
    			document.EmailForm.zip.select();	
                return false;
            }else if (parseFloat(document.EmailForm.zip.value)<=0 || isNaN(document.EmailForm.zip.value)  || (document.EmailForm.zip.value.indexOf('.') !== -1) || (trim(document.EmailForm.zip.value).length >= 1 && trim(document.EmailForm.zip.value).length < 5)){
    			alert ("Please enter your 5 digit zip code.")
    			document.EmailForm.zip.select();	
                return false;
    		}else{
    			document.EmailForm.submit();
    		}		 
    	} 
    	
   function openVacwin(win)
    {
        var winDesc = 'resizable=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,width=880,height=700';
        HelpWin = window.open(win,"ICT",winDesc);
        HelpWin.focus();
    }
    	
    	
