var chart_width = (document.documentElement.clientWidth - 100);
var chart_height = (document.documentElement.clientHeight - 94);

function getElementsByClass (searchClass) {
  // This function returns an array of all HTML objects with the
  // specified className.  Tag is optional   
  var returnArray = [];
  var els = document.getElementsByTagName('*');
  var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
  for (var i = 0; i < els.length; i++) {
    if ( pattern.test(els[i].className) ) { returnArray.push(els[i]); }
  }
  return returnArray;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curtop,curleft];
}

/* Cross-browser function for getting the vertical scroll position */
function getScrollTop(){
    if(typeof pageYOffset!= 'undefined'){
        //most browsers
        return pageYOffset;
    }
    else{
        var B= document.body; //IE 'quirks'
        var D= document.documentElement; //IE with doctype
        D= (D.clientHeight)? D: B;
        return D.scrollTop;
    }
}

function popVideo(vid, darken) {
  // This function accepts a division ID (vid), either a string or the actual
  // object itself.   vid is mandatory.   darken is optional, if it's true
  // the page will be greyed out under the video.
  var videos = getElementsByClass('video');     // Get all the videos on the page.
  var isplaying=null;
  for(i=0; i<videos.length; i++) {              // Loop through all the videos
    if (videos[i].style.display=='block') {     // This video is playing 
      isplaying=videos[i].id;                   // remember its name
      var tmp=videos[i].innerHTML;              // Get the division contents
      videos[i].innerHTML='';                   // destroy the contents
      videos[i].style.display='none';           // Terminate the video.
      videos[i].innerHTML=tmp;                  // rebuild the contents.
    }
  }
  
  	if (vid == 'close') {
		var divEmbedPShareVideo = document.getElementById('divEmbedPShareVideo');
		if (divEmbedPShareVideo)
			divEmbedPShareVideo.innerHTML = '';
			
		var divEmbedVideo_InvoicesPromo = document.getElementById('divEmbedVideo_InvoicesPromo');
		if (divEmbedVideo_InvoicesPromo)
			divEmbedVideo_InvoicesPromo.innerHTML = '';
  	}
  
  // This handles the darkening of the background while a video is playing.
  // First we see if the dark layer exists.
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');          // Create the layer.
        tnode.style.backgroundColor='rgb(0, 0, 0)';     // Make it black.
        tnode.style.opacity='0.7';                      // Set the opacity (firefox/Opera)
        tnode.style.MozOpacity='0.70';                  // Firefox 1.5
        tnode.style.filter='alpha(opacity=70)';         // IE.
        tnode.style.zIndex='50';                         // Zindex of 50 so it "floats"
        tnode.style.position='absolute';                // Position absolutely
        tnode.style.top='0px';                          // In the top
        tnode.style.left='0px';                         // Left corner of the page
        tnode.style.overflow='hidden';                  // Try to avoid making scroll bars            
        tnode.style.display='none';                     // Start out Hidden
        tnode.id='darkenScreenObject';                  // Name it so we can find it later
    tbody.appendChild(tnode);                           // Add it to the web page
    dark=document.getElementById('darkenScreenObject'); // Get the object.
  }
  dark.style.display='none';
  if ((isplaying==vid)||(/^close$/i.test(vid))) { return false; }
  if (typeof(vid)=="string") { 
  	if (vid == 'referrals_learnmore_video') {
		divEmbedPShareVideo = document.getElementById('divEmbedPShareVideo');
		divEmbedPShareVideo.innerHTML = '<iframe type="text/html" width="560" height="345" src="http://www.youtube.com/embed/ikeBd_2rivs?autoplay=1" frameborder="0" allowfullscreen></iframe>';
  	} else if (vid == 'divPopupVideo_InvoicesPromo') {
		divEmbedVideo_InvoicesPromo = document.getElementById('divEmbedVideo_InvoicesPromo');
		divEmbedVideo_InvoicesPromo.innerHTML = '<iframe type="text/html" width="560" height="345" src="http://www.youtube.com/embed/vMY4IaHQnJ4?autoplay=1" frameborder="0" allowfullscreen></iframe>';
	}
  	vid=document.getElementById(vid); 
	}
  if (vid&&typeof(vid)=="object") {
    if (darken) {
      // Calculate the page width and height 
      if( window.innerHeight && window.scrollMaxY )  { 
        var pageWidth = window.innerWidth + window.scrollMaxX;
        var pageHeight = window.innerHeight + window.scrollMaxY;
      } else if( document.body.scrollHeight > document.body.offsetHeight ) {
        var pageWidth = document.body.scrollWidth;
        var pageHeight = document.body.scrollHeight;
      } else { 
        var pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
        var pageHeight = document.body.offsetHeight + document.body.offsetTop; 
      }
      //set the shader to cover the entire page and make it visible. 
      dark.style.width= pageWidth+'px';
      dark.style.height= pageHeight+'px';
      dark.style.display='block';                                
    }
    // Make the video visible and set the zindex so its on top of everything else
    vid.style.zIndex='100';    
    vid.style.display='block';
    var scrollTop = getScrollTop(); var clientHeight = 0; var clientWidth = 0;
    if ((document.documentElement != undefined) && (document.documentElement.clientHeight != undefined) && (document.documentElement.clientHeight > 0)) {
		clientHeight = document.documentElement.clientHeight;
		clientWidth = document.documentElement.clientWidth;
	} else if (document.body) {
		clientHeight = document.body.clientHeight;
		clientWidth = document.body.clientWidth;
	}

    // set the starting x and y position of the video
	var top_offset = scrollTop+Math.floor((clientHeight/2)-(vid.offsetHeight/2));
	if (top_offset > 10)
     	vid.style.top = top_offset+'px';
	else
		vid.style.top = '10px';
    vid.style.left=Math.floor((clientWidth/2)-(vid.offsetWidth/2))+'px';
  }
  return false;
}

