//----------------------------------------------------------------------// 
// 
// 
// 
// 
//----------------------------------------------------------------------// 
//	List of Functions
//----------------------------------------------------------------------// 
// 
// 	DisableButtons(theform)
// 	isEmpty(s)
// 	isWhitespace(s)
// 	IsTime(strTime)
// 	isEmail(s)
// 	isWhitespace(s)
// 	isWhitespace(s)
// 	isWhitespace(s)
// 	isWhitespace(s)


	// Variable Declarations
	var whitespace = " \t\n\r";
	 
	////////////////////////////////////////////////////////
	/// DHTML Combo Boxes
	////////////////////////////////////////////////////////
	var v=false;
	if (typeof(Option)+"" != "undefined") v=true;
	
	if(v)
	    {a=new Array();aln=0;}
	
	function getFormNum (formName) 
	    {
	        formNum =-1;
	        for (i=0;i<document.forms.length;i++)
	            {
	                tempForm = document.forms[i];
	                if (formName == tempForm) 
	                    {
	                        formNum = i;
	                        correctForm = tempForm;
	                        break;
	                    }
	            }
	        return formNum;
	    }
	
	function jmp(formName,elementNum) 
	    {
	        getFormNum(formName);
	        if (formNum>=0) 
	            {
	                with (document.forms[formNum].elements[elementNum]) 
	                    {
	                        i=selectedIndex;
	                        if (i>=0) location=options[i].value;
	                    }
	            }
	    }
	
	function O(txt,url){a[k]=new Option(txt,url);k++;}
	function DisableButtons(theform){if (document.all||document.getElementById){for (i=0;i<theform.length;i++){var tempobj=theform.elements[i];if(tempobj.type.toLowerCase()=="submit")tempobj.disabled=true;}}}
	function EnableButtons(theform){if (document.all||document.getElementById){for (i=0;i<theform.length;i++){var tempobj=theform.elements[i];if(tempobj.type.toLowerCase()=="submit")tempobj.disabled=false}}}		
	function HMStoSeconds(T){var A = T.split(/\D+/);return (A[0]*60 + +A[1])*60 + +A[2];}
	function isEmpty(s){return ((s == null) || (s.length == 0))}    // Check whether string s is empty.
		
	/****************************************************************/
	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;
		}

	function IsTime(strTime)
		{
			var strTestTime = new String(strTime);
			strTestTime.toUpperCase();
	
			var bolTime = false;
	
			if (strTestTime.indexOf("PM",1) != -1 || strTestTime.indexOf("AM",1))
				bolTime = true;
	
			if (bolTime && strTestTime.indexOf(":",0) == 0)
				bolTime = false;
	
			var nColonPlace = strTestTime.indexOf(":",1);
			if (bolTime && ((parseInt(nColonPlace) + 5) < (strTestTime.length - 1) || (parseInt(nColonPlace) + 4) > (strTestTime.length - 1)))
				bolTime = false;
	
	
			return bolTime;
		}
		
		function multiEmail(email_field) {
			var email = email_field.split(',');
		for (var i = 0; i < email.length; i++) {
				if (!validateEmail(email[i], 1, 0)) 
					{
						alert('one or more email addresses entered is invalid');
						return false;
					}
				}
				return true;
			} 
					
		function ValidateEmailAddress(sEmail,Message) 
			{
				var sCharacterFilter = '\/\'\\ ":?!()[]\{\}^|';
				for (i=0; i<sCharacterFilter.length; i++) 
					{
	   					if (sEmail.indexOf(sCharacterFilter.charAt(i),0) > -1) 
							{
      							alert(Message + " email address contains invalid characters");
      							return false;
   							}
					}
				
				for (i=0; i< sEmail.length; i++) 
					{
   						if (sEmail.charCodeAt(i)>127) 
							{
						  		alert(Message + " email address contains non ascii characters.");
						  		return false;
   							}
					}

				var atPos = sEmail.indexOf('@',0);
				if (atPos == -1) 
					{
					   alert(Message + " email address must contain an @");
					   return false;
					}
					
				if (atPos == 0) 
					{
					   alert(Message + " email address must not start with @");
					   return false;
					}
					
				if ((sEmail.indexOf(';', atPos) == 0) && (sEmail.indexOf('@', atPos + 1) > - 1)) 
					{
					   alert(Message + " email address must contain only one @");
					   return false;
					}
					
				if (sEmail.indexOf('.', atPos) == -1) 
					{
					   alert(Message + " email address must contain a period in the domain name");
					   return false;
					}
					
				if (sEmail.indexOf('@.',0) != -1) 
					{
					   alert(Message + " period must not immediately follow @ in email address");
					   return false;
					}
					
				if (sEmail.indexOf('.@',0) != -1)
					{
					   alert(Message + " period must not immediately precede @ in email address");
					   return false;
					}
					
				if (sEmail.indexOf('..',0) != -1) 
					{
					   alert(Message + " two periods must not be adjacent in email address");
					   return false;
					}
				
				var str = sEmail;
				if (str.search('UserName') == 0)
					{
					   alert(Message + " invalid username in email address");
					   return false;
					}	
							
				var suffix = sEmail.substring(sEmail.lastIndexOf('.')+1);
				if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') 
					{
					   alert(Message + " invalid primary domain in email address");
					   return false;
					}
			return true;
		}		

		
	/****************************************************************/
	
	// Checks to see if a required field is blank.  If it is, a warning
	// message is displayed...
	
	function ForceEntry(objField, FieldName)
	{
		var strField = new String(objField.value);
		if (isWhitespace(strField)) {
			alert("You need to enter information for " + FieldName);
			objField.focus();
			objField.select();
			return false;
		}
	
		return true;
	}
	
	/****************************************************************/
	// Returns true if the string passed in is a valid number
	//  (no alpha characters), else it displays an error message
	function ForceNumber(objField, FieldName)
		{
		   	var strValidChars = "0123456789.-";
		   	var strChar;
		   	var CheckString=objField.value;

   			if (CheckString.length == 0) 
				{
					alert('Please enter a numeric value for ' + FieldName + '!');
					objField.focus();
					objField.select();
					return false;
				}
			else if (CheckString == '.') 
				{
					alert('Please enter a numeric value for ' + FieldName + '!');
					objField.focus();
					objField.select();
					return false;
				}
			else
				{
	   				
					//  test strString consists of valid characters listed above
					for (i = 0; i < CheckString.length; i++)
      					{
							strChar = CheckString.charAt(i);
							if (strValidChars.indexOf(strChar) == -1)
								{
									alert('Please enter a numeric value for ' + FieldName + '!');
									objField.focus();
									objField.select();
									return false;
								}
      					}
   				}
			return true;
		}
		
   function TextLimit(Field, FieldName,MaxLen) 
		{
			if (Field.value.length > MaxLen + 1)
				{
					alert('The Maximum Input Length for ' + FieldName + ' field is ' + MaxLen + '!');
					if (Field.value.length > MaxLen)
						Field.value = Field.value.substring(0, MaxLen);
					return false;
				}
			return true;
		}
		
   function TextMinimum(Field, FieldName,MinLength) 
		{
			if (Field.value.length < MinLength)
				{
					alert('The Minimum Input Length for ' + FieldName + ' field is ' + MinLength + '!');
					return false;
				}
			return true;
		}		
		
