var elqPPS = '50';
var form = "DoNotModify"; 
window.onload = initPage;
function initPage(){
    if (this.GetElqCustomerGUID){
        document.forms['DoNotModify'].elements['elqCustomerGUID'].value = GetElqCustomerGUID();
    }
    setfields();
}
// Figure out if user's browser is Explorer
browserVersion=0
if (navigator.appName.indexOf("Microsoft") != -1){
	if (navigator.appVersion.indexOf("MSIE")!=-1){
			temp=navigator.appVersion.split("MSIE")
			browserVersion=parseFloat(temp[1])
	}
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ValidateEmailAddress(Element) {
   var varRegExp='^[A-Z0-9!#\\$%&\'\\*\\+\\-/=\\?\\^_`\\{\\|\\}~][A-Z0-9!#\\$%&\'\\*\\+\\-/=\\?\\^_`\\{\\|\\}~\\.]{0,62}@([A-Z0-9](?:[A-Z0-9\\-]{0,61}[A-Z0-9])?(\\.[A-Z0-9](?:[A-Z0-9\\-]{0,61}[A-Z0-9])?)+)$';
   if ((Element) && (Element.value != '')) {
      Element.value = trim(Element.value);
      var reg = new RegExp(varRegExp,"i");
      var match = reg.exec(Element.value);
         if ((match) && (match.length=3) && (match[1].length<=255) && ((match[2].length>=3) & (match[2].length<=7)))
            return true;
   }
   return false;
}

function formSubmit()
    {
        var blnOk = true;
	 
        if (!document.forms[form])
        {
            alert('Form not found on this page.');
            blnOk = false;
        }
//This is the vaildation for short forms------------------------------------------------------------
             if (blnOk)
        {
               if (document.forms[form].C_EmailAddress)
               {
                       if (browserVersion==0)
                       {
                               if (document.forms[form].C_EmailAddress.value == '')
                               {
				                    omnitureFormAnalysis('Missing e-mail');
                                      alert('Please enter your email.');
                                      blnOk = false;
                               }
                               else if(!ValidateEmailAddress(document.forms[form].C_EmailAddress))
                               {
								    omnitureFormAnalysis('Missing valid email address');
                                      alert('Please enter a valid email address.');
                                      blnOk = false;
                               }
                       }
                       if (browserVersion>=5.5)
                       {
                               if (document.forms[form].C_EmailAddress.value == '')
                               {
                                       omnitureFormAnalysis('Missing e-mail');
									  alert('Please enter your email.');
                                      blnOk = false;
                               }
                               else if(!ValidateEmailAddress(document.forms[form].C_EmailAddress))
                               {
								   omnitureFormAnalysis('Missing valid email address');
                                      alert('Please enter a valid email address.');
                                      blnOk = false;
                               }
                       }
               }
        }
               
        // Check Email Domain
               if (blnOk)
               {
               if (document.forms[form].C_EmailAddress){
                       var user_email = document.getElementById('C_EmailAddress').value;
                       var user_domain = user_email.substring( user_email.indexOf("@")+1, user_email.length );
                       var baddomains = Array( "yahoo.com", "gmail.com", "hotmail.com", "aol.com", "comcast.net", "adelphia.net", "netzero.com", "cox.net", "aol.net", "att.net", "cableone.com", "comcast.com", "earthlink.com", "email.com", "excite.com", "hotpop.com", "juno.com", "lycos.com", "mindspring.com", "msn.com", "mymail.com", "netscape.com", "qwest.com", "rocketmail.com", "usa.com", "Verizon.com", "cableone.net", "earthlink.net", "email.net", "excite.net", "gmail.net", "hotmail.net", "hotpop.net", "juno.net", "lycos.net", "mindspring.net", "msn.net", "mymail.net", "netscape.net", "netzero.net", "qwest.net", "rocketmail.net", "usa.net", "verizon.net", "yahoo.net" );
                       //loop through bad domain list and see if it matches any of them
                       for( var dm = 0; dm <= baddomains.length-1; dm++)
                       {
                               if( user_domain == baddomains[dm] )
                               {
                                      
                                      blnOk = false;
									  omnitureFormAnalysis('Missing business email address');
                                      alert("Please enter a business email address.");
                                      break;
                               }
                       }
                       
               }
        }
//End e-mail validation-----------------------------------------------------------------------------------------------

//This is the validation for the long form ---------------------------------------------------------------------------	
        // FirstName
        if (blnOk)
        {
            if (document.forms[form].C_FirstName)
            {
                if (document.forms[form].C_FirstName.value == '')
                {
                    omnitureFormAnalysis('Missing first name');
                    alert('Please enter your first name.');
                    blnOk = false;
                }
            }
        }
        // LastName
        if (blnOk)
        {
            if (document.forms[form].C_LastName)
            {
                if (document.forms[form].C_LastName.value == '')
                {
		    omnitureFormAnalysis('Missing last name');
                    alert('Please enter your last name.');
                    blnOk = false;
                }
            }
        }
 
        // Company
        if (blnOk)
        {
            if (document.forms[form].C_Company)
            {
                if (document.forms[form].C_Company.value == '')
                {
		    omnitureFormAnalysis('Missing Company name');
                    alert('Please enter your company name.');
                    blnOk = false;
                }
            }
        }
		// Postal code
        if (blnOk)
        {
            if (document.forms[form].C_Zip_Postal)
            {
                if (document.forms[form].C_Zip_Postal.value == '')
                {  
		    omnitureFormAnalysis('Missing Zip code');
                    alert('Please enter your zip or postal code.');
                    blnOk = false;
                }
            }
        }
		  // Business Phone
        if (blnOk)
        {
            if (document.forms[form].C_BusPhone)
            {
                if (document.forms[form].C_BusPhone.value == '')
                {
		    omnitureFormAnalysis('Missing Phone number');
                    alert('Please enter your phone number.');
                    blnOk = false;
                }
            }
        }
	

        // Title
        if (blnOk)
        {
            if (document.forms[form].C_Title__Exact_1)
            {
                if (document.forms[form].C_Title__Exact_1.value == '')
                {
		    omnitureFormAnalysis('Missing Title');
                    alert('Please indicate your Title.');
                    blnOk = false;
                }
            }
        }  
		//Country
		  if (blnOk)
        {
            if (document.forms[form].C_Country)
            {
                if (document.forms[form].C_Country.value == '')
                {
		    omnitureFormAnalysis('Missing Country');
                    alert('Please enter your Country.');
                    blnOk = false;
                }
            }
        }
		
		// Corporate Card Provider
        if (blnOk)
        {
            if (document.forms[form].C_Corp_Card_Types1)
            {
                if (document.forms[form].C_Corp_Card_Types1.value == '')
                {

		    omnitureFormAnalysis('Missing Corporate Card Provider');
                    alert('Please enter your Corporate Card Provider.');
                    blnOk = false;
                }
            }
        }
		
		//Number of employees
		  if (blnOk)
        {
            if (document.forms[form].C_CT_EMPLOYEES1)
            {
                if (document.forms[form].C_CT_EMPLOYEES1.value == '')
                {
		    omnitureFormAnalysis('Missing Number of employees');
                    alert('Please number of employees.');
                    blnOk = false;
                }
            }
        }
	    
		//payroll
		if (blnOk)
        {
            if (document.forms[form].C_CT_PAYROLL1)
            {
                if (document.forms[form].C_CT_PAYROLL1.value == '')
                {
		    omnitureFormAnalysis('Missing how your company processes payroll');
                    alert('Please indicate how your company processes payroll.');
                    blnOk = false;
                }
            }
        }
//end long form validation  ------------------------------------------------------------------------------------------  

//Short travel form validation ---------------------------------------------------------------------------------------
		  //How do you book travel
        if (blnOk)
        {
            if (document.forms[form].C_How_do_you_book_travel1)
            {
                if (document.forms[form].C_How_do_you_book_travel1.value == '')
                {
		    omnitureFormAnalysis('Missing How do you book travel');
                    alert('Please enter how you book travel.');
                    blnOk = false;
                }
            }
        }
 
   // Concern - Travel Manager
        if (blnOk)
        {
            if (document.forms[form].C_Concern___Travel_Manager1)
            {
                if (document.forms[form].C_Concern___Travel_Manager1.value == '')
                {
		    omnitureFormAnalysis('Missing What your most important area of travel concern');
                    alert('Please enter your most important area of travel concern.');
                    blnOk = false;
                }
            }
        }
		 // Travel Volume Monthly
        if (blnOk)
        {
            if (document.forms[form].C_Travel_Volume_Monthly1)
            {
                if (document.forms[form].C_Travel_Volume_Monthly1.value == '')
                {
		    omnitureFormAnalysis('Missing how many air travel transactions your organization processes monthly');
                    alert('Please enter how many air travel transactions your organization processes monthly.');
                    blnOk = false;
                }
            }
        }
		//TMC / Travel Agency (Yes/No)
		if (blnOk)
		{
			if (document.forms[form].C_TMC_Travel_Agency1)
			{
				if(document.forms[form].C_TMC_Travel_Agency1[0].checked )
				{		
					if (document.forms[form].C_TMC_Travel_Agency_Other1)
					{
						if (document.forms[form].C_TMC_Travel_Agency_Other1.value == '')
						{
							omnitureFormAnalysis('Missing Who is you current TMC:');
							alert('Please enter your current TMC.');
							blnOk = false;
						}
					}
				}
			}
		}
//End short travel form validation ------------------------------------------------------------------------------	

//Short expense form validation ---------------------------------------------------------------------------------	



		 // Current Expense Process
        if (blnOk)
        {
            if (document.forms[form].C_Expense_Reporting_Process1)
            {
                if (document.forms[form].C_Expense_Reporting_Process1.value == '')
                {
		    omnitureFormAnalysis('Missing which describes your current expense reporting process');
                    alert('Please select which describes your current expense reporting process');
                    blnOk = false;
                }
            }
        }
		 // Expense Reports Monthly
        if (blnOk)
        {
            if (document.forms[form].C_CT_MONEXPREPORTS1)
            {
                if (document.forms[form].C_CT_MONEXPREPORTS1.value == '')
                {
		    omnitureFormAnalysis('Missing how many expense reports does your organization process monthly:');
                    alert('Please select how many expense reports your organization processes monthly:');
                    blnOk = false;
                }
            }
        }
	
		 // T&E Concerns
       if (blnOk)
       {
           if (document.forms[form].C_T_E_Concerns1)
	       {
             var radios = document.forms[form].elements['C_T_E_Concerns1'];
             var radiosChecked = false;
             for (var i=0; i <radios.length; i++) 
			 {
			   if (radios[i].checked) {
				radiosChecked = true;
			   }
             }
			 if (!radiosChecked)
             { 
		omnitureFormAnalysis('Missing What is your primary concern about expense reporting');
                alert('Please select your primary concern about expense reporting.');
                 blnOk = false;
              }
            }
          } 
		  	
//End short expense form validation --------------------------------------------------------------------------------

//Short invoice form validation --------------------------------------------------------------------------------

			// Current Purchase Process
        if (blnOk)
        {
            if (document.forms[form].C_Current_Purchase_Process1)
            {
                if (document.forms[form].C_Current_Purchase_Process1.value == '')
                {
		    omnitureFormAnalysis('Missing How you currently buy goods/services');
                    alert('Please select how you currently buy goods/services.');
                    blnOk = false;
                }
            }
        }
		  	// Current Invoice Process
       if (blnOk)
       {
           if (document.forms[form].C_Current_Invoice_Process1)
	       {
             var radios = document.forms[form].elements['C_Current_Invoice_Process1'];
             var radiosChecked = false;
             for (var i=0; i <radios.length; i++) 
			 {
			   if (radios[i].checked) {
				radiosChecked = true;
			   }
             }
			 if (!radiosChecked)
             { 
		omnitureFormAnalysis('Missing whats your current invoice process look like today');
                alert('Please select What your current invoice process looks like today.');
                 blnOk = false;
              }
            }
          } 
		   	// Invoice Volume Monthly
        if (blnOk)
        {
            if (document.forms[form].C_Invoice_Volume_Monthly1)
            {
                if (document.forms[form].C_Invoice_Volume_Monthly1.value == '')
                {
		    omnitureFormAnalysis('Missing How many invoices does your company process monthly');
                    alert('Please select how many invoices your company processes monthly');
                    blnOk = false;
                }
            }
        }
		
//End short invoice form validation --------------------------------------------------------------------------------

//Short travelExpense form validation --------------------------------------------------------------------------------

		   	// How do you book travel
        if (blnOk)
        {
            if (document.forms[form].C_How_do_you_book_travel1)
            {
                if (document.forms[form].C_How_do_you_book_travel1.value == '')
                {
		    omnitureFormAnalysis('Missing How does your company currently book travel');
                    alert('Please select how your company currently books travel:');
                    blnOk = false;
                }
            }
        }
			// Travel & Expense Interface
        if (blnOk)
        {
            if (document.forms[form].C_Travel___Expense_Interface1)
            {
                if (document.forms[form].C_Travel___Expense_Interface1.value == '')
                {
		    omnitureFormAnalysis('Missing Does your current travel process interface to your current expense process:');
                    alert('Please select weather your current travel process interface to your current expense process.');
                    blnOk = false;
                }
            }
        }
				// Travel & Expense Interface
        if (blnOk)
        {
            if (document.forms[form].C_Travel___Expense_Interface1)
            {
                if (document.forms[form].C_Travel___Expense_Interface1.value == '')
                {
		    omnitureFormAnalysis('Missing Does your current travel process interface to your current expense process:');
                    alert('Please select weather your current travel process interface to your current expense process.');
                    blnOk = false;
                }
            }
        }
		
//End Short travelExpense form validation -----------------------------------------------------------------------------

		// Disable
	  if (blnOk){
			   /*the following code sends a message to Omniture that the submit was successful*/
			   if(typeof(pageName)!='undefined'){
			   	s.sendFormEvent('s',pageName,document.getElementsByName("elqFormName")[0].value);
			   }
			   blnOk = DisableSubmit();
	   }       
 
        return blnOk;
}
/*This function accepts the error message a user gets when doing a form validation. It passes the error to Omniture for tracking*/
function omnitureFormAnalysis(message) {
	var elqFormName = document.getElementsByName("elqFormName")[0].value;
	if(typeof(pageName)!='undefined'){
		s.sendFormEvent('e', pageName, elqFormName, message);
	}	
}


maxLength=1000; 
function initCount(ident,displayId){ // initial display setting
  taObj=document.getElementById(ident);
  if (displayId.toLowerCase()=="nodisplay") {return;} // suppress display
  dispObj=document.getElementById(displayId);
  dispObj.innerHTML=maxLength-taObj.value.length;
}
function taCount(ident,displayId){
  taObj=document.getElementById(ident);
  taLength=taObj.value.length; // look at current length
  if (taLength>maxLength) { // clip characters
    taObj.value = taObj.value.substring(0,maxLength);}
  taLength=taObj.value.length; oldLength=0;
  if (displayId.toLowerCase()=="nodisplay") {return;} // suppress display
  dispObj=document.getElementById(displayId);
  dispObj.innerHTML=(maxLength-taObj.value.length);
}

// Populate email forward information for emailfooter
function getQueryStringParamValue(strQStrParam) {
var strURL = document.location.href;
var strQStrParamValue = '';
            if (strURL.indexOf('?') != -1)
            {
                        strQStrParamValue = strURL.substr(strURL.indexOf('?') + 1);
                        if (strQStrParamValue.indexOf(strQStrParam) != -1)
                        {
                                    strQStrParamValue = strQStrParamValue.substr(strQStrParamValue.indexOf(strQStrParam));
                                    strQStrParamValue = strQStrParamValue.substr(strQStrParamValue.indexOf('=') + 1);
                                    if (strQStrParamValue.indexOf('&') != -1)
                                    strQStrParamValue = strQStrParamValue.substr(0, strQStrParamValue.indexOf('&'));
                                    return strQStrParamValue;
                        }else{
                                    return strQStrParamValue;
                        }
            }else{
                        return strQStrParamValue;
            }
}
 
function setfields(){
// Populate query string values
	var fullURL = parent.document.URL;
	if(document.forms[form].qs){
		document.forms[form].elements['qs'].value=fullURL.substring(fullURL.indexOf('?')+1, fullURL.length) ;
	}
	if(document.forms[form].email){
		document.forms[form].elements['email'].value = getQueryStringParamValue('email');
	}
	if(document.forms[form].docid){
		document.forms[form].elements['docid'].value = getQueryStringParamValue('docid');
	}
	if(document.forms[form].doc){
 		var doc = getQueryStringParamValue('doc');
		if(doc != ''){
			document.forms[form].elements['doc'].value=doc;
			if(document.forms[form].retURL){
				if(document.forms[form].retURL.value == ""){
					document.forms[form].elements['retURL'].value='http://www.concur.com/thanks/litrequest.html?doc='+doc;
				}
			}
		}
	}
 }
//override the Return URL for document call to actions
function overrideRetURL(urlVal){
	if(document.forms[form].doc){
		var myDoc = getQueryStringParamValue('doc');
		document.forms[form].elements['doc'].value=myDoc;
		if(document.forms[form].retURL){
			document.forms[form].elements['retURL'].value=urlVal+'?doc='+myDoc;
		}
	}
}


//lit request code
function setpdf(){
        var url ="http://www.concur.com/elqNow/elqRedir.htm?ref=http://www.concur.com/products/PDFs/" +getQueryStringParamValue('doc') + ".pdf";
   	var newWin = window.open(url,null,"toolbar=1,status=1,scrollbars=1,menubar=1,resizable=1,left=260,top=191,width=800,height=500");
        if(newWin==null){if(document.images){window.opener.location.replace(url);}
   	else{window.opener.location = url;}
	}else{newWin.opener = self;}
}