function popHelp(div, darken, alignTop, alignRight, VOffset, HOffset) {
  // This function accepts a division ID (div), either a string or the actual
  // object itself.   div is mandatory.   darken is optional, if it's true
  // the page will be greyed out under the video.
  var popupforms = getElementsByClass('popuphelp');  // Get all the videos on the page.
  var isdisplayed=null;
  for(i=0; i<popupforms.length; i++) {              // Loop through all the videos
    if (popupforms[i].style.display=='block') {     // This video is playing 
      isdisplayed=popupforms[i].id;                   // remember its name
      var tmp=popupforms[i].innerHTML;              // Get the division contents
      popupforms[i].innerHTML='';                   // destroy the contents
      popupforms[i].style.display='none';           // Terminate the video.
      popupforms[i].innerHTML=tmp;                  // rebuild the contents.
    }
  }
  
  // This handles the darkening of the background while a video is playing.
  // First we see if the dark layer exists.
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');          // Create the layer.
        tnode.style.backgroundColor='rgb(0, 0, 0)';     // Make it black.
        tnode.style.opacity='0.7';                      // Set the opacity (firefox/Opera)
        tnode.style.MozOpacity='0.70';                  // Firefox 1.5
        tnode.style.filter='alpha(opacity=70)';         // IE.
        tnode.style.zIndex='1';                         // Zindex of 50 so it "floats"
        tnode.style.position='absolute';                // Position absolutely
        tnode.style.top='0px';                          // In the top
        tnode.style.left='0px';                         // Left corner of the page
        tnode.style.overflow='hidden';                  // Try to avoid making scroll bars            
        tnode.style.display='none';                     // Start out Hidden
        tnode.id='darkenScreenObject';                  // Name it so we can find it later
    tbody.appendChild(tnode);                           // Add it to the web page
    dark=document.getElementById('darkenScreenObject'); // Get the object.
  }
  dark.style.display='none';
  if ((isdisplayed==div)||(/^close$/i.test(div))) { return false; }
  if (typeof(div)=="string") { div=document.getElementById(div); }
  if (div&&typeof(div)=="object") {
    if (darken) {
      // Calculate the page width and height 
      if( window.innerHeight && window.scrollMaxY )  { 
        var pageWidth = window.innerWidth + window.scrollMaxX;
        var pageHeight = window.innerHeight + window.scrollMaxY;
      } else if( document.body.scrollHeight > document.body.offsetHeight ) {
        var pageWidth = document.body.scrollWidth;
        var pageHeight = document.body.scrollHeight;
      } else { 
        var pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
        var pageHeight = document.body.offsetHeight + document.body.offsetTop; 
      }
      //set the shader to cover the entire page and make it visible. 
      dark.style.width= pageWidth+'px';
      dark.style.height= pageHeight+'px';
      dark.style.display='block';                                
    }
    // Make the video visible and set the zindex so its on top of everything else
    div.style.zIndex='100';    
    div.style.display='block';
	var alignTopElement = document.getElementsByName(alignTop)[0];
	var alignTopCoords = findPos(alignTopElement);
	var alignRightElement = document.getElementsByName(alignRight)[0];
	var alignRightCoords = findPos(alignRightElement);
	
	var popup_top = alignTopCoords[0];
	if (VOffset == 'center')
		popup_top = popup_top - Math.floor(div.offsetHeight / 2);
	else
		popup_top = popup_top - VOffset;
		
	var popup_left = (alignRightCoords[1] + alignRightElement.offsetWidth + HOffset);
	
	div.style.top = popup_top + 'px';
	div.style.left = popup_left + 'px';
	
    // set the starting x and y position of the video
    //div.style.top=scrollTop+Math.floor((document.documentElement.clientHeight/2)-(div.offsetHeight/2))+'px';
    //div.style.left=Math.floor((document.documentElement.clientWidth/2)-(div.offsetWidth/2))+'px';
  }
  return false;
}