/****************************************************************/

// Returns true if the string passed in is a valid money
//  (no alpha characters except a decimal place), 
//   else it displays an error message

function ForceMoney(objField, FieldName)
{
	var strField = new String(objField.value);
	
	if (isWhitespace(strField)) return true;

	var i = 0;

	for (i = 0; i < strField.length; i++)
		if ((strField.charAt(i) < '0' || strField.charAt(i) > '9') && (strField.charAt(i) != '.')) {
			alert(FieldName + " must be a valid numeric entry.  Please do not use commas or dollar signs or any non-numeric symbols.");
			objField.focus();
			return false;
		}

	return true;
}


/****************************************************************/

// Right trims the string...  Useful for SQL datatypes of CHAR

function RTrim(strTrim)
{
	var str = new String(strTrim);
	var i = 0;
	var c = "";
	var endpos = 0

	for (i = str.length; i >= 0 && endpos == 0; i = i - 1) {
		c = str.charAt(i);
		if (whitespace.indexOf(c) == -1)
			endpos = i;
	}

	return str.substring(0,endpos+1);
}

	/****************************************************************/
	
	/* PURPOSE:  Returns true if the string is a valid date number.
		A method is passed in (1 = month, 2 = day).  If the string is
		nonnumeric, false is passed back.  If the day in the date string
		is greater than 31, false is returned.  If the month is greater
		than 12, an error is returned.
	*/
	function isDateNumber(strNum,method)
		{
			var str = new String(strNum);
			var i = 0;
		
			if (isNaN(parseInt(str)) || parseInt(str) < 0) return false;
			if (method == 1)
				if (parseInt(str) > 31)
					return false;
			if (method == 2)
				if (parseInt(str) > 12)
					return false;
		
			for (i = 0; i < str.length; i++)
				if (str.charAt(i) < '0' || str.charAt(i) > '9')
					return false;
		
		
			return true;
		}

	/****************************************************************/
	// Displays an alert box with the passed in string...
	
	function PromptErrorMsg(Field,strError)
		{
			alert("You have entered an invalid date for " + strError + ".  Please make sure your date format is in M/D/Y format.");
			Field.focus();
		}
	
	/****************************************************************/
	
	/* PURPOSE: Checks to see if the string is a valid date.  A valid
		date is defined as any of the following:
	
			MM/DD/YY, MM/DD/YYYY, M/D/YY, M/D/YYYY,
			MM-DD-YY, MM-DD-YYYY, M-D-YY, M-D-YYYY
	*/
	function ForceDate(strDate,strField)
		{
			var str = new String(strDate.value);
			if (isWhitespace(str)) 
				{
					return true;
					// if the field is empty, just return true...
				}
	
			var i = 0, count = str.length, j = 0;
			while ((str.charAt(i) != "/" && str.charAt(i) != "-") && i < count)
				i++;
				if (i == count || i > 2) 
					{
						PromptErrorMsg(strDate,strField);
						return false;
					}
			
			var addOne = false;
			if (i == 2) addOne = true;
	
			if (!isDateNumber(str.substring(0,i),1)) 
				{
					PromptErrorMsg(strDate,strField);
					return false;
				}
		
			j = i+1;
			i = 0;
	
			while ((str.charAt(i+j) != "/" && str.charAt(j+i) != "-") && i+j < count)
				i++;
	
				if (i+j == count || i > 2) 
					{
						PromptErrorMsg(strDate,strField);
						return false;
					}

			if (!isDateNumber(str.substring(j,i+j),2)) 
				{
					PromptErrorMsg(strDate,strField);
					return false;
				}

			j = i+3;
			i = 0;

			if (addOne) j++;

			while (i+j < count)
				i++;

				if (i != 2 && i != 4) 
					{
						PromptErrorMsg(strDate,strField);
						return false;
					}

				if (!isDateNumber(str.substring(j,i+j),3)) 
					{
						PromptErrorMsg(strDate,strField);
						return false;
					}

				return true;
		}
		
	function LoadNoRightMouse()
	    {
			<!-- Begin
			function RightMouseClick(EventVal) 
				{
					if (navigator.appName == 'Netscape' && 
						(EventVal.which == 3 || EventVal.which == 2))
						return false;
					else if (navigator.appName == 'Microsoft Internet Explorer' && 
						(event.button == 2 || event.button == 3))
						{
							alert('Sorry, you do not have permission to right click.');
							return false;
						}
					return true;
				}
	
			document.onmousedown=RightMouseClick;
			document.onmouseup=RightMouseClick;
			if (document.layers) window.captureEvents(Event.MOUSEDOWN);
			if (document.layers) window.captureEvents(Event.MOUSEUP);
			window.onmousedown=RightMouseClick;
			window.onmouseup=RightMouseClick;
		}
		    
	function NoPageHistory()
		{
			javascript:window.history.forward(1);
		}

	function DiffDays(DateFrom,DateTo) 
		{ 
			// The number of milliseconds in one day
			var one_day = 1000 * 60 * 60 * 24;
		
			// Create date From
			var jsDateFrom = new Date();
			var jsDateTo = new Date();
			
			// Extract Date and Set Date From Information
			var iDay = DateFrom.substr(0,2);
			var iMonth = DateFrom.substr(3,2);
			var iYear = DateFrom.substr(6,4);
			
			jsDateFrom.setYear(iYear);
			jsDateFrom.setMonth(iMonth);
			jsDateFrom.setDate(iDay);
			
			// Extract Date and Set Date To Information
			var iDay = DateTo.substr(0,2);
			var iMonth = DateTo.substr(3,2);
			var iYear = DateTo.substr(6,4);
			
			jsDateTo.setYear(iYear);
			jsDateTo.setMonth(iMonth);
			jsDateTo.setDate(iDay);
			
			// Convert both dates to milliseconds
			var msDateFrom = jsDateFrom.getTime();
			var msDateTo = jsDateTo.getTime();
						
			// Calculate the difference in milliseconds
			var difference_ms = msDateTo - msDateFrom;
			
			// Convert back to days and return
			return Math.round(difference_ms/one_day)
		}
	
	function dateFormat(aDate, displayPat)
		{
		/********************************************************
		*   Valid Masks:
		*   !mmmm = Long month (eg. January)
		*   !mmm = Short month (eg. Jan)
		*   !mm = Numeric date (eg. 07)
		*   !m = Numeric date (eg. 7)
		*   !dddd = Long day (eg. Monday)
		*   !ddd = Short day (eg. Mon)
		*   !dd = Numeric day (eg. 07)
		*   !d = Numeric day (eg. 7)
		*   !yyyy = Year (eg. 1999)
		*   !yy = Year (eg. 99)
	   ********************************************************/
	
		intMonth = aDate.getMonth();
		intDate = aDate.getDate();
		intDay = aDate.getDay();
		intYear = aDate.getFullYear();
	
		var months_long =  new Array ('January','February','March','April',
		   'May','June','July','August','September','October','November','December')
		var months_short = new Array('Jan','Feb','Mar','Apr','May','Jun',
		   'Jul','Aug','Sep','Oct','Nov','Dec')
		var days_long = new Array('Sunday','Monday','Tuesday','Wednesday',
		   'Thursday','Friday','Saturday')
		var days_short = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat')
	
		var mmmm = months_long[intMonth]
		var mmm = months_short[intMonth]
		var mm = intMonth < 9?'0'+ (1 + intMonth) + '':(1+intMonth)+'';
		var m = 1+intMonth+'';
		var dddd = days_long[intDay];
		var ddd = days_short[intDay];
		var dd = intDate<10?'0'+intDate+'':intDate+'';
		var d = intDate+'';
		var yyyy = intYear;
	
		century = 0;
		while((intYear-century)>=100)
			century = century + 100;
	
		var yy = intYear - century
		if(yy<10)
			yy = '0' + yy + '';
	
		displayDate = new String(displayPat);
	
		displayDate = displayDate.replace(/!mmmm/i,mmmm);
		displayDate = displayDate.replace(/!mmm/i,mmm);
		displayDate = displayDate.replace(/!mm/i,mm);
		displayDate = displayDate.replace(/!m/i,m);
		displayDate = displayDate.replace(/!dddd/i,dddd);
		displayDate = displayDate.replace(/!ddd/i,ddd);
		displayDate = displayDate.replace(/!dd/i,dd);
		displayDate = displayDate.replace(/!d/i,d);
		displayDate = displayDate.replace(/!yyyy/i,yyyy);
		displayDate = displayDate.replace(/!yy/i,yy);
	
		return displayDate;
	}

	function toggleBox(szDivID, iState) // 1 visible, 0 hidden
		{
			if(document.layers)	   //NN4+
				{document.layers[szDivID].visibility = iState ? "show" : "hide";}
			else if(document.getElementById)	  //gecko(NN6) + IE 5+
				{
					var obj = document.getElementById(szDivID);
					obj.style.visibility = iState ? "visible" : "hidden";
				}
			else if(document.all)	// IE 4
				{document.all[szDivID].style.visibility = iState ? "visible" : "hidden";}
		}

	function toggleBoxBooking(szDivID,sHTML,iState) // 1 visible, 0 hidden
		{
			if(document.layers)	   //NN4+
				{
				   document.layers[szDivID].visibility = iState ? "show" : "hide";
				   document.layers[szDivID].height = iState ? "60" : "0";
				   document.layers[szDivID].innerHTML = iState ? "<font face='Verdana, Arial, Helvetica, sans-serif' size='1'>" + sHTML + "</font>" : "" ;
				}
			else if(document.getElementById)	  //gecko(NN6) + IE 5+
				{
					var obj = document.getElementById(szDivID);
					obj.style.visibility = iState ? "visible" : "hidden";
					obj.style.height = iState ? "60" : "0";
					obj.innerHTML=iState ? "<font face='Verdana, Arial, Helvetica, sans-serif' size='1'>" + sHTML + "</font>" : "" ;
				}
			else if(document.all)	// IE 4
				{
					document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
					document.all[szDivID].style.height = iState ? "60" : "0";
					document.all[szDivID].innerHTML=iState ? "<font face='Verdana, Arial, Helvetica, sans-serif' size='1'>" + sHTML + "</font>" : "" ;
				}
		}		

	function WriteProcessingHTML(ProcessingLabel,RootPath)
		{
			document.write ("<form name='frmProcessing'>");
			document.write ("<div ID='ProcessingBar' class='DivClass'>"); 
			document.write ("	<table border=0 cellpadding=0 cellspacing=0 height=30 width=100% align='center'>");
			document.write ("		<tr>");
			document.write ("			<td width='100%' height='100%' align='center' Valign='middle'><br><br>");
			document.write ("				<Font face='Helvetica,Verdana,Arial' color='#000066'>");
			document.write ("					<B><Font size='2'>" + ProcessingLabel + "<BR>... Loading. Please wait ...</Font></B>");
			document.write ("				</Font><br><br>");
			document.write ("				<IMG SRC='" + RootPath + "Images/Display/ProcessingBar.gif' border=0><br>");
			document.write ("				<br>"); 
			document.write ("			</td>");
			document.write ("		</tr>");
			document.write ("	</table>");
			document.write ("</div>");
			document.write ("</form>");		
		}
		
	function FormatNumber(num, decimalNum, bolLeadingZero, bolParens)
	   /* IN - num:            the number to be formatted
			   decimalNum:     the number of decimals after the digit
			   bolLeadingZero: true / false to use leading zero
			   bolParens:      true / false to use parenthesis for - num
	
		  RETVAL - formatted number
	   */
	   {
		   var tmpNum = num;
	
		   // Return the right number of decimal places
		   tmpNum *= Math.pow(10,decimalNum);
		   tmpNum = Math.floor(tmpNum);
		   tmpNum /= Math.pow(10,decimalNum);
	
		   var tmpStr = new String(tmpNum);
	
		   // See if we need to hack off a leading zero or not
		   if (!bolLeadingZero && num < 1 && num > -1 && num !=0)
			   if (num > 0)
				   tmpStr = tmpStr.substring(1,tmpStr.length);
			   else
				   // Take out the minus sign out (start at 2)
				   tmpStr = "-" + tmpStr.substring(2,tmpStr.length);                        
	
	
		   // See if we need to put parenthesis around the number
		   if (bolParens && num < 0)
			   tmpStr = "(" + tmpStr.substring(1,tmpStr.length) + ")";
	
	
		   return tmpStr;
	   }
		

  	//Default Routines loaded for each page
	//LoadNoRightMouse();
	NoPageHistory();
	
    function maxWindow()
        {
	        window.moveTo(0,0);
	        if (document.all)
	        {
		        top.window.resizeTo(screen.availWidth,screen.availHeight);
	        }
	        else if (document.layers||document.getElementById)
	        {
		        if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)
		        {
			        top.window.outerHeight = screen.availHeight;
			        top.window.outerWidth = screen.availWidth;
		        }
	        }
        }	
        
    function setPointer() 
        {
            if (parent.parent.parent.parent.document.all)
                {
                    for (var i=0;i < parent.parent.parent.parent.document.all.length; i++)
                        parent.parent.parent.parent.document.all(i).style.cursor = 'wait';
                }
            if (parent.parent.parent.document.all)
                {
                    for (var i=0;i < parent.parent.parent.document.all.length; i++)
                        parent.parent.parent.document.all(i).style.cursor = 'wait';
                }
            if (parent.document.all)
                {
                    for (var i=0;i < parent.document.all.length; i++)
                        parent.document.all(i).style.cursor = 'wait';
                }
            if (document.all)
                {
                    for (var i=0;i < document.all.length; i++)
                        document.all(i).style.cursor = 'wait';
                }                            
        }

    function resetPointer() 
        {
            if (parent.parent.parent.parent.document.all)
                {
                    for (var i=0;i < parent.parent.parent.parent.document.all.length; i++)
                       parent.parent.parent.parent.document.all(i).style.cursor = 'default';
                }
            if (parent.parent.parent.document.all)
                {
                    for (var i=0;i < parent.parent.parent.document.all.length; i++)
                        parent.parent.parent.document.all(i).style.cursor = 'default';
                }
            if (parent.document.all)
                {
                    for (var i=0;i < parent.document.all.length; i++)
                        parent.document.all(i).style.cursor = 'default';
                }
            if (document.all)
                {
                    for (var i=0;i < document.all.length; i++)
                        document.all(i).style.cursor = 'default';
                }                            
        }        

    function TimeDelay(MilliSeconds) 
        {
            var now = new Date();
            var exitTime = now.getTime() + MilliSeconds;
            while (true) 
                {
                    now = new Date();
                    if (now.getTime() > exitTime)
                    return;
                }
        }

    function GetBrowserWidth()
        {
            var width=null;
            try
                {width=innerWidth;}
            catch(e1)
                {
                    try
                        {width=document.documentElement.offsetWidth;}
                    catch(e2)
                        {
                            try
                                {width=document.documentElement.clientWidth;}
                            catch(e2)
                                {
                                    try
                                        {width=document.body.clientWidth;}
                                    catch(e2)
                                        {}
                                }
                        }
                }
            return width;
        }
        
    function GetBrowserHeight()
        {
            var height=null;
            try
                {height=innerHeight;}
            catch(e1)
                {
                    try
                        {height=document.documentElement.offsetHeight;}
                    catch(e2)
                        {
                            try
                                {height=document.documentElement.clientHeight;}
                            catch(e2)
                                {
                                    try
                                        {height=document.body.clientHeight;}
                                    catch(e2)
                                        {}
                                } 
                        }        
                }
            return height;
        }
    
    function StringTrimAll(sString){while (sString.substring(0,1) == ' '){sString = sString.substring(1, sString.length);}while (sString.substring(sString.length-1, sString.length) == ' '){sString = sString.substring(0,sString.length-1);} return sString;}
		     
	function WriteReportFooter(bPageBreak,sName,sYear)
		{
			document.write ("<table style='width:100%;height:40;'>")
			document.write ("<tr style='height:5px'>")
			document.write ("<td class='TableRow'>&nbsp;<td>")
			document.write ("</tr>");
			document.write ("<tr style='height:10px;text-align:right;'>")
			document.write ("<td class='DisplayTextRight'>Report Produced for " + sName + "<td>")
			document.write ("</tr>");
			document.write ("<tr style='height:10px;text-align:right;'>")
			document.write ("<td class='TableRowSmall'>By Capital Transport Group &copy; " + sYear + "<td>")
			document.write ("</tr></table>");
            if (bPageBreak == 1) 
			    {document.write ("<p style='page-break-after:always'>&nbsp;</p>");}			
		}
    
    function GoogleAnalyticsPart1()
        {
            var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
            document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
        }
    
    function GoogleAnalyticsPart2()
        {
            var pageTracker = _gat._getTracker("UA-2090923-4");
            pageTracker._initData();
            pageTracker._trackPageview();
        }
	    
	function getWindowSize()
	    {
	        var e = new Object();
	        if (window.self && self.innerWidth)
	            {
		            e.width = self.innerWidth;
		            e.height = self.innerHeight;
	            }
	        else if(document.documentElement && document.documentElement.clientHeight)
	            {
		            e.width = document.documentElement.clientWidth;
		            e.height = document.documentElement.clientHeight;
	            }
	        else
	            {
		            e.width = document.body.clientWidth;
		            e.height = document.body.clientHeight;
	            }
	        return e
        }
    
    function iecompattest(){return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body}

    function getposOffset(what, offsettype)
        {
            var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
            var parentEl=what.offsetParent;
            while (parentEl!=null)
                {
                    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
                    parentEl=parentEl.offsetParent;
                }
            return totaloffset;
        }

    function showhide(obj, e, visible, hidden, menuwidth)
        {
            if (ie4||ns6)
                dropmenuobj.style.left=dropmenuobj.style.top="-500px"
            if (menuwidth!="")
                {
                    dropmenuobj.widthobj=dropmenuobj.style
                    dropmenuobj.widthobj.width=menuwidth
                }
            if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
            obj.visibility=visible
            else if (e.type=="click")
            obj.visibility=hidden
        }

    function clearbrowseredge(obj, whichedge)
        {
            var edgeoffset=0
            if (whichedge=="rightedge")
                {
                    var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
                    dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
                    if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
                    edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
                }
            else
                {
                    var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
                    var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
                    dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
                    if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
                    edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
                    if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
                    edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
                }
        }
            return edgeoffset
        }

    function populatemenu(what)
        {
            if (ie4||ns6)
            dropmenuobj.innerHTML=what.join("")
        }

    function dropdownmenu(obj, e, menucontents, menuwidth)
        {
            if (window.event) event.cancelBubble=true
            else if (e.stopPropagation) e.stopPropagation()
                clearhidemenu()
                dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
                populatemenu(menucontents)

            if (ie4||ns6)
                {
                    showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
                    dropmenuobj.x=getposOffset(obj, "left")
                    dropmenuobj.y=getposOffset(obj, "top")
                    dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
                    dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
        }

        return clickreturnvalue()
         }

    function clickreturnvalue(){if (ie4||ns6){return false}else{return true}}
    function contains_ns6(a, b){while (b.parentNode)if ((b = b.parentNode) == a){return true;}return false;}

    function dynamichide(e)
        {
            if (ie4&&!dropmenuobj.contains(e.toElement))
                delayhidemenu()
            else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
                delayhidemenu()
        }

    function hidemenu(e)
        {
            if (typeof dropmenuobj!="undefined")
                {
                    if (ie4||ns6)
                    dropmenuobj.style.visibility="hidden"
                }
        }

    function delayhidemenu(){if (ie4||ns6)delayhide=setTimeout("hidemenu()",disappeardelay)}
    function clearhidemenu(){if (typeof delayhide!="undefined")clearTimeout(delayhide)}
    function setCookie(c_name,value,expiredays){var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());}
        
    function getCookie(c_name)
        {
            if (document.cookie.length>0)
                {
                    c_start=document.cookie.indexOf(c_name + "=");
                    if (c_start!=-1)
                        { 
                            c_start=c_start + c_name.length+1; 
                            c_end=document.cookie.indexOf(";",c_start);
                            if (c_end==-1) c_end=document.cookie.length;
                            return unescape(document.cookie.substring(c_start,c_end));
                        } 
                }
            return "";
        } 
        
        
    function zeroPad(num,count)
        { 
            var numZeropad = num + '';
            while(numZeropad.length < count) 
                {
                    numZeropad = "0" + numZeropad; 
                }
            return numZeropad;
        }

    GetElement=function(ObjectID){ return document.getElementById(ObjectID);}      
    var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
    function LZ(x){return(x<0||x>9?"":"0")+x}
    function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;}
    function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0 || d2==0){return -1;}else if(d1 > d2){return 1;}return 0;}
    function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length < 4){y=""+(y-0+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];value["NNN"]=MONTH_NAMES[M+11];value["d"]=d;value["dd"]=LZ(d);value["E"]=DAY_NAMES[E+7];value["EE"]=DAY_NAMES[E];value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;}else{value["K"]=H;}value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H > 11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(value[token] != null){result=result + value[token];}else{result=result + token;}}return result;}
    function _isInteger(val){var digits="1234567890";for(var i=0;i < val.length;i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}return true;}
    function _getInt(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length < minlength){return null;}if(_isInteger(token)){return token;}}return null;}
    function getDateFromFormat(val,format){val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=1;var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm="";while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(token=="yyyy" || token=="yy" || token=="y"){if(token=="yyyy"){x=4;y=4;}if(token=="yy"){x=2;y=2;}if(token=="y"){x=2;y=4;}year=_getInt(val,i_val,x,y);if(year==null){return 0;}i_val += year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM"||token=="NNN"){month=0;for(var i=0;i<MONTH_NAMES.length;i++){var month_name=MONTH_NAMES[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){if(token=="MMM"||(token=="NNN"&&i>11)){month=i+1;if(month>12){month -= 12;}i_val += month_name.length;break;}}}if((month < 1)||(month>12)){return 0;}}else if(token=="EE"||token=="E"){for(var i=0;i<DAY_NAMES.length;i++){var day_name=DAY_NAMES[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=="MM"||token=="M"){month=_getInt(val,i_val,token.length,2);if(month==null||(month<1)||(month>12)){return 0;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return 0;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}i_val+=hh.length;}else if(token=="kk"||token=="k"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=_getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return 0;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return 0;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}else{i_val+=token.length;}}}if(i_val != val.length){return 0;}if(month==2){if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) ){if(date > 29){return 0;}}else{if(date > 28){return 0;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date > 30){return 0;}}if(hh<12 && ampm=="PM"){hh=hh-0+12;}else if(hh>11 && ampm=="AM"){hh-=12;}var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}
    function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');var d=null;for(var i=0;i<checkList.length;i++){var l=window[checkList[i]];for(var j=0;j<l.length;j++){d=getDateFromFormat(val,l[j]);if(d!=0){return new Date(d);}}}return null;}
