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('Veuillez saisir votre adresse email.');
                                      blnOk = false;
                               }
                               else if(!ValidateEmailAddress(document.forms[form].C_EmailAddress))
                               {
								    omnitureFormAnalysis('Missing valid email address');
                                      alert('Veuillez saisir une adresse email valide.');
                                      blnOk = false;
                               }
                       }
                       if (browserVersion>=5.5)
                       {
                               if (document.forms[form].C_EmailAddress.value == '')
                               {
                                       omnitureFormAnalysis('Missing e-mail');
									  alert('Veuillez saisir votre adresse email.');
                                      blnOk = false;
                               }
                               else if(!ValidateEmailAddress(document.forms[form].C_EmailAddress))
                               {
								   omnitureFormAnalysis('Missing valid email address');
                                      alert('Veuillez saisir une adresse email valide.');
                                      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("Veuillez saisir une adresse email professionelle.");
                                      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('Veuillez saisir votre pr\u00e9nom');
                    blnOk = false;
                }
            }
        }
        // LastName
        if (blnOk)
        {
            if (document.forms[form].C_LastName)
            {
                if (document.forms[form].C_LastName.value == '')
                {
		    omnitureFormAnalysis('Missing last name');
                    alert('Veuillez saisir votre nom.');
                    blnOk = false;
                }
            }
        }
 
        // Company
        if (blnOk)
        {
            if (document.forms[form].C_Company)
            {
                if (document.forms[form].C_Company.value == '')
                {
		    omnitureFormAnalysis('Missing Company name');
                    alert('Veuillez saisir le nom de votre soci\u00e9t\u00e9');
                    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('Veuillez saisir votre code postal');
                    blnOk = false;
                }
            }
        }
		  // Business Phone
        if (blnOk)
        {
            if (document.forms[form].C_BusPhone)
            {
                if (document.forms[form].C_BusPhone.value == '')
                {
		    omnitureFormAnalysis('Missing Phone number');
                    alert('Veuillez saisir votre numero de t\u00e9l\u00e9phone');
                    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('PVeuillez indiquer votre fonction.');
                    blnOk = false;
                }
            }
        }  
		//Country
		  if (blnOk)
        {
            if (document.forms[form].C_Country)
            {
                if (document.forms[form].C_Country.value == '')
                {
		    omnitureFormAnalysis('Missing Country');
                    alert('Veuillez saisir votre pays.');
                    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('Veuillez indiquer l\u2019effectif');
                    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('Veuillez indiquer le syst\u00e8me de gestion de paye utilis\u00e9 par votre soci\u00e9t\u00e9');
                    blnOk = false;
                }
            }
        }
		//C_Current_Booking_Solution1
		if (blnOk)
        {
            if (document.forms[form].C_Current_Booking_Solution1)
            {
                if (document.forms[form].C_Current_Booking_Solution1.value == '')
                {
		    omnitureFormAnalysis('Missing Do you use e-Travel online booking tool');
                    alert('Veuillez indiquer Utilisez-vous un outil de r\u00e9servation en ligne ?');
                    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('Veuillez indiquer comment votre soci\u00e9t\u00e9 r\u00e9serve les d\u00e9placements des collaborateurs :');
                    blnOk = false;
                }
            }
        }
 
 
 //C_Travel_Requests1
 
  if (blnOk)
        {
            if (document.forms[form].C_Travel_Requests1)
            {
                if (document.forms[form].C_Travel_Requests1.value == '')
                {
		    omnitureFormAnalysis('Missing Do you use travel requests:');
                    alert('Veuillez indiquer si vous utilisez des demandes pr\u00e9alables de voyage ou ordre de mission :');
                    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('Veuillez indiquer \u00e0 quelle probl\u00e9matique principale vous \u00EAtes confront\u00e9s en mati\u00e9re de gestion des d\u00e9placements : ');
                    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('Veuillez s\u00e9lectionner le nombre de d\u00e9placements professionnels g\u00e9r\u00e9s par votre soci\u00e9t\u00e9 : ');
                    blnOk = false;
                }
            }
        }
		//TMC / Travel Agency 
		if (blnOk)
		{
			if (document.forms[form].C_TMC_Travel_Agency1)
			{
				if (document.forms[form].C_TMC_Travel_Agency1.value == '')
				{
					omnitureFormAnalysis('Missing Who is you current TMC:');
					alert('Veuillez s\u00e9lectionner votre agence de voyage  actuelle :');
					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('Veuillez indiquer comment vous g\u00e9rez le remboursement des frais professionnels: ');
                    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('Veuillez indiquer le nombre de note de frais mensuel trait\u00e9 par votre soci\u00e9t\u00e9: ');
                    blnOk = false;
                }
            }
        }
	
		 // T&E Concerns
       if (blnOk)
       {
           if (document.forms[form].C_T_E_Concerns1)
	       {
             var TEradios = document.forms[form].elements['C_T_E_Concerns1'];
             var TEradiosChecked = false;
             for (var TEradiosCount=0; TEradiosCount < TEradios.length; TEradiosCount++)
			 {
			   if (TEradios[TEradiosCount].checked) {
				TEradiosChecked = true;
			   }
             }
			 if (!TEradiosChecked)
             { 
		omnitureFormAnalysis('Missing What is your primary concern about expense reporting');
                alert('Veuillez indiquer \u00e0 quelle probl\u00e9matique principale vous t\u00e7tes confront\u00e9s en mati\u00e8re de gestion des notes de frais:');
                 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('Veuillez indiquer votre processus d\u2019achat actuel :');
                    blnOk = false;
                }
            }
        }
		  	// Current Invoice Process
       if (blnOk)
       {
           if (document.forms[form].C_Current_Invoice_Process1)
	       {
             var invoiceRadios = document.forms[form].elements['C_Current_Invoice_Process1'];
             var invoiceRadiosChecked = false;
             for (var invoiceRadioCount=0; invoiceRadioCount < invoiceRadios.length; invoiceRadioCount++)
			 {
			   if (invoiceRadios[invoiceRadioCount].checked) {
				invoiceRadiosChecked = true;
			   }
             }
			 if (!invoiceRadiosChecked)
             { 
		omnitureFormAnalysis('Missing whats your current invoice process look like today');
                alert('Veuillez indiquer votre processus actuel de gestion des factures fournisseurs :');
                 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('Veuillez indiquer le nombre mensuel de factures fournisseur trait\u00e9 par votre soci\u00e9t\u00e9 :');
                    blnOk = false;
                }
            }
        }
		//C_Primary_Concern_Invoice1
		   if (blnOk)
       {
           if (document.forms[form].C_Primary_Concern_Invoice1)
	       {
             var radios = document.forms[form].elements['C_Primary_Concern_Invoice1'];
             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 your invoice process:');
                alert('Veuillez indiquer votre probl\u00e9matique principale en mati\u00e8re de gestion des factures fournisseur :');
                 blnOk = false;
              }
            }
          } 
		
//End short invoice form validation --------------------------------------------------------------------------------

//Short travelExpense form validation --------------------------------------------------------------------------------

		
			// 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('Veuillez indiquer si, dans votre processus actuel, la gestion des d\u00e9placements professionnels elle li\u00e9e � la gestion des notes de frais : ');
                    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'){
                               try{
                                   s.sendFormEvent('s',pageName,document.getElementsByName("elqFormName")[0].value);
                               }
                               catch (e){}
			   }
                           //the concur_sAccount variable is set in the s_code.js file
                           if(typeof(concur_sAccount)!='undefined')
                           {
                                sendEventsToOmniture(getQueryStringParamValue('docid'),concur_sAccount);
                           }
			   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;}
}