function popForm(div, darken, extra_info1, extra_info2) {
  // This function accepts a division ID (vid), either a string or the actual
  // object itself.   vid is mandatory.   darken is optional, if it's true
  // the page will be greyed out under the video.
  var popupforms = getElementsByClass('popupform');  // Get all the videos on the page.
  var isdisplayed=null;
  for(i=0; i<popupforms.length; i++) {              // Loop through all the videos
    if (popupforms[i].style.display=='block') {     // This video is playing 
      isdisplayed=popupforms[i].id;                   // remember its name
      var tmp=popupforms[i].innerHTML;              // Get the division contents
      popupforms[i].innerHTML='';                   // destroy the contents
      popupforms[i].style.display='none';           // Terminate the video.
      popupforms[i].innerHTML=tmp;                  // rebuild the contents.
    }
  }
  
  // Ensure the cashout-verification pop-up "Cashout" buttons are hidden by default
  btnCashoutCAD = document.getElementById('btnCashoutCAD');
  if (btnCashoutCAD) btnCashoutCAD.style.display='none';
  btnCashoutUSD = document.getElementById('btnCashoutUSD');
  if (btnCashoutUSD) btnCashoutUSD.style.display='none';
  
  if (div == 'invoice_handler') {
	var invoice_handler_title = document.getElementById('invoice_handler_title');
	var invoice_handler_payment_status = document.getElementById('invoice_handler_payment_status');
	var invoice_handler_venue_access = document.getElementById('invoice_handler_venue_access');
	
	// Hide the progress animation
	var divProcess_Payment_Status_Progress = document.getElementById('divProcess_Payment_Status_Progress');
	divProcess_Payment_Status_Progress.style.display = 'none';
	
	// Assign the invoice ID to all hidden inputs requiring it
	var hdn_invoice_ids = document.getElementsByName('invoice_id');
	hdn_invoice_ids[0].value = extra_info1;
	hdn_invoice_ids[1].value = extra_info1;
	
	//for (var hdn_invoice_id in hdn_invoice_ids) {
	//	hdn_invoice_id.value = extra_info1;	
	//}
	
	// Display either the payment status controls or venue access controls,
	// depending on whether the invoice is marked as paid
	if (extra_info2 == 0) {
		invoice_handler_title.innerHTML = "Handle Payment Status for an Invoiced Patron&nbsp;";
		invoice_handler_venue_access.style.display = 'none';
		invoice_handler_payment_status.style.display = 'block';
		
		var btnProcess_Payment_Status = document.getElementById('btnProcess_Payment_Status');
		btnProcess_Payment_Status.style.display = 'none';
		
	} else if (extra_info2 == 1) {
		invoice_handler_title.innerHTML = "Provide Venue Access to an Invoiced Patron&nbsp;";
		invoice_handler_payment_status.style.display = 'none';
		invoice_handler_venue_access.style.display = 'block';
		
		var divVenue_Access_Details = document.getElementById('divVenue_Access_Details');
		divVenue_Access_Details.style.display = 'none';
	}
	
  } else if (div == 'buyer_email_admin') {
	var hdnBuyerAdminID = document.getElementById('hdnBuyerAdminID');
	hdnBuyerAdminID.value = extra_info1;  
	
	var lnkBuyerEmailAdminMailto = document.getElementById('lnkBuyerEmailAdminMailto');
	lnkBuyerEmailAdminMailto.href = 'mailto:' + extra_info2;
	
	var spanBuyerEmailAdminNormal = document.getElementById('spanBuyerEmailAdminNormal');
	spanBuyerEmailAdminNormal.innerHTML = extra_info2;
	
	var txtBuyerEmailAddress = document.getElementById('txtBuyerEmailAddress');
	txtBuyerEmailAddress.value = extra_info2;
	
	handle_buyer_email_admin_canceledit();
  } else if (div == 'event_graph1_large') {
	swfobject.embedSWF("incl/php-ofc-library/open-flash-chart.swf", "chart1_large", chart_width, chart_height, "9.0.0", "expressInstall.swf", {"data-file":"%2FSR%2Fincl%2Fevent_graph_data1.php%3Fev%3D" + event_id} );
  } else if (div == 'event_graph2_large') {
	swfobject.embedSWF("incl/php-ofc-library/open-flash-chart.swf", "chart2_large", chart_width, chart_height, "9.0.0", "expressInstall.swf", {"data-file":"%2FSR%2Fincl%2Fevent_graph_data2.php%3Fev%3D" + event_id} );
  } else if (div == 'event_graph3_large') {
	swfobject.embedSWF("incl/php-ofc-library/open-flash-chart.swf", "chart3_large", chart_width, chart_height, "9.0.0", "expressInstall.swf", {"data-file":"%2FSR%2Fincl%2Fevent_graph_data3.php%3Fev%3D" + event_id} );
  }
  
  // This handles the darkening of the background while a video is playing.
  // First we see if the dark layer exists.
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');          // Create the layer.
        tnode.style.backgroundColor='rgb(0, 0, 0)';     // Make it black.
        tnode.style.opacity='0.7';                      // Set the opacity (firefox/Opera)
        tnode.style.MozOpacity='0.70';                  // Firefox 1.5
        tnode.style.filter='alpha(opacity=70)';         // IE.
        tnode.style.zIndex='1';                         // Zindex of 50 so it "floats"
        tnode.style.position='absolute';                // Position absolutely
        tnode.style.top='0px';                          // In the top
        tnode.style.left='0px';                         // Left corner of the page
        tnode.style.overflow='hidden';                  // Try to avoid making scroll bars            
        tnode.style.display='none';                     // Start out Hidden
        tnode.id='darkenScreenObject';                  // Name it so we can find it later
    tbody.appendChild(tnode);                           // Add it to the web page
    dark=document.getElementById('darkenScreenObject'); // Get the object.
  }
  dark.style.display='none';
  if ((isdisplayed==div)||(/^close$/i.test(div))) { return false; }
  if (typeof(div)=="string") { var divname = div; div=document.getElementById(div); }
  if (div&&typeof(div)=="object") {
    if (darken) {
      // Calculate the page width and height 
      if( window.innerHeight && window.scrollMaxY )  { 
        var pageWidth = window.innerWidth + window.scrollMaxX;
        var pageHeight = window.innerHeight + window.scrollMaxY;
      } else if( document.body.scrollHeight > document.body.offsetHeight ) {
        var pageWidth = document.body.scrollWidth;
        var pageHeight = document.body.scrollHeight;
      } else { 
        var pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
        var pageHeight = document.body.offsetHeight + document.body.offsetTop; 
      }
      //set the shader to cover the entire page and make it visible. 
      dark.style.width= pageWidth+'px';
      dark.style.height= pageHeight+'px';
	  dark.style.display='block';
    }
    // Make the video visible and set the zindex so its on top of everything else
    div.style.zIndex='100';
	div.style.display='block';
    var scrollTop = getScrollTop(); var clientHeight = 0; var clientWidth = 0;
    if ((document.documentElement != undefined) && (document.documentElement.clientHeight != undefined) && (document.documentElement.clientHeight > 0)) {
		clientHeight = document.documentElement.clientHeight;
		clientWidth = document.documentElement.clientWidth;
	} else if (document.body) {
		clientHeight = document.body.clientHeight;
		clientWidth = document.body.clientWidth;
	}

	if (divname == 'divAdminHeaderControls') {
		div.style.top = extra_info1 + 'px';
		div.style.left = extra_info2 + 'px';
	} else {
		
		if (divname.indexOf("event_graph") > -1)
			setTimeout('handle_align_div(\'' + divname + '\')', 250);

		// set the starting x and y position of the video
		div.style.top=scrollTop+Math.floor((clientHeight/2)-(div.offsetHeight/2))+'px';
		div.style.left=Math.floor((clientWidth/2)-(div.offsetWidth/2))+'px';
	}
  }
  return false;
}

