/*
 * Class: Form
 * Description: Used to manage interaction with a form.
 */
function Form(){}

/*
 * Submit a for using the ID
 */
Form.submit = function(a_formId)
{
	document.getElementById(a_formId).submit();
}

/********************************************************
 * ORIGINAL CRITICAL MASS METHODS
 ********************************************************/

function getElementsByClassName(className,tagNames,oParent) {
  // grab elements by class, restricting search to certain tags or a parent element
  var doc = (oParent||document);
  var matches = [];
  var i,j;
  var nodes = [];
  if (tagNames && typeof(tagNames)!='string' && typeof(tagNames)!='undefined') {
    for (i=0; i<tagNames.length; i++) {
      if (!nodes || !nodes[tagNames[i]]) {
        nodes[tagNames[i]] = doc.getElementsByTagName(tagNames[i]);
      }
    }
  } else if (tagNames) {
    nodes = doc.getElementsByTagName(tagNames);
  } else {
    nodes = doc.all||doc.getElementsByTagName('*');
  }
  if (typeof(tagNames)!='string' && typeof(tagNames)!='undefined') {
    for (i=0; i<tagNames.length; i++) {
      for (j=0; j<nodes[tagNames[i]].length; j++) {
        if (nodes[tagNames[i]][j].className && nodes[tagNames[i]][j].className.indexOf(className)+1 && (nodes[tagNames[i]][j].className == className || nodes[tagNames[i]][j].className.indexOf(className+' ')+1 || nodes[tagNames[i]][j].className.indexOf(' '+className)+1)) {
          matches[matches.length] = nodes[tagNames[i]][j];
        }
      }
    }
  } else {
    for (i=0; i<nodes.length; i++) {
      if (nodes[i].className && nodes[i].className.indexOf(className)+1 && (nodes[i].className == className || nodes[i].className.indexOf(className+' ')+1 || nodes[i].className.indexOf(' '+className)+1)) {
        matches[matches.length] = nodes[i];
      }
    }
  }
  return matches; // kids, don't play with fire. ;)
}

function BrowserDetect() {
  // Browser Detect
  var ua = navigator.userAgent.toLowerCase();

  // browser engine name
  this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
  this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

  // browser name
  this.isKonqueror   = (ua.indexOf('konqueror') != -1);
  this.isSafari      = (ua.indexOf('safari') != - 1);
  this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
  this.isOpera       = (ua.indexOf('opera') != -1);
  this.isIcab        = (ua.indexOf('icab') != -1);
  this.isAol         = (ua.indexOf('aol') != -1);
  this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) );
  this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
  this.isFirebird    = (ua.indexOf('firebird/') != -1);
  this.isFirefox     = (ua.indexOf('firefox/') != -1); // scotts
  this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );

  // spoofing and compatible browsers
  this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
  this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);

  // rendering engine versions
  this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
  this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
  this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );

  // browser version
  this.versionMinor = parseFloat(navigator.appVersion);

  // correct version number
  if (this.isGecko && !this.isMozilla) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
  } else if (this.isMozilla) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
  } else if (this.isIE && this.versionMinor >= 4) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
  } else if (this.isKonqueror) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
  } else if (this.isSafari) {
    this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
  } else if (this.isOmniweb) {
    this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
  } else if (this.isOpera) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
  } else if (this.isIcab) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
  }

  this.versionMajor = parseInt(this.versionMinor);
  // dom support
  this.isDOM1 = (document.getElementById);
  this.isDOM2Event = (document.addEventListener && document.removeEventListener);

  // css compatibility mode
  this.mode = document.compatMode ? document.compatMode : 'BackCompat';

  // platform
  this.isWin    = (ua.indexOf('win') != -1);
  this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
  this.isMac    = (ua.indexOf('mac') != -1);
  this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
  this.isLinux  = (ua.indexOf('linux') != -1);

  // specific browser shortcuts
  this.isNS4x = (this.isNS && this.versionMajor == 4);
  this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
  this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
  this.isNS4up = (this.isNS && this.versionMinor >= 4);
  this.isNS6x = (this.isNS && this.versionMajor == 6);
  this.isNS6up = (this.isNS && this.versionMajor >= 6);
  this.isNS7x = (this.isNS && this.versionMajor == 7);
  this.isNS7up = (this.isNS && this.versionMajor >= 7);

  this.isIE4x = (this.isIE && this.versionMajor == 4);
  this.isIE4up = (this.isIE && this.versionMajor >= 4);
  this.isIE5x = (this.isIE && this.versionMajor == 5);
  this.isIE55 = (this.isIE && this.versionMinor == 5.5);
  this.isIE5up = (this.isIE && this.versionMajor >= 5);
  this.isIE6x = (this.isIE && this.versionMajor == 6);
  this.isIE6up = (this.isIE && this.versionMajor >= 6);
  this.isIE4xMac = (this.isIE4x && this.isMac);
}

