
function gup(name) { 
  // Diego 8/25/2009 
  // This function returns the value of any html parameter passed based on the name used. 
  // Example index.html?param1=1&param2=abc   
  // Executing gup('param2') returns abc. 
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function GetIframeSrc() {
   // Return the html source document based on the url params passed. 
   // Diego 8/25/2009 
   var urlsrc = gup( 'src' );
   var ishdwr = '';
   
   if  (urlsrc.length == 0)   {   
      ishdwr = gup( 'hdwr' );
   }
    
   // Determine Day of the Week for Finance banner 
   // DOT 3/15/2010. Loads different iframe page based on day of week (Fri, Sat, Sun vs others)
   var dteNow = new Date();
   var dteToday = dteNow.getDay();
   var retPage = 'welcome_insert4.htm'; 
    
   if (urlsrc.length > 0) 
      { return urlsrc; }
   else if (ishdwr == '1')
      { return 'hdwr.html'; }
   else
    {  
		  switch(dteToday)
		  {
			   case 0: case 5: case 6:
				 // DOT:3/25/2010 Process did not start yet, uncomment when ready. 
				 //retPage = 'welcome_insert4_FINANCE.htm'
				 //$('#financebanner').hide();
				 break; 
			   default: 
				 $('#financebanner').show();
		  }
	} 	 

     return retPage; 
}

function iFrameHeight() { 
	return  window.frames[document.getElementById('mainbox').name].document.height; 

}

function changeContent() {
	var ocontent = document.getElementById('CFContent');
	var oiframe = document.getElementById('mainbox');
	ocontent.innerHTML = window.frames['mainbox'].document.getElementsByTagName('html')[0].innerHTML;
}

function aodLink()
{
     var  aodhref =  'http://mainaod2/kiosk/kiosk/kiosk_not_logged_in.jsp';
     var isaod = gup('aod'); 
	 
	if (isaod)
      {
	      var $aod = $('#aodlnk');
		  $aod.attr('href', aodhref);
	      $aod.removeAttr('target');
	  	// idleTimer() takes an optional argument that defines the idle timeout
		// timeout is in milliseconds; defaults to 30000
		$.idleTimer(60000);   // 1 min idle timeout
	 
		$(document).bind("idle.idleTimer", function(){
				window.location = aodhref;
		 });
  
	  }
}

 $(document).ready(function() {
    // Get HTML Source for iFrame based on URL Parameters passed.   class="autoHeight"
   $('#mainbox').attr('src', GetIframeSrc());
    aodLink(); 
		
 });