function popComboBox_TicketQuantity(div, ticket_num, alignInput) {
  // This function accepts a division ID (div), either a string or the actual
  // object itself.   div is mandatory.   darken is optional, if it's true
  // the page will be greyed out under the video.
 /* var combobox_lists = getElementsByClass('combobox_list_ticket_quantity');  // Get all the videos on the page.
  var isdisplayed=null;
  for(i=0; i<combobox_lists.length; i++) {              // Loop through all the videos
    if (combobox_lists[i].style.display=='block') {     // This video is playing 
      isdisplayed=combobox_lists[i].id;                   // remember its name
      //var tmp=combobox_lists[i].innerHTML;              // Get the division contents
      //combobox_lists[i].innerHTML='';                   // destroy the contents
      combobox_lists[i].style.display='none';           // Terminate the video.
      //combobox_lists[i].innerHTML=tmp;                  // rebuild the contents.
    }
  }*/
	var combobox = document.getElementById(div);
	var isdisplayed=null;
	if (combobox.style.display=='block') {
		isdisplayed=div;
		combobox.style.display='none';
	}
  
  if ((isdisplayed == div) || (div == 'close') || (alignInput == undefined)) { return false; }
  if (typeof(div)=="string") { div=document.getElementById(div); }
  if (div&&typeof(div)=="object") {
    // Make the video visible and set the zindex so its on top of everything else
    div.style.zIndex='100';    
    div.style.display='block';
	var alignInput = document.getElementById(alignInput);
	var alignTopCoords = findPos(alignInput);
	var alignRightCoords = findPos(alignInput);
	var HOffset = -62;
	var VOffset = -30;
	
	var popup_top = alignTopCoords[0];
	if (VOffset == 'center')
		popup_top = popup_top - Math.floor(div.offsetHeight / 2);
	else
		popup_top = popup_top - VOffset;
		
	var popup_left = (alignRightCoords[1] + alignInput.offsetWidth + HOffset);
	
	div.style.top = popup_top + 'px';
	div.style.left = popup_left + 'px';
	
	// Set focus to the associated input field
	$("#lnkTicketQuantityComboButton_" + ticket_num).focus();
   	fleXenv.initByClass("combobox_list_ticket_quantity");
  }
  return false;
}

function popComboBox_Region(div, alignInput) {
  // This function accepts a division ID (div), either a string or the actual
  // object itself.   div is mandatory.   darken is optional, if it's true
  // the page will be greyed out under the video.
  var combobox_lists = getElementsByClass('combobox_list_region');  // Get all the videos on the page.
  var isdisplayed=null;
  for(i=0; i<combobox_lists.length; i++) {              // Loop through all the videos
    if (combobox_lists[i].style.display=='block') {     // This video is playing 
      isdisplayed=combobox_lists[i].id;                   // remember its name
      combobox_lists[i].style.display='none';           // Terminate the video.
    }
  }
  
  if ((isdisplayed == div) || (div == 'close') || (alignInput == undefined)) { return false; }
  if (typeof(div)=="string") { div=document.getElementById(div); }
  if (div&&typeof(div)=="object") {
    // Make the video visible and set the zindex so its on top of everything else
    div.style.zIndex='100';    
    div.style.display='block';
	var alignInput = document.getElementById(alignInput);
	var alignTopCoords = findPos(alignInput);
	var alignRightCoords = findPos(alignInput);
	var HOffset = -171;
	var VOffset = -37;
	
	var popup_top = alignTopCoords[0];
	if (VOffset == 'center')
		popup_top = popup_top - Math.floor(div.offsetHeight / 2);
	else
		popup_top = popup_top - VOffset;
	var popup_left = (alignRightCoords[1] + alignInput.offsetWidth + HOffset);
	
	div.style.top = popup_top + 'px';
	div.style.left = popup_left + 'px';
	
	// Set focus to the associated input field
	$("#lnkRegionComboButton").focus();
	fleXenv.initByClass("combobox_list_region");
  }
  return false;
}