var ua = new BrowserDetect();

function setCookie(name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + value +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function getCookie(name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
      endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function deleteCookie(name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 07:06:00 GMT";
  }
}

function pop(url,width,height,params) {
  var newWin = window.open(url,"newwin","width="+width+",height="+height+","+params);
}

function TextControl() {
  this.size = null;
  this.scaleValues = ['0.76em','0.9em','1.1em'];
  this.scaleDefault = this.scaleValues[0];
  this.cookieName = 'textsize'; // cookie name reference
  this.cookieExpire = new Date(new Date().getTime()+(365*24*60*60*1000)); // 1 year

  this.init = function() {
    // assign default size, if cookied
    if (!isNaN(parseInt(getCookie(this.cookieName)))) this.setTextSize(getCookie(this.cookieName),true);
  }

  this.setTextSize = function(sizeIndex,avoidCookie) {
    if (document.body) document.body.style.fontSize = (typeof(sizeIndex)!='undefined' && sizeIndex<this.scaleValues.length)?this.scaleValues[sizeIndex]:this.scaleDefault;
    if (!avoidCookie) setCookie(this.cookieName,sizeIndex,this.cookieExpire,'/','criticalmass.com',null);
    return false;
  }

}

var textControl = new TextControl();

function NewsFilter(){

    this.divs = document.getElementsByTagName("DIV");
    this.index = 0;
    this.items = [];
    this.years = document.getElementById('year-filter').getElementsByTagName('a');

    for (i=0;i<this.divs.length;i++) {
        if(this.divs[i].className && this.divs[i].className=="news-by-year") {
            this.items[this.items.length] = this.divs[i];
        }
    }

    this.applyFilter = function(index) {
        var scroll = true;
        if (index=='init') {
            scroll = false;
            index = 0;
        }
        if (this.items[this.index]) {
          this.items[this.index].style.display = 'none';
        }
        if (this.items[index]) {
          this.items[index].style.display='block';
        }
        if (this.years[this.index+1]) {
          this.years[this.index+1].className = '';
        }
        this.index = index;
        if (this.years[this.index+1]) {
          this.years[this.index+1].className = 'active';
        }
        if (scroll) {
          //window.location.href = '#news';
        }
        return false;
    }

}


function vidObject(mediaType,size,filename,path) {
    this.mediaType=mediaType;
    this.size=size;
    this.filename=filename;
    this.path="../../../../../.."+path; // may need to be absolute?
    this.objectTag="";
    this.init = function(){
      switch(this.mediaType) {
          case('wmv'):
           this.objectTag+='<object id="wmplayer" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'+this.size+'" height="320">\n';
           this.objectTag+=' <param name="uiMode" value="full" />\n';
           this.objectTag+=' <param name="autoStart" value="true" />\n';
           this.objectTag+=' <param name="URL" value="'+this.path+this.filename+'_'+this.size+'.'+this.mediaType+'" />\n'
           this.objectTag+=' <param name="bgcolor" value="#F0ECE7" />\n';
           this.objectTag+=' <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" width="'+this.size+'" height="320" src="'+this.path+this.filename+'_'+this.size+'.'+this.mediaType+'" filename="'+this.path+this.filename+'_'+this.size+'.'+this.mediaType+'" bgcolor="#F0ECE7" autostart="True" showcontrols="True" showstatusbar="True" showdisplay="True" autorewind="True">\n';
           // this.objectTag+=' <div style="font-size:x-small">Your browser does not support the ActiveX Windows Media Player.<br /><div style="text-align:left">&lt;<a href="javascript:window.history.go(-1)">go back</a></div></div>\n';
           this.objectTag+=' </embed>';
           this.objectTag+='</object>';
          break;
          case('mov'):
          this.objectTag+='<object classid="clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b" width="'+this.size+'" height="320" codebase="http://www.apple.com/qtactivex/qtplugin.cab">\n';
          this.objectTag+='<param name="src" value="'+this.path+this.filename+'_'+this.size+'.'+this.mediaType+'">\n';
          this.objectTag+='<param name="autoplay" value="true">\n';
          this.objectTag+='<param name="controller" value="true">\n';
          this.objectTag+='<param name="bgcolor" value="#F0ECE7">\n';
          this.objectTag+='<embed src="'+this.path+this.filename+'_'+this.size+'.'+this.mediaType+'" width="'+this.size+'" height="320" autoplay="true" bgcolor="#F0ECE7" controller="true" pluginspage="http://www.apple.com/quicktime/download/"></embed>\n';
          this.objectTag+='</object>';
          break;
        }
    }

    this.renderObject = function() {
        return(this.objectTag);
    }
}

function checkTextLength(elementName) {
	/*  Function to alert the user that they have reached 
		the maximum number of characters(1000) allowed in 
		the textarea. Can't figure out how to enforce the 1000
		character limit without disabling the textbox (which 
		wouldn't allow the user to remove the extra chacters)
		Any ideas or assistance would be greatly appreciated
	*/
	if ( elementName.value.length > 1000 )
		alert('Sorry, you have reached the 1000 character limit of this textbox. Please adjust your comments accordingly.');
}

function createNumTravelerInput(val) 
{
/* Function to dynamically generate number of travelers
   fields in the Your Wish Fulfilled - Travel form.
*/
	for (i=0;i<=5;i++) 
	{
		var inputName = "preferences.nameOfTraveler[" + i + "]";
		var obj = document.getElementById(i);
		if(obj.style.display == 'block')
		{
			if(i>val-1)
			{	
  				obj.style.display = 'none';
				obj.disabled = true;
			} 
  		}
  		else
  		{
  			if (i <= val-1)
  			{
  				obj.style.display = 'block';
				obj.disabled = false;
			}
		}
	}
}
	
function createInput(val) {
/* Function to dynamically generate number of travelers
   fields in the Your Wish Fulfilled - Travel form.

*/

		for (i=0;i<=5;i++) {
			var inputName = "childBY" + i;
			var obj = document.getElementById(i);
			if(obj.style.display == 'block')
			{		
				if(i>val-1){	
					document.getElementById(i).style.display = 'none';
					document.getElementById(inputName).disabled = true;
				} 
  
			}else{
				if (i <= val-1){
					document.getElementById(i).style.display = 'block';
					document.getElementById(inputName).disabled = false;
				}
			}
		
		}
		
	
	}

/*Dynamic homepage popup functions*/		
function showObj() {   
	var obj = document.getElementById('siteIntro');
	var objw = document.getElementById('siteIntroWrapper');
	if(getCookie('citiintro')!= null)
	{ 
		checkFirst();
	}else{
		
		obj.style.display='block';
		objw.style.display='block';
		setCookie('citiintro',1);
		setTimeout('closeObj()', 15000);                
	}
}

function checkFirst(){
	if(getCookie('citiintro') != 1)
	{
		obj.style.display='block';
		objw.style.display='block';
		setCookie('citiintro',1);
		setTimeout('closeObj()', 15000); 
	}
}

function closeObj() {
	var obj = document.getElementById('siteIntro');
	var objw = document.getElementById('siteIntroWrapper');
	obj.style.display='none';
	objw.style.display='none';
}

/*end dynamic popup functions*/


/*Cancel order confirmation*/
 
function cancelConfirm() {
	var val = window.confirm("Are you sure you would like to cancel this order?");
	if(val == true)
	{
		//code to call form submit script goes here
	}else{
		return;
	}
}

/*Dynamic table row build functions for Profile Travel page - AGF*/
	function addAccount(frm){
		var val = frm.accountName.selectedIndex;
		var tx = new String(frm.ffNum.value);
		
		if(val != 0 || tx==" "){
			var theTable = document.getElementById('ffTable');
			var rw = theTable.insertRow(1);
			var cl = rw.insertCell(-1);
			var cl0 = rw.insertCell(0);
			var cl1 = rw.insertCell(1);
				rw.id = 'r'+frm.accountName.options[val].value;
				cl.innerHTML =  '<input type="Checkbox" name="inputInfo" id="'+frm.accountName.options[val].value+'">';
				cl0.innerHTML =  '<a href="javascript:void(0);" onclick="populateFields('+val+','+frm.ffNum.value+')">'+frm.accountName.options[val].innerHTML+'</a>'; //pass selected index select app. option
				cl1.innerHTML = '<a href="javascript:void(0);" onclick="populateFields('+val+','+frm.ffNum.value+')">'+frm.ffNum.value+'</a>';  //innerhtml to value of input
				
		}else{
			alert('Please Select a valid Flyer Program/Number');
		}	
	}
	
	function deleteRow(frm){
			var theTable = document.getElementById('ffTable');
			
			for(i=0;i<frm.elements.length;i++)
			{
					if(frm.elements[i].checked)
					{
						var nm = frm.elements[i].id
						var rn = document.getElementById('r'+nm);
						theTable.deleteRow(rn.rowIndex);
						deleteRow(frm);
					}
					
			}
		}	
		
	function populateFields(sel,txt){
		var frm = document.getElementById('flightForm');
		
		frm.accountName.selectedIndex = sel;
		frm.ffNum.value = txt;
	}	
	
	var oldTogglehd = "";
	var oldToggle = "";
	/*Toggles CitiBusiness Card list*/
	 function toggleList(head,info, drawFrame){
	 	var objhd = document.getElementById(head);
	 	var obj = document.getElementById(info);
		var disp = obj.style.display;
		var tmpStr = "";
	 	
		if(disp != 'block')
		{
			if (oldToggle) {
				oldToggle.style.display = 'none';
				tmpStr = oldTogglehd.className;
				tmpStr = tmpStr.replace(/cardOff/,"cardOn");
				oldTogglehd.className = tmpStr;
				if(drawFrame) {
					overlapFrame(obj, true);
				}
			}
			obj.style.display = 'block';
			tmpStr = objhd.className;
			tmpStr = tmpStr.replace(/(cardOn)/,"cardOff");
			objhd.className = tmpStr;
			if(drawFrame) {
				overlapFrame(obj, false);
			}
			oldToggle = obj;
			oldTogglehd = objhd;
		}else{
			obj.style.display = 'none';
			tmpStr = objhd.className;
			tmpStr = tmpStr.replace(/cardOff/,"cardOn");
			objhd.className = tmpStr;
			if(drawFrame) {
				overlapFrame(obj, true);
			}
		}
	 }
	 
	 function overlapFrame(divObj, hide)
	 {
		 var iframeObj = document.getElementById("hoverFrame");
	 	if(hide) {
	 		iframeObj.style.display = 'none';
	 	}
	 	else {
	 		iframeObj.style.left = divObj.style.left;
	 		iframeObj.style.top = divObj.style.top;
	 		iframeObj.style.width = divObj.offsetWidth + "px";
	 		iframeObj.style.height = divObj.offsetHeight + "px";
	 		iframeObj.style.display = 'block';
	 	}
	 }
	 
	 
function FlashLibrary(){
	var t = this;
	var activeX = false;
	t.ieAutoInstall = true;
	t.hasVersion = function(ver){
		t.swf = false;
		if(!ver) ver = 0;
		var n = navigator;
		if(n.plugins && n.plugins.length > 0){
			var m,tp,d,v;
			m = n.mimeTypes;
			tp = 'application/x-shockwave-flash';
			if(m && m[tp] && m[tp].enabledPlugin && m[tp].enabledPlugin.description){
				d = m[tp].enabledPlugin.description;
				v = d.charAt(d.indexOf('.')-1);
				t.swf = (v >= ver) ? true : false;
			}
			
		}else if(n.appVersion.indexOf("Mac") == -1 && window.execScript){
			for(var i=ver; i<=8&&i!=1&&t.swf!=true; i++){
				execScript('on error resume next: flash.swf=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash'+((i==0)?'':'.'+i)+'"))','VBScript');
			}
			activeX = true;
		}else{
			t.swf = false;
		}
		return t.swf;
	}
	t.getPluginTag = function(swfFile,width,height,bgcolor,ver,params,vars,obj){
		var s = '';
		var win = (navigator.appVersion.toLowerCase().indexOf("win")!=-1);
		var ie = (navigator.appName=="Microsoft Internet Explorer");
		if(t.hasVersion(ver) && swfFile || win && ie && swfFile && t.ieAutoInstall){
			var additionalParams = '';
			if(params && params.length>0){
				var pArray = params.split(",");
				for(var i=0; i<pArray.length; i++){
					var ta = pArray[i].substr(0,pArray[i].indexOf('='));
					var v = pArray[i].substr(pArray[i].indexOf('=')+1,pArray[i].length);
					additionalParams += (activeX)?'\t<param name="' + ta + '" value="' + v + '" />\n': ' '+ ta + '="' + v + '"';
				}
			}
			if(activeX){
				s = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" align="top">\n';
				s += '\t<param name="movie" value="'+swfFile+'" />\n';
				s += '\t<param name="quality" value="high" />\n';
				s += '\t<param name="menu" value="0" />\n';
				s += '<param name="flashvars" value="'+vars+'" />\n';
				s += '</object>\n\n';
				document.getElementById(obj).innerHTML = s;
			}else{
				s = '<embed src="'+swfFile+'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'"></embed>\n';
				return s;
			}
        }
	}
}
var flash = new FlashLibrary();

	 
function objFix(obj){
	
if(navigator.appName.indexOf('Microsoft Internet Explorer')>-1)
{
		var objectTags = [];
		var nameObj = [];
		objectTags = document.getElementsByTagName("OBJECT");
	    var noFlashMarkup = '';
		var f = flash.hasVersion(8);
		if(f)
		{
			for (var i=0; i<objectTags.length; i++)
			 {
			 	objectTags[i].style.display='none';
		     }
			var paramTags = [];
			paramTags = document.getElementsByTagName("PARAM");
			for (var i=0; i<paramTags.length; i++)
			{
				if (paramTags[i].name=='flashvars')
				{
					var fvars = (paramTags[i].value);
				} 
				if (paramTags[i].name=='movie')
				{
					var swname = paramTags[i].value;
				}
			}
			if(arguments.length > 1)
			{
				for (var i=0; i<objectTags.length; i++)
				{
					var flashMarkup = flash.getPluginTag(objectTags[i].childNodes[0].value, objectTags[i].width, objectTags[i].height, '#ffffff','salign=T',8,fvars,arguments[i]);
			    }
			 }else{
			 		var flashMarkup = flash.getPluginTag(swname, objectTags[0].width, objectTags[0].height, '#ffffff','salign=T',8,fvars,obj);
			 }
					
			}
		}
	}

					
							
//this object is for the overlay and the functions within either show or hide the overlay
//The arguements also have the coords of the calling link, and the offset needed to position the
//overlay where desired.

	var overLay = 
	{
		overlay : 'overlay-wrap',
		overlayControl : 'overlay-close',
		overlayVisible : 'visible',
		overlayHidden : 'hidden',
		showOverlay : function() 
		{	var theAction = arguments[0];
			var callingLink = arguments[1];
			var alterLeft = arguments[2] || 0;
			var alterTop = arguments [3] || 0;
			var theOverlay = document.getElementById(overLay.overlay);


			if (theOverlay)
			{
			 switch(theAction)
			 { 
			 	case "hidden":
			 		theOverlay.className = "hidden";
					break;
			 	default :
			 		theOverlay.className = "visible";
					var coords = this.cumulativeOffset(callingLink);
					theOverlay.style.left= parseInt(coords[0]+alterLeft)+"px";
					theOverlay.style.top= parseInt(coords[1]+alterTop)+"px";
			 }
			}else{
			return false;
			}
		},
		init : function()
		{	
			var theControl = document.getElementById(this.overlayControl);
			if (theControl)
			{
				theControl.onclick = function(){overLay.showOverlay('hidden');return false;};
			}
			this.showOverlay();
		},
		cumulativeOffset: function(element) 
		{
		    var valueT = 0, valueL = 0;
		    do {
		      valueT += element.offsetTop  || 0;
		      valueL += element.offsetLeft || 0;
		      element = element.offsetParent;
		    } while (element);
		    return [valueL, valueT];
       }
	}
	
//SIMILAR TO THE ONE ABOVE BUT FOR THE TRAVEL SECTION ONLY
	var travelOverLay = 
	{
		overlay : 'overlay-wrap',
		overlayControl : 'overlay-close',
		overlayVisible : 'travel-visible',
		overlayHidden : 'travel-hidden',
		showOverlay : function() {	
			var theAction = arguments[0];
			var theOverlay = document.getElementById(arguments [1]) || document.getElementById(travelOverLay.overlay);
			var alterLeft = arguments[2] || 0;
			var alterTop = arguments [3] || 0;
			var callingLink = arguments[4];
			
			if (theOverlay){
			 	switch(theAction){ 
			 	case "travel-hidden":
			 		theOverlay.className = "travel-hidden";
					break;
			 	default :
			 		theOverlay.className = "travel-visible";
					var coords = this.cumulativeOffset(callingLink);
					theOverlay.style.left= parseInt(coords[0]+alterLeft)+"px";
					theOverlay.style.top= parseInt(coords[1]+alterTop)+"px";
			 	}
			}else{
				return false;
			}
		},
		init : function()
		{	
			var theControl = document.getElementById(this.overlayControl);
			if (theControl)
			{
				theControl.onclick = function(){travelOverLay.showOverlay('travel-hidden');return false;};
			}
			this.showOverlay();
		},
		cumulativeOffset: function(element) 
		{
		    var valueT = 0, valueL = 0;
		    do {
		      valueT += element.offsetTop  || 0;
		      valueL += element.offsetLeft || 0;
		      element = element.offsetParent;
		    } while (element);
		    return [valueL, valueT];
       }
	}
	
	//SIMILAR TO THE ONE ABOVE BUT FOR THE EXPEDIA SECTION ONLY
	var expediaOverLay = 
	{
		overlay : 'overlay-wrap',
		overlayControl : 'overlay-close',
		overlayVisible : 'module-visible',
		overlayHidden : 'module-hidden',
		showOverlay : function() {	
			var theAction = arguments[0];
			var theOverlay = document.getElementById(arguments [1]) || document.getElementById(moduleOverLay.overlay);
			var alterLeft = arguments[2] || 0;
			var alterTop = arguments [3] || 0;
			var callingLink = arguments[4];
			
			if (theOverlay){
			 	switch(theAction){ 
			 	case "module-hidden":
			 		theOverlay.className = "module-hidden";
					break;
			 	default :
			 		theOverlay.className = "module-visible";
					var coords = this.cumulativeOffset(callingLink);
					theOverlay.style.left= parseInt(coords[0]+alterLeft)+"px";
					theOverlay.style.top= parseInt(coords[1]+alterTop)+"px";
			 	}
			}else{
				return false;
			}
		},
		init : function()
		{	
			var theControl = document.getElementById(this.overlayControl);
			if (theControl)
			{
				theControl.onclick = function(){travelOverLay.showOverlay('module-hidden');return false;};
			}
			this.showOverlay();
		},
		cumulativeOffset: function(element) 
		{
		    var valueT = 0, valueL = 0;
		    do {
		      valueT += element.offsetTop  || 0;
		      valueL += element.offsetLeft || 0;
		      element = element.offsetParent;
		    } while (element);
		    return [valueL, valueT];
       }
	}	

function randomImage(){
    var xx = Math.random(); 
	var rnumber = Math.round(xx*2); 
	picArray = new Array("picture2.jpg","picture3.jpg","picture4.jpg");
	document.getElementById("earnModule").src = "../../images/index/"+picArray[rnumber];
}  

function CreateBookmarkLink() { 
	title = document.title;   
 	url = location.href;  
	//alert("the URL is "+url+"and the title is "+title);
	if (window.sidebar) { // Mozilla Firefox Bookmark		
		window.sidebar.addPanel(title, url,"");	
	} else if( window.external ) { // IE Favorite		
		window.external.AddFavorite( url, title); 
	} else if(window.opera && window.print) { // Opera Hotlist		
		var mbm = document.createElement('a');
   		mbm.setAttribute('rel','sidebar');
    	mbm.setAttribute('href',url);
    	mbm.setAttribute('title',title);
    	mbm.click();
		return true; 
	} else { 
      alert('Please bookmark this page manually. Your browser does not support this script.');    
	}
}
		
						