function popComboBox_ExpMonth(div, alignInput) {
  // This function accepts a division ID (div), either a string or the actual
  // object itself.   div is mandatory.   darken is optional, if it's true
  // the page will be greyed out under the video.
  var combobox_lists = getElementsByClass('combobox_list_exp_month');  // Get all the videos on the page.
  var isdisplayed=null;
  for(i=0; i<combobox_lists.length; i++) {              // Loop through all the videos
    if (combobox_lists[i].style.display=='block') {     // This video is playing 
      isdisplayed=combobox_lists[i].id;                   // remember its name
      combobox_lists[i].style.display='none';           // Terminate the video.
    }
  }
  
  if ((isdisplayed == div) || (div == 'close') || (alignInput == undefined)) { return false; }
  if (typeof(div)=="string") { div=document.getElementById(div); }
  if (div&&typeof(div)=="object") {
    // Make the video visible and set the zindex so its on top of everything else
    div.style.zIndex='100';    
    div.style.display='block';
	var alignInput = document.getElementById(alignInput);
	var alignTopCoords = findPos(alignInput);
	var alignRightCoords = findPos(alignInput);
	var HOffset = -96;
	var VOffset = -37;
	
	var popup_top = alignTopCoords[0];
	if (VOffset == 'center')
		popup_top = popup_top - Math.floor(div.offsetHeight / 2);
	else
		popup_top = popup_top - VOffset;
	var popup_left = (alignRightCoords[1] + alignInput.offsetWidth + HOffset);
	
	div.style.top = popup_top + 'px';
	div.style.left = popup_left + 'px';
	
	// Set focus to the associated input field
	$("#lnkExpMonthComboButton").focus();
	fleXenv.initByClass("combobox_list_exp_month");
  }
  return false;
}

function popComboBox_ExpYear(div, alignInput) {
  // This function accepts a division ID (div), either a string or the actual
  // object itself.   div is mandatory.   darken is optional, if it's true
  // the page will be greyed out under the video.
  var combobox_lists = getElementsByClass('combobox_list_exp_year');  // Get all the videos on the page.
  var isdisplayed=null;
  for(i=0; i<combobox_lists.length; i++) {              // Loop through all the videos
    if (combobox_lists[i].style.display=='block') {     // This video is playing 
      isdisplayed=combobox_lists[i].id;                   // remember its name
      combobox_lists[i].style.display='none';           // Terminate the video.
    }
  }
  
  if ((isdisplayed == div) || (div == 'close') || (alignInput == undefined)) { return false; }
  if (typeof(div)=="string") { div=document.getElementById(div); }
  if (div&&typeof(div)=="object") {
    // Make the video visible and set the zindex so its on top of everything else
    div.style.zIndex='100';    
    div.style.display='block';
	var alignInput = document.getElementById(alignInput);
	var alignTopCoords = findPos(alignInput);
	var alignRightCoords = findPos(alignInput);
	var HOffset = -96;
	var VOffset = -37;
	
	var popup_top = alignTopCoords[0];
	if (VOffset == 'center')
		popup_top = popup_top - Math.floor(div.offsetHeight / 2);
	else
		popup_top = popup_top - VOffset;
	var popup_left = (alignRightCoords[1] + alignInput.offsetWidth + HOffset);
	
	div.style.top = popup_top + 'px';
	div.style.left = popup_left + 'px';
	
	// Set focus to the associated input field
	$("#lnkExpYearComboButton").focus();
	fleXenv.initByClass("combobox_list_exp_year");
  }
  return false;
}

function popLoginForm(div, darken) {
  
	if (div == 'close') {
		var divTemp = $('.global_login_form_frame')[0];
			if (divTemp.style.display=='block') {     // This video is playing 
				  var tmp=divTemp.innerHTML;              // Get the division contents
				  divTemp.innerHTML='';                   // destroy the contents
				  divTemp.style.display='none';           // Terminate the video.
				  divTemp.innerHTML=tmp;                  // rebuild the contents.
				  
				  // Reset Email Address
				  var input_email = document.getElementById('txtUser_Email');
				  input_email.value = 'Email Address';
				  
				  // Replace password-type input with text input
				  var input_pw = document.getElementById('txtUser_PW');
				  if (input_pw.getAttribute('type') == 'password') {
				  	var input2=document.createElement('input'); 
					input2.type='text'; input2.id=input_pw.id; input2.name=input_pw.name; 
					input2.setAttribute('class', input_pw.getAttribute('class')); 
					input2.value='Password';
					input2.setAttribute('onfocus', 'if (this.value==\'Password\') { this.value=\'\'; var input2=document.createElement(\'input\'); input2.type=\'password\'; input2.id=this.id; input2.name=this.name; input2.setAttribute(\'class\', this.getAttribute(\'class\')); input2.value=\'\'; this.parentNode.replaceChild(input2, this); setTimeout(\'$(\".global_login_input_pw\").focus()\', 50); }');
					input2.setAttribute('onkeypress', 'handleKeyPress(event,document.frmLogin)');
					input_pw.parentNode.replaceChild(input2, input_pw);
				  }
			}
	}
  
  // This handles the darkening of the background while a video is playing.
  // First we see if the dark layer exists.
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');          // Create the layer.
        tnode.style.backgroundColor='rgb(0, 0, 0)';     // Make it black.
        tnode.style.opacity='0.7';                      // Set the opacity (firefox/Opera)
        tnode.style.MozOpacity='0.70';                  // Firefox 1.5
        tnode.style.filter='alpha(opacity=70)';         // IE.
        tnode.style.zIndex='3';                         // Zindex of 50 so it "floats"
        tnode.style.position='absolute';                // Position absolutely
        tnode.style.top='0px';                          // In the top
        tnode.style.left='0px';                         // Left corner of the page
        tnode.style.overflow='hidden';                  // Try to avoid making scroll bars            
        tnode.style.display='none';                     // Start out Hidden
        tnode.id='darkenScreenObject';                  // Name it so we can find it later
    tbody.appendChild(tnode);                           // Add it to the web page
    dark=document.getElementById('darkenScreenObject'); // Get the object.
  }
  dark.style.display='none';
  
  if (div == 'close') { return false; }
  
  //if (typeof(div) == "string") { var divname = div; div=document.getElementsByClassName(div)[0]; }
  if (typeof(div) == "string") { var divname = div; var div = $('.' + div)[0]; }
  if (div && (typeof(div) == "object")) {
    if (darken) {
      // Calculate the page width and height 
      if( window.innerHeight && window.scrollMaxY )  { 
        var pageWidth = window.innerWidth + window.scrollMaxX;
        var pageHeight = window.innerHeight + window.scrollMaxY;
      } else if( document.body.scrollHeight > document.body.offsetHeight ) {
        var pageWidth = document.body.scrollWidth;
        var pageHeight = document.body.scrollHeight;
      } else { 
        var pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
        var pageHeight = document.body.offsetHeight + document.body.offsetTop; 
      }
      //set the shader to cover the entire page and make it visible. 
      dark.style.width = '100%'; //pageWidth+'px';
      dark.style.height = pageHeight + 'px';
	  dark.style.display = 'block';
	  
	  dark.setAttribute("onclick", "popLoginForm('close');");
    }
    // Make the video visible and set the zindex so its on top of everything else
    div.style.zIndex = '100';
	div.style.display = 'block';
    var scrollTop = getScrollTop(); var clientHeight = 0; var clientWidth = 0;
    if ((document.documentElement != undefined) && (document.documentElement.clientHeight != undefined) && (document.documentElement.clientHeight > 0)) {
		clientHeight = document.documentElement.clientHeight;
		clientWidth = document.documentElement.clientWidth;
	} else if (document.body) {
		clientHeight = document.body.clientHeight;
		clientWidth = document.body.clientWidth;
	}

	// set the starting x and y position of the video
	div.style.top = scrollTop + Math.floor((clientHeight / 2) - (div.offsetHeight / 2)) + 'px';
	div.style.left = Math.floor((clientWidth / 2) - (div.offsetWidth / 2)) + 'px';
  }
  return false;
}

function popLoggedOutNotice(div, darken) {
  
	if (div == 'close') {
		var divTemp = $('.global_logged_out_notice_frame')[0];
			if (divTemp.style.display=='block') {     // This video is playing 
				  var tmp=divTemp.innerHTML;              // Get the division contents
				  divTemp.innerHTML='';                   // destroy the contents
				  divTemp.style.display='none';           // Terminate the video.
				  divTemp.innerHTML=tmp;                  // rebuild the contents.
				  
				  // Redirect the browser to the Picatic home page if the user is viewing an account page
				  if (window.location.search.indexOf("client_account") > -1)
				  	window.location = "http://www.picatic.com";
			}
	}
  
  // This handles the darkening of the background while a video is playing.
  // First we see if the dark layer exists.
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');          // Create the layer.
        tnode.style.backgroundColor='rgb(0, 0, 0)';     // Make it black.
        tnode.style.opacity='0.7';                      // Set the opacity (firefox/Opera)
        tnode.style.MozOpacity='0.70';                  // Firefox 1.5
        tnode.style.filter='alpha(opacity=70)';         // IE.
        tnode.style.zIndex='3';                         // Zindex of 50 so it "floats"
        tnode.style.position='absolute';                // Position absolutely
        tnode.style.top='0px';                          // In the top
        tnode.style.left='0px';                         // Left corner of the page
        tnode.style.overflow='hidden';                  // Try to avoid making scroll bars            
        tnode.style.display='none';                     // Start out Hidden
        tnode.id='darkenScreenObject';                  // Name it so we can find it later
    tbody.appendChild(tnode);                           // Add it to the web page
    dark=document.getElementById('darkenScreenObject'); // Get the object.
  }
  dark.style.display='none';
  
  if (div == 'close') { return false; }
  
  //if (typeof(div) == "string") { var divname = div; div=document.getElementsByClassName(div)[0]; }
  if (typeof(div) == "string") { var divname = div; var div = $('.' + div)[0]; }
  if (div && typeof(div) == "object") {
    if (darken) {
      // Calculate the page width and height 
      if( window.innerHeight && window.scrollMaxY )  { 
        var pageWidth = window.innerWidth + window.scrollMaxX;
        var pageHeight = window.innerHeight + window.scrollMaxY;
      } else if( document.body.scrollHeight > document.body.offsetHeight ) {
        var pageWidth = document.body.scrollWidth;
        var pageHeight = document.body.scrollHeight;
      } else { 
        var pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
        var pageHeight = document.body.offsetHeight + document.body.offsetTop; 
      }
      //set the shader to cover the entire page and make it visible. 
      dark.style.width='100%'; //pageWidth+'px';
      dark.style.height= pageHeight+'px';
	  dark.style.display='block';
	  
	  dark.setAttribute("onclick", "popLoggedOutNotice('close');");
    }
    // Make the video visible and set the zindex so its on top of everything else
    div.style.zIndex='100';
	div.style.display='block';
    var scrollTop = getScrollTop(); var clientHeight = 0; var clientWidth = 0;
    if ((document.documentElement != undefined) && (document.documentElement.clientHeight != undefined) && (document.documentElement.clientHeight > 0)) {
		clientHeight = document.documentElement.clientHeight;
		clientWidth = document.documentElement.clientWidth;
	} else if (document.body) {
		clientHeight = document.body.clientHeight;
		clientWidth = document.body.clientWidth;
	}

	// set the starting x and y position of the video
	div.style.top=scrollTop+Math.floor((clientHeight/2)-(div.offsetHeight/2))+'px';
	div.style.left=Math.floor((clientWidth/2)-(div.offsetWidth/2))+'px';
  }
  return false;
}

function popContactPromoterForm(div, darken) {
  
	if (div == 'close') {
		var divTemp = document.getElementsByClassName('eventpage_contact_promoter_form_frame')[0];
			if (divTemp.style.display=='block') {     // This video is playing 
				  var tmp=divTemp.innerHTML;              // Get the division contents
				  divTemp.innerHTML='';                   // destroy the contents
				  divTemp.style.display='none';           // Terminate the video.
				  divTemp.innerHTML=tmp;                  // rebuild the contents.
			}
	}
  
  // This handles the darkening of the background while a video is playing.
  // First we see if the dark layer exists.
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');          // Create the layer.
        tnode.style.backgroundColor='rgb(0, 0, 0)';     // Make it black.
        tnode.style.opacity='0.7';                      // Set the opacity (firefox/Opera)
        tnode.style.MozOpacity='0.70';                  // Firefox 1.5
        tnode.style.filter='alpha(opacity=70)';         // IE.
        tnode.style.zIndex='3';                         // Zindex of 50 so it "floats"
        tnode.style.position='absolute';                // Position absolutely
        tnode.style.top='0px';                          // In the top
        tnode.style.left='0px';                         // Left corner of the page
        tnode.style.overflow='hidden';                  // Try to avoid making scroll bars            
        tnode.style.display='none';                     // Start out Hidden
        tnode.id='darkenScreenObject';                  // Name it so we can find it later
    tbody.appendChild(tnode);                           // Add it to the web page
    dark=document.getElementById('darkenScreenObject'); // Get the object.
  }
  dark.style.display='none';
  
  if (div == 'close') { return false; }
  
  if (typeof(div) == "string") { var divname = div; div=document.getElementsByClassName(div)[0]; }
  if (div && typeof(div) == "object") {
    if (darken) {
      // Calculate the page width and height 
      if( window.innerHeight && window.scrollMaxY )  { 
        var pageWidth = window.innerWidth + window.scrollMaxX;
        var pageHeight = window.innerHeight + window.scrollMaxY;
      } else if( document.body.scrollHeight > document.body.offsetHeight ) {
        var pageWidth = document.body.scrollWidth;
        var pageHeight = document.body.scrollHeight;
      } else { 
        var pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
        var pageHeight = document.body.offsetHeight + document.body.offsetTop; 
      }
      //set the shader to cover the entire page and make it visible. 
      dark.style.width='100%'; //pageWidth+'px';
      dark.style.height= pageHeight+'px';
	  dark.style.display='block';
	  
	  dark.setAttribute("onclick", "popContactPromoterForm('close');");
    }
    // Make the video visible and set the zindex so its on top of everything else
    div.style.zIndex='100';
	div.style.display='block';
	var scrollTop = getScrollTop(); var clientHeight = 0; var clientWidth = 0;
	//if ((document.documentElement) && (document.documentElement.scrollTop)) {
    if ((document.documentElement != undefined) && (document.documentElement.clientHeight != undefined) && (document.documentElement.clientHeight > 0)) {
		clientHeight = document.documentElement.clientHeight;
		clientWidth = document.documentElement.clientWidth;
	} else if (document.body) {
		clientHeight = document.body.clientHeight;
		clientWidth = document.body.clientWidth;
	}

	// set the starting x and y position of the video
	div.style.top=scrollTop+Math.floor((clientHeight/2)-(div.offsetHeight/2))+'px';
	div.style.left=Math.floor((clientWidth/2)-(div.offsetWidth/2))+'px';
  }
  return false;
}

function popLearnMoreVideoLightbox(div, darken) {
  
	if (div == 'close') {
		//var divTemp = document.getElementsByClassName('learn_more_video_lightbox_frame')[0];
		var divTemp = $(".learn_more_video_lightbox_frame")[0];
			if (divTemp.style.display=='block') {     // This video is playing 
				  var tmp=divTemp.innerHTML;          // Get the division contents
				  divTemp.innerHTML='';               // destroy the contents
				  divTemp.style.display='none';       // Terminate the video.
				  divTemp.innerHTML=tmp;              // rebuild the contents.
			}
		var divLearnMoreVideo = document.getElementById("divLearnMoreVideoEmbed");
		if (divLearnMoreVideo)
			divLearnMoreVideo.innerHTML = '';
	}
  
  // This handles the darkening of the background while a video is playing.
  // First we see if the dark layer exists.
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');          // Create the layer.
        tnode.style.backgroundColor='rgb(0, 0, 0)';     // Make it black.
        tnode.style.opacity='0.7';                      // Set the opacity (firefox/Opera)
        tnode.style.MozOpacity='0.70';                  // Firefox 1.5
        tnode.style.filter='alpha(opacity=70)';         // IE.
        tnode.style.zIndex='50';                        // Zindex of 50 so it "floats"
        tnode.style.position='absolute';                // Position absolutely
        tnode.style.top='0px';                          // In the top
        tnode.style.left='0px';                         // Left corner of the page
        tnode.style.overflow='hidden';                  // Try to avoid making scroll bars            
        tnode.style.display='none';                     // Start out Hidden
        tnode.id='darkenScreenObject';                  // Name it so we can find it later
    tbody.appendChild(tnode);                           // Add it to the web page
    dark=document.getElementById('darkenScreenObject'); // Get the object.
  }
  dark.style.display='none';
  
  if (div == 'close') { return false; }
  
  if (typeof(div) == "string") { 
  	var divname = div;
	if (div == 'learn_more_video_lightbox_frame') {
		var divLearnMoreVideo = document.getElementById("divLearnMoreVideoEmbed");
		divLearnMoreVideo.innerHTML = '<iframe type="text/html" width="560" height="315" src="http://www.youtube.com/embed/eniJ44CUHgo?autoplay=1" frameborder="0" allowfullscreen></iframe>';
	}
	div = $(".learn_more_video_lightbox_frame")[0];
  }
  if (div && typeof(div) == "object") {
    if (darken) {
      // Calculate the page width and height 
      if( window.innerHeight && window.scrollMaxY )  { 
        var pageWidth = window.innerWidth + window.scrollMaxX;
        var pageHeight = window.innerHeight + window.scrollMaxY;
      } else if( document.body.scrollHeight > document.body.offsetHeight ) {
        var pageWidth = document.body.scrollWidth;
        var pageHeight = document.body.scrollHeight;
      } else { 
        var pageWidth = document.body.offsetWidth + document.body.offsetLeft; 
        var pageHeight = document.body.offsetHeight + document.body.offsetTop; 
      }
      //set the shader to cover the entire page and make it visible. 
      dark.style.width='100%'; //pageWidth+'px';
      dark.style.height= pageHeight+'px';
	  dark.style.display='block';
	  
	  dark.setAttribute("onclick", "popLearnMoreVideoLightbox('close');");
    }
    // Make the video visible and set the zindex so its on top of everything else
    div.style.zIndex='100';
	div.style.display='block';
	var scrollTop = getScrollTop(); var clientHeight = 0; var clientWidth = 0;
	//if ((document.documentElement) && (document.documentElement.scrollTop)) {
    if ((document.documentElement != undefined) && (document.documentElement.clientHeight != undefined) && (document.documentElement.clientHeight > 0)) {
		clientHeight = document.documentElement.clientHeight;
		clientWidth = document.documentElement.clientWidth;
	} else if (document.body) {
		clientHeight = document.body.clientHeight;
		clientWidth = document.body.clientWidth;
	}

	// set the starting x and y position of the video
	div.style.top = scrollTop + Math.floor((clientHeight / 2) - (div.offsetHeight / 2)) + 'px';
	div.style.left = Math.floor((clientWidth / 2) - (div.offsetWidth / 2)) + 'px';
	
  }
  return false;
}

function handle_align_div(divname) {
	//alert('handle_align_graph');
	div=document.getElementById(divname);
	
	if ((div.offsetWidth < chart_width) || (div.offsetHeight < chart_height)) {
		setTimeout('handle_align_graph(\'' + divname + '\')', 250);
	} else {
		var scrollTop = getScrollTop(); var clientHeight = 0; var clientWidth = 0;
		if ((document.documentElement != undefined) && (document.documentElement.clientHeight != undefined) && (document.documentElement.clientHeight > 0)) {
			clientHeight = document.documentElement.clientHeight;
			clientWidth = document.documentElement.clientWidth;
		} else if (document.body) {
			clientHeight = document.body.clientHeight;
			clientWidth = document.body.clientWidth;
		}
		
		div.style.top = scrollTop + Math.floor((clientHeight/2)-(div.offsetHeight/2)) + 'px';
    	div.style.left = Math.floor((clientWidth/2)-(div.offsetWidth/2)) + 'px';
	}
}
