// Cpanel Common JavaScript Functions
var safe_to_fade = 0;
var cur_div = 0;
var next_div = 0;
var fade_delay;
var fade_duration;
var fade_cur = 100;
var fade_next = 0;
//var item_fade_cur;
var enable_initAnims = true;

// Handle scroll bar positioning
var clear_scrollbar_pos = false;


function silentErrorHandler() {
	return true;
}
window.onerror=silentErrorHandler;

window.onload=function(){
	
	if (document.getElementById("my_menu")) {
		var myMenu;
		myMenu = new mycontent("my_menu");
		myMenu.init();
	}

	Nifty("div#centerTop","transparent top big");
	Nifty("div#labelBox","transparent top");
	Nifty("div.labelBox","transparent top");
	Nifty("div#labelBox_long","transparent top");
	Nifty("div.labelBox_long","transparent top");
	Nifty("div.labelBoxLarge", "transparent top");
	Nifty("div#labelBoxLarge", "transparent top");
	Nifty("div#labelBoxBottom","bottom");
	Nifty("div.labelBoxBottom","bottom");
  Nifty("div#labelBoxTabBottom","bottom");
	Nifty("div.labelBoxTabBottom","bottom");
	Nifty("div#itemContainer","transparent");
	Nifty("div.itemContainer","transparent");
	Nifty("div.itemContainerCenter","transparent bottom");
	Nifty("div#itemContainerCenter","transparent bottom");
	Nifty("div.itemContainer_alert_red","transparent all");
	Nifty("div#itemContainer_alert_red","transparent all");
	Nifty("div.itemContainer_alert_green","transparent all");
	Nifty("div#itemContainer_alert_green","transparent all");
	Nifty("div.form_error", "transparent all");
	Nifty("div#form_error", "transparent all");
	Nifty("div.form_error_membercode", "transparent all");
	Nifty("div#form_error_membercode", "transparent all");

	initScrollbar();
	
	if (document.getElementById('google_ads_box')){
		change_style('google_ads_box_fake', 'display', 'none');
		change_style('google_ads_box', 'display', 'block');
	}	
	
	if (document.getElementById("slider1")) {
		sliders = lmwGetElementsByClass(lmwSliderClassName) // Find the horizontal sliders.
		for (i = 0; i < sliders.length; i++) {
			sliders[i].onmousedown = slide // Attach event listener.
		}
		displays = lmwGetElementsByClass(lmwSliderDisplayClassName) // Find the displays.
		for (i = 0; i < displays.length; i++) {
			displays[i].onfocus = focusDisplay // Attach event listener.
		}
	}
	
	if (inititalize_the_lightbox){
		initialize_lightbox();
		getBrowserInfo();		
	}
	
	ajax_tooltip_active = 1;
	
	initAnims();
	
	init_fade();
	
	if (initiate_file_upload == 1)
		iniFilePage();	
}

window.onunload=function(){
	deinitScrollbar();
}


var addEvent = (addEvent) ? addEvent : function(el, ev, fn){  
	var on_ev = "on" + ev;
	var old_fn;

	if (el.addEventListener) {
		el.addEventListener(ev, fn, false);  
	} else if (el.attachEvent) {
		el.attachEvent(on_ev, fn);  
	} else if (typeof(el[on_ev]) === 'function') {
		old_fn = el[on_ev];
		el[on_ev] = function() { old_fn(); fn(); };
	} else {
		el[on_ev]=fn;  
	}
};


function initScrollbar() {
	var doc, cur, last;

	doc = { 'page': document.location.href, 'scroll': 0 };
	cur = { 'page': getCookie('current_page'),
		'scroll': getCookie('current_scrollbar_position') };
	last = { 'page': getCookie('last_page'),
		'scroll': getCookie('last_scrollbar_position') };

	// document.documentElement.scrollTop requires a DOCTYPE >= HTML 4 to work.
	if (!cur.page) {	// no history: record this page as current
		setScrollbarCookie('current', doc);
	} else if (doc.page == cur.page) { // page reload: no change to current/last page
		document.documentElement.scrollTop = cur.scroll || 0;
	} else if (last.page && doc.page == last.page) { // came back to last page: swap current & last
		document.documentElement.scrollTop = last.scroll || 0;

		setScrollbarCookie('last', cur);
		setScrollbarCookie('current', last);
	} else { // new page: discard old last_page and record new current/last
		setScrollbarCookie('last', cur);
		setScrollbarCookie('current', doc);
	}

	var fs = document.forms; 
	for (var i = 0; i < fs.length; i++) {
		addEvent(fs[i], "submit", clearScrollbarPos);
	} 
}

function setScrollbarCookie(which, data) {
	var scroll_name = which + '_scrollbar_position';
	var page_name = which + '_page';

	setCookie(page_name, data.page, 365);
	setCookie(scroll_name, data.scroll, 365);
}

function clearScrollbarPos() {
	clear_scrollbar_pos = true;
	return true; // allow form to submit
}

function deinitScrollbar() {
	var pos = (clear_scrollbar_pos ? 0 : document.documentElement.scrollTop);
	setCookie('current_scrollbar_position', pos, 365);
}


function change_style_auto(style2, attribute, value) {
	var property = attribute;
	var dash;

	// convert all "-foo" to "Foo"
	while ((dash = property.indexOf("-")) != -1) {
		property = property.substr(0, dash) +              // everything before the dash
			property.substr(dash+1, 1).toUpperCase() + // letter afterward to uppercase
			property.substr(dash+2);                   // rest of the string
	}

	// set dynamically
	style2[property] = value;
}

function change_style(id, attribute, value){
	var style2 = getElement(id);
	
	switch (attribute) {
		case "background":
			style2.backgroundColor = value;
			break;
		case "background2":
			style2.background = value;
			break;
		case "opacity":
			style2.opacity = (value / 100);
			style2.filter = "alpha(opacity="+value+")"	
			break;
		default:
			// original cases now handled here: border border-left border-right
			// text-decoration color display height cursor
			change_style_auto(style2, attribute, value);
			break;
	}	
};

function getElement(div_id){
	return getElementBase(div_id).style;
}

function getElementValue(div_id){
	var identification = getElementBase(div_id);
	return identification.value;
}

// Rename this to simply getElement - rename the other found in common.js to getElementStyle
function getElementBase(div_id){
	if (document.getElementById){
		// this is the way the standards work
		var identification = document.getElementById(div_id);
	}
	else if (document.all){
		// this is the way old msie versions work
		var identification = document.all[div_id];
	}
	else if (document.layers){
		// this is the way nn4 works
		var identification = document.layers[div_id];
	}
	return identification;
}

function toggleLayer(whichLayer){
	var style2 = getElement(whichLayer);
	style2.display = style2.display? "":"none";
}

function toggleLayer2(whichLayer){
	var style2 = getElement(whichLayer);
	if (document.getElementById){
		// this is the way the standards work	
		var this_height = 0;
		while (this_height < 100) {
			setTimeout(style2.top = this_height, 5000);			
			this_height++;
		}
	} else {
		style2.display = style2.display? "":"none";
	}
}



function open_popup_window(theURL, name, width, height, options) {
  var winl = (screen.width-width)/2;
	var wint = (screen.height-height)/2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;

	var default_options = {
		'width': width,
		'height': height,
		'left': winl,
		'top': wint,
		'location': 'no',
		'menubar': 'no',
		'toolbar': 'no',
		'scrollbars': 'no',
		'resizable': 'no'
	};
	var key, value;
	var option_str = new Array();

	if (!options) options = {};

	for (key in default_options) {
		value = ((key in options) ? options[key] : default_options[key]);
		option_str[option_str.length] = key + '=' + value;
	}
	option_str = option_str.join(',');

	try {
        msgWindow = open(theURL, name, option_str);
		if (msgWindow.opener == null) msgWindow.opener = self;
		if (window.focus) msgWindow.focus();
	}
	catch (e) {
	  alert('blocked');
		// popups blocked by a 3rd party
	}
}

function view(theURL) { //v2.0
	open_popup_window(theURL, 'PROlibraries', 730, 610);
}

function view_tutorial(theURL) { //v2.0
	open_popup_window(theURL, 'PROlibraries', 615, 515);
}

function viewpreview(theURL) { //v2.0
	open_popup_window(theURL, 'PROlibraries', 895, 610);
}

function viewfreeman(theURL) { //v2.0
	open_popup_window(theURL, 'PROlibraries', 895, 665);
}

// seems to be only in use from: prolibraries_new/left_overs.html
function viewverisign(theURL) { //v2.0
	open_popup_window(theURL, 'VRSN_Splash', 560, 500, {'location':'yes', 'status':'yes', 'resizable':'yes', 'scrollbars':'yes'});
}

function moneyf(mnt) {
	mnt -= 0;
	mnt = (Math.round(mnt*100))/100;
	return (mnt == Math.floor(mnt)) ? mnt + '.00' 
		  : ( (mnt*10 == Math.floor(mnt*10)) ? 
		  mnt + '0' : mnt);
}
					
function jtax() {
	if(document.form_checkout.state.value != "NY"){
		var thesub = Number(document.form_checkout.total2.value);
		var tax = (thesub * 0) / 100;
	} else {
		var thesub = Number(document.form_checkout.total2.value);
		var tax = (thesub * 8.00) / 100;
	}
				
	var total = thesub + tax;
	document.form_checkout.tax.value = '$' + moneyf(tax);
	document.form_checkout.total.value = '$' + moneyf(total);
}

function submitenter(myfield,e) {
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else if (e) 
		keycode = e.which;
	else 
		return true;
	
	if (keycode == 13) {
	   myfield.form.submit();
	   return false;
	}
	else
	   return true;
}

function componentMinMax(the_layer){
	toggleLayer(the_layer);	
	if (getCookie(the_layer) == "no")
		setCookie(the_layer, "yes", 365);
	else			
		setCookie(the_layer, "no", 365);
}



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 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 removeCookie(cookie_name) {
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime (cookie_date.getTime() - 1);
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}


function deleteCookie( name, path, domain ) {
  if ( Get_Cookie( name ) )
    document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") +
      ( ( domain ) ? ";domain=" + domain : "" ) +
      ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}



function startList(filter_id_name) {
	// Target ie 6
	if (document.all && document.getElementById) {		
		navRoot = document.getElementById(filter_id_name);		
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
	  	}		
	}
	
}

function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\s)" + className + "(\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}


function init_anims_do(classname) {
	// internal functions used as event handlers
    //elem.childNodes[1].setAttribute('src', '');
    //elem.childNodes[1].setAttribute('src', elem.childNodes[1].src.replace('select=slide', 'select=slide&slide=002'));
    // http://server2.prolibraries.com/gdlib/index.php?select=slide&slide=002&sourceURL=prolibraries/amsn/2005/1307-0120-002
    // http://server2.prolibraries.com/gdlib/index.php?select=slide&sourceURL=prolibraries/amsn/2005/1307-0120-002
    //alert(elem.childNodes[1].src.replace('select=slide', 'select=slide&slide=002'));

    function fadeBGColMem() {
        if (!this.currentbgRGB) this.currentbgRGB = [255,255,255]; //if no mem is set, set it first;
        //currentFadeID = this.id;
        //alert('ON ' + currentFadeID);
		    doBGFadeMem(this,this.currentbgRGB,[239, 243, 255],4,10,1);
		    change_style(this.id+"_title", "text-decoration", "underline");
        if (this.id.substring(0, 7) == 'content'){
            change_style(this.id+"_title", "color", "#000000");
            change_style(this.id+"_id", "color", "#000000");
            change_style(this.id+"_id", "text-decoration", "underline");
            change_style(this.id+"_score", "color", "#000000");
        }
        //initSessionSlideShow(this);
        //this.childNodes[1].setAttribute('src', this.childNodes[1].src.replace('&slide=002', ''));
        //this.childNodes[1].setAttribute('src', this.childNodes[1].src.replace('select=slide', 'select=slide&slide=002'));
		//change_style(this.id, "border-bottom", "1px solid #004D80");
		//change_style(this.id, "border-top", "1px solid #004D80");
	}

	function fadeBGColRestore() {
		if (!this.currentbgRGB) return;	//avoid error if mouseout an element occurs before the mosueover
											//(e.g. the pointer already in the object when onload)
        //if (this.id == currentFadeID) return;
		change_style(this.id+"_title", "text-decoration", "none");
        if (this.id.substring(0, 7) == 'content'){
            change_style(this.id+"_title", "color", "#696969");
            change_style(this.id+"_id", "color", "#696969");
            change_style(this.id+"_id", "text-decoration", "none");
            change_style(this.id+"_score", "color", "#808080");
            if (this.getAttribute('originalBackground') == '#FFFFFF')
                doBGFadeMem(this,this.currentbgRGB,[255,255,255],20,40,0.5);
            else
                doBGFadeMem(this,this.currentbgRGB,[250,250,250],20,40,0.5);
        }
        else
            doBGFadeMem(this,this.currentbgRGB,[255,255,255],20,40,0.5);
		//change_style(this.id, "border-bottom", "1px solid #EEEEEE");
		//change_style(this.id, "border-top", "1px solid #FFFFFF");
        //alert((('src', this.childNodes[1].src.replace('slide=002', 'slide=001'))));
        //this.childNodes[1].setAttribute('src', this.childNodes[1].src.replace('&slide=001', ''));
        //this.childNodes[1].setAttribute('src', this.childNodes[1].src.replace('select=slide', 'select=slide&slide=001'));
        //alert('OFF ' + currentFadeID);

        //alert(this.childNodes[1].src);
	}

	// actual setup code
	var animElements = getElementsByClassName(classname);	
	for(var i=0; i < animElements.length; i++) {
		animElements[i].onmouseover = fadeBGColMem;
		animElements[i].onmouseout = fadeBGColRestore;
	}
}

var currentFadeID;

function initAnims() {
	if (!enable_initAnims) {
		return;
	}
	
	var i;
	var classlist = [
		'prolibraries_librarywrapper_cf',
		'prolibraries_productwrapper',
		'prolibraries_librarywrapper_ve',
		'prolibraries_productwrapper3',
		'prolibraries_librarywrapper',
		'home_pop_item_library',
		'home_pop_item_speakers',
		'home_pop_item_programs',
		'home_pop_item_meetings',
		'hover_select_box'
	];

	for (i in classlist) {
		init_anims_do(classlist[i]);
	}

}

function doBGFadeMem(elem,startRGB,endRGB,steps,intervals,powr) {
	if (elem.bgFadeMemInt) window.clearInterval(elem.bgFadeMemInt);
	var actStep = 0;
    elem.bgFadeMemInt = window.setInterval(
		function() {
			elem.currentbgRGB = [
				easeInOut(startRGB[0],endRGB[0],steps,actStep,powr),
				easeInOut(startRGB[1],endRGB[1],steps,actStep,powr),
				easeInOut(startRGB[2],endRGB[2],steps,actStep,powr)
				];
			elem.style.backgroundColor = "rgb("+
				elem.currentbgRGB[0]+","+
				elem.currentbgRGB[1]+","+
				elem.currentbgRGB[2]+")";
			actStep++;
			if (actStep > steps) window.clearInterval(elem.bgFadeMemInt);
		}
		,intervals)
}

function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) {
//Generic Animation Step Value Generator By www.hesido.com
	var delta = maxValue - minValue;
	var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
	return Math.ceil(stepp)
}

function initSessionSlideShow(elem){
    alert(elem.id);
    //elem.childNodes[1].setAttribute('src', this.childNodes[1].src.replace('&slide=002', ''));
    //elem.childNodes[1].setAttribute('src', this.childNodes[1].src.replace('select=slide', 'select=slide&slide=002'));
}

function doSessionSlideShow(elem){

}

var imfading = 0;

function fade_replace_div(div_id_start, div_id_end) {
	if (div_id_start == "all"){
		//change_style('topic_programs_wrapper', "display", "none");
		change_style('topic_associations_wrapper', "display", "none");
		change_style('topic_speaker_wrapper', "display", "none");
		change_style('topic_rss_wrapper', "display", "none");
		change_style(div_id_end, "display", "block");
		return;
	}
	if (imfading == 0) {
		imfading = 1;
		fade_replace_value = 90;
		change_style(div_id_start, "display", "block");		
		fade_replace_interval = window.setInterval(
			function() {
				change_style(div_id_start+"_c", "opacity", fade_replace_value);				
				fade_replace_value -= 10;
				fade_replace_value = 0;
				if (fade_replace_value <= 0){					
					window.clearInterval(fade_replace_interval);
					fade_replace_value = 10;
					change_style(div_id_start, "display", "none");
					change_style(div_id_end+"_c", "opacity", "0");
					change_style(div_id_end, "display", "block");
					fade_replace_interval = window.setInterval(
						function() {
							change_style(div_id_end+"_c", "opacity", fade_replace_value);	
							fade_replace_value += 10;
							if (fade_replace_value >= 100){
								window.clearInterval(fade_replace_interval);
								imfading = 0;
							}														   
						}
						, 5);
				}
			}
			, 5);
	}
}


function topicTab_over(div_id) {
	change_style(div_id+"_p", "color", "#000000");
}

function topicTab_out(div_id) {
	change_style(div_id+"_p", "color", "#EFF3FF");
}

function topicTab_click(div_id) {
	change_style("topic_programs_wrapper", "display", "none");
	change_style("topic_associations_wrapper", "display", "none");
	change_style("topic_speaker_wrapper", "display", "none");
	change_style(div_id, "display", "block");
	change_style(div_id+"_p", "color", "#000000");
}

var login_fade = 0;
var login_height;
var login_fade_delay;
var login_fade_delay2;
var login_status = "closed";

function hide() {
	var id = "splashOverlayID";
	splash = document.getElementById(id);
	splash.style.visibility = "hidden";
}

function init_fade(){
	for (var x = 2; x <= 4; x++){	
		document.getElementById('procasts_home_pane' + x).style.opacity = "0";
		document.getElementById('procasts_home_pane' + x).style.filter = 
			"alpha(opacity=0) progid:DXImageTransform.Microsoft.AlphaImageLoader (src='./images/home_pane.png', sizingMethod='scale');";
	}	
	cur_div = 1;	
	document.getElementById('procasts_overlay1').style.filter = "alpha(opacity=0)";
	document.getElementById('procasts_overlay1').style.opacity = "0";
	document.getElementById('procasts_home_pane1').style.background = "#B32200";
	document.getElementById('procasts_home_pane1').style.opacity = "1.00";
	document.getElementById('procasts_home_pane1').style.filter = 
		"alpha(opacity=100) progid:DXImageTransform.Microsoft.AlphaImageLoader (src='./images/home_pane.png', sizingMethod='scale');";
	go_fade();
}


function change_button(this_div) {	
	for (var x = 1; x <= 4; x++){ 
		document.getElementById('procasts_overlay' + x).style.filter = "alpha(opacity=30)";
		document.getElementById('procasts_overlay' + x).style.opacity = "0.30";
	}		
	document.getElementById('procasts_overlay' + this_div).style.filter = "alpha(opacity=0)";
	document.getElementById('procasts_overlay' + this_div).style.opacity = "0";	
}

function home_hover_over(overlay_num){
	clearInterval(fade_delay);
	clearInterval(fade_duration);
	safe_to_fade = 0;			
	if (cur_div != overlay_num){		
		cur_div = overlay_num;	
		change_button (cur_div);		
		
		for (var x = 1; x <= 4; x++){	
			document.getElementById('procasts_home_pane' + x).style.opacity = "0";
			document.getElementById('procasts_home_pane' + x).style.filter = 
				"alpha(opacity=0) progid:DXImageTransform.Microsoft.AlphaImageLoader (src='./images/home_pane.png', sizingMethod='scale');";
		}	
		document.getElementById('procasts_home_pane' + overlay_num).style.opacity = "1.00";
		document.getElementById('procasts_home_pane' + overlay_num).style.filter = 
			"alpha(opacity=100) progid:DXImageTransform.Microsoft.AlphaImageLoader (src='./images/home_pane.png', sizingMethod='scale');";	
	}		
}

function go_fade(){
	clearInterval(fade_delay);
	clearInterval(fade_duration);
	safe_to_fade = 1;
	fade_delay = setInterval("new_fade()", 7000);
}

function halt_fade(){
	safe_to_fade = 0;
	clearInterval(fade_delay);
	clearInterval(fade_duration);		
	for (var x = 1; x <= 4; x++){	
		document.getElementById('procasts_home_pane' + x).style.opacity = "0";
		document.getElementById('procasts_home_pane' + x).style.filter = 
			"alpha(opacity=0) progid:DXImageTransform.Microsoft.AlphaImageLoader (src='./images/home_pane.png', sizingMethod='scale');";
	}	
	document.getElementById('procasts_home_pane' + cur_div).style.opacity = "1.00";
	document.getElementById('procasts_home_pane' + cur_div).style.filter = 
		"alpha(opacity=100) progid:DXImageTransform.Microsoft.AlphaImageLoader (src='./images/home_pane.png', sizingMethod='scale');";
	change_button(cur_div);
}

function new_fade() {
	if (safe_to_fade) {		
		next_div = parseInt(cur_div) + 1;
		if (next_div > 4)
			next_div = 1;
		fade_cur = 100;
		fade_next = 0;
		
		cross_fade();		
	}
	else {
		clearInterval(fade_delay);
	}
}

function cross_fade() {
	if (fade_cur == 100) {		
		fade_duration = setInterval("cross_fade()", 100);		
	}
	if (fade_cur == 50)
		change_button(next_div);
	if (fade_cur > 0){	
		fade_cur -= 10;
		fade_next += 10;
		document.getElementById('procasts_home_pane' + cur_div).style.opacity = (fade_cur / 100);
		document.getElementById('procasts_home_pane' + cur_div).style.filter = 
			"alpha(opacity=" + fade_cur + ")" + "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='./images/home_pane.png', sizingMethod='scale');";
		document.getElementById('procasts_home_pane' + next_div).style.opacity = (fade_next / 100);
		document.getElementById('procasts_home_pane' + next_div).style.filter = 
			"alpha(opacity=" + fade_next + ")" + "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='./images/home_pane.png', sizingMethod='scale');";
	}
	else {
		cur_div = next_div;
		//change_button(cur_div);
		clearInterval(fade_duration);
	}
}



function addSearchProvider() { // part of 'add search engine' functionality for Firefox2/IE7
	try {
		window.external.AddSearchProvider('http://www.prolibraries.com.com/search.xml');
	}
	catch (e) {
		alert("Currently, the search provider function requires either Firefox 2 or Internet Explorer 7.");
		return;
	}
}



function f_over (label_id, input_id, is_button){
	change_style(input_id, 'border', '1px solid #1E5493');
	change_style(input_id, 'background', '#EFF3FF');
	change_style(label_id, 'text-decoration', 'underline');
	change_style(label_id, 'color', '#000000');
}

function f_out (label_id, input_id, is_button){
	change_style(input_id, 'border', '1px solid #333333');	
	change_style(input_id, 'background', '#FAFAFA');
	change_style(label_id, 'text-decoration', 'none');
	if (is_button)
		change_style(label_id, 'color', '#1E5493');
	else
		change_style(label_id, 'color', '#666666');
}

function f_over2 (label_id){
	change_style(label_id, 'border', '1px solid #87A3C9');
	change_style(label_id, 'background', '#EFF3FF');
	change_style(label_id, 'color', '#000000'); 
}

function f_out2 (label_id){
	change_style(label_id, 'border', '1px solid #FFFFFF');	
	change_style(label_id, 'background', '#FFFFFF');
	change_style(label_id, 'color', '#1E5493');
}

function f_over3 (button_id, wrapper_id, price_id){
	change_style(button_id, 'border', '1px solid #1E5493');
	change_style(button_id, 'background', '#EFF3FF');
	change_style(button_id, 'text-decoration', 'underline');
	change_style(button_id, 'color', '#000000'); 
	change_style(wrapper_id, 'border', '1px solid #1E5493');
	change_style(price_id, 'background', '#FFFFFF');
}

function f_out3 (button_id, wrapper_id, price_id){
	change_style(button_id, 'border', '1px solid #333333');	
	change_style(button_id, 'background', '#FAFAFA');
	change_style(button_id, 'text-decoration', 'none');
	change_style(button_id, 'color', '#1E5493');
	change_style(wrapper_id, 'border', '1px solid #FFFFFF');
	change_style(price_id, 'background', '#FFFFFF');
}

function styleChange (the_div, new_style_string) {	
	var new_style_array = new Array();
	var this_style_value = new Array();
	new_style_array = new_style_string.split(';');		
	for (cur_style in new_style_array) {
		this_style_value = new_style_array[cur_style].split(':');
		this_style_value[0] = this_style_value[0].replace(" ", "");
		this_style_value[1] = this_style_value[1].replace(" ", "");
		change_style(the_div, this_style_value[0], this_style_value[1]);
	}	
}

var verticalOpenDivBusy = 0;
var the_vdiv;
var speed;
var steps;
var start_height;
var cur_height;
var stop_height;
var verticalInterval;
var vincrement;

function verticalOpenDiv(the_vdiv1, speed1, steps1, start_height1, stop_height1){
	if (verticalOpenDivBusy == 0) {
		verticalOpenDivBusy = 1;		
		the_vdiv = getElement(the_vdiv1);
		speed = speed1;
		steps = steps1;
		start_height = start_height1;
		stop_height = stop_height1;
		if (the_vdiv.height == (stop_height + "px")){
			temp_height = start_height;
			start_height = stop_height;
			stop_height = temp_height;
		}
		cur_height = start_height;
		if (start_height < stop_height)
			vincrement = Math.round((stop_height - start_height) / steps);				
		else
			vincrement = Math.round((start_height - stop_height) / steps);		
		verticalInterval = setInterval("do_verticalOpenDiv ()", speed);		
	}	
}

function do_verticalOpenDiv () {
	if (cur_height != stop_height) {		
		if (start_height < stop_height) {			
			cur_height = parseInt(cur_height + vincrement);
			if (cur_height > stop_height)
				cur_height = stop_height;
		}
		else { 
			cur_height = parseInt(cur_height - vincrement);
			if (cur_height < stop_height)
				cur_height = stop_height;
		}		
		the_vdiv.height = parseInt(cur_height) + "px";
	}
	else {
		window.clearInterval(verticalInterval);
		verticalOpenDivBusy = 0;
	}		
}

function doSelectFilter(select_id, cur_addy){
	var current_select = document.getElementById(select_id).value;
	document.location=cur_addy+"&"+select_id+"="+current_select;
}

function doKeywordFilter(cur_addy){
	var current_keyword = document.getElementById('f_keyword').value;	
	document.location=cur_addy+"&f_keyword="+current_keyword;
}

function doGotoPage(select_id, cur_addy){
	var current_select = document.getElementById(select_id).value;
	document.location=cur_addy+"&page="+current_select;
}

function doMyContentFilter(cur_addy) {
	document.location=cur_addy+"&f_mycontent=1";	
}

var f_datestart;
var f_timestart;
var f_dateend;
var f_timeend;

function doDateTimeFilter(cur_addy){
	f_datestart = document.getElementById('f_datestart').value;
	f_timestart = document.getElementById('f_timestart').value;
	f_dateend = document.getElementById('f_dateend').value;
	f_timeend = document.getElementById('f_timeend').value;
	
	f_datestart = f_datestart.replace("/", "_");
	f_datestart = f_datestart.replace("/", "_");
	f_dateend = f_dateend.replace("/", "_");
	f_dateend = f_dateend.replace("/", "_");
	
	f_timestart = f_timestart.replace(":", "_");
	f_timestart = f_timestart.replace(" ", "M");
	f_timeend = f_timeend.replace(":", "_");
	f_timeend = f_timeend.replace(" ", "M");
		
	document.location=cur_addy+"&f_datestart="+f_datestart+"&f_timestart="+f_timestart+"&f_dateend="+f_dateend+"&f_timeend="+f_timeend;
}

function doDateFilter(cur_addy){
	localTime = new Date();	
	localOffset = localTime.getTimezoneOffset();		
	offset = (360 - localOffset) * 60;	
		
	var startDate = document.getElementById('startDate').value;
	var endDate = document.getElementById('endDate').value;
		
	var dateFilter = '';
		
	if (startDate != ''){		
		myDate = new Date(startDate);		
		myEpoch = (myDate.getTime() / 1000.0) + offset;		
		dateFilter += "&startDate=" + myEpoch;	
	}
	
	if (endDate != ''){
		myDate = new Date(endDate); 
		myEpoch = (myDate.getTime() / 1000.0) + offset;		
		dateFilter += "&endDate=" + myEpoch;
	}
	
	window.location=cur_addy+dateFilter;
}

function doDateTimeFilter2(cur_addy){
	localTime = new Date();	
	localOffset = localTime.getTimezoneOffset();		
	offset = (360 - localOffset) * 60;	
		
	var startDate = document.getElementById('startDate').value;
	var startTime = document.getElementById('startTime').value;	
	var endDate = document.getElementById('endDate').value;	
	var endTime = document.getElementById('endTime').value;
		
	var dateFilter = '';
		
	if (startDate != ''){		
		myDate = new Date(startDate + ' ' + startTime);		
		myEpoch = (myDate.getTime() / 1000.0) + offset;		
		dateFilter += "&startDateTime=" + myEpoch;	
	}
	
	if (endDate != ''){
		myDate = new Date(endDate + ' ' + endTime); 
		myEpoch = (myDate.getTime() / 1000.0) + offset;		
		dateFilter += "&endDateTime=" + myEpoch;
	}
	
	window.location=cur_addy+dateFilter;
}


var bring_focus_div;
var bring_focus_busy = 0;
var bring_focus_value = 0;
var bring_focus_interval;
var bring_focus_addition = 10;

function stop_focus(the_id) {
	window.clearInterval(bring_focus_interval);
	bring_focus_div.background = "#FFFFFF";
}

function bring_focus(the_id) {
	bring_focus_div = getElement(the_id);
	bring_focus_interval = setInterval("do_bring_focus()", 50);	
}

function do_bring_focus() {
	bring_focus_div.background = getTintedColor('87A3C9', bring_focus_value);
	bring_focus_value = bring_focus_value + bring_focus_addition;
	
	if (bring_focus_value >= 255)
		bring_focus_addition = -10;
	if (bring_focus_value <= 0)
		bring_focus_addition = 10;
}

function getTintedColor(color, v) {
	if (color.length >6) 
		color= color.substring(1,color.length)
	var rgb = parseInt(color, 16);
	var r = Math.abs(((rgb >> 16) & 0xFF)+v); if (r>255) r=r-(r-255);
	var g = Math.abs(((rgb >> 8) & 0xFF)+v); if (g>255) g=g-(g-255);
	var b = Math.abs((rgb & 0xFF)+v); if (b>255) b=b-(b-255);
	r = Number(r < 0 || isNaN(r)) ? 0 : ((r > 255) ? 255 : r).toString(16); if (r.length == 1) r = '0' + r;
	g = Number(g < 0 || isNaN(g)) ? 0 : ((g > 255) ? 255 : g).toString(16); if (g.length == 1) g = '0' + g;
	b = Number(b < 0 || isNaN(b)) ? 0 : ((b > 255) ? 255 : b).toString(16); if (b.length == 1) b = '0' + b;
	return "#" + r + g + b;
} 

var stopGotoSession = 0;

function addToCart(get_string) {
	stopGotoSession = 1;
	makeRequest('../library/components/shoppingcart_mini.php', get_string, 'shoppingcart_mini');
	setTimeout('stopGotoSession = 0;', 2000);
}

function addToCart2(get_string, price_div) {
  document.getElementById(price_div).onclick = "return false;";
	stopGotoSession = 1;
	ajax_q._in('../library/components/shoppingcart_mini.php', get_string, 'shoppingcart_mini');
	ajax_q._in('../library/components/added_to_cart.php', get_string, price_div);
	start_queue();
	setTimeout('stopGotoSession = 0;', 2000);
}

function addToCartVerify(get_string) {
	stopGotoSession = 1;
	window.location = get_string;	
}

function gotoSession(session_id) {	
	if (stopGotoSession == 0)
		window.location='?select=session&sessionID='+session_id;	
}

function gotoSessionLibrary(base, libname, session_id) {
	if (stopGotoSession == 0)
		window.location='http://www.'+base+'/'+libname+'/?select=session&sessionID='+session_id;
}

function gotoPublication(session_id) {	
	if (stopGotoSession == 0)
		window.location='?select=publication&publicationID='+session_id;
}

function gotoPublication2(identification) {	
	if (stopGotoSession == 0)
		window.location='?select=publication&identification='+identification;
}

function gotoConference(conference_id) {
	if (stopGotoSession == 0)
		window.location='?select=sessionlist&f_conference='+conference_id;
}

function gotoResource(conference_id, resource_id) { // unused?
	if (stopGotoSession == 0)
		window.location='?select=sessionlist&f_conference='+conference_id+'&f_resource='+resource_id;
}

function gotoPackage(conference_id, package_id) {	
	if (stopGotoSession == 0)
		window.location='?select=sessionlist&f_conference='+conference_id+'&f_package='+package_id;
}

function gotoPackage2(conference_id, package_id) {	
	if (stopGotoSession == 0)
		window.location='?select=sessionlist&conferenceID='+conference_id+'&packageID='+package_id;
}

function gotoSessionProlibraries(session_id, libname) {		
	if (stopGotoSession == 0){
		if (libname == "procasts")
			window.location='?select=session&sessionID='+session_id;
		else
			window.location='http://www.prolibraries.com/'+libname+'/?select=session&sessionID='+session_id;	
		
	}
}

function gotoSessionOnlineCELibrary(session_id, libname) {
	if (stopGotoSession == 0){
		if (libname == "procasts")
			window.location='?select=session&sessionID='+session_id;
		else
			window.location='http://www.onlinecelibrary.com/'+libname+'/?select=session&sessionID='+session_id;
		
	}
}

function gotoSessionCPA(session_id, libname) {		
	if (stopGotoSession == 0){
		if (libname == "procasts")
			window.location='?select=session&sessionID='+session_id;
		else
			window.location='http://www.aicpaconferencematerials.com/'+libname+'/?select=session&sessionID='+session_id;	
		
	}
}

function viewShoppingCart() {
	stopGotoSession = 1;
	window.location='?select=shoppingcart';
}

function gotoSession2(session_id) {	
	if (stopGotoSession == 0)
		window.location='?select=procasts_session&sessionID='+session_id;	
}

// http://dynamic-tools.net/toolbox/isMouseLeaveOrEnter/
function isMouseLeaveOrEnter(e, handler) {		
	var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;
	while (reltg && reltg != handler) reltg = reltg.parentNode;
	return (reltg != handler);
}

function toggleCheckbox(the_div) {
	var the_checkbox = getElementBase(the_div);
	
	if (the_checkbox.checked == false)
		the_checkbox.checked = true;
	else
		the_checkbox.checked = false;
	
}

function forum_add_reply(){
	styleChange('floatOverlayID', 'display: block;');
	getElementBase('the_entire_body').scroll = "no";	
}

function forum_populate_sessionlist(libname){
	//getElementBase('add_topic_session').disabled = "";
	conferenceID = getElementValue('add_topic_session_conf');
	get_string = "?libname=" + libname + "&conferenceID=" + conferenceID;
	makeRequest('../library/components/get_session_selectlist.php', get_string, 'forum_session_select_list');
}

function cereportPopulateConferenceList(){
	getElementBase('cereportSession').disabled = true;
	getElementBase('cereportConference').disabled = true;
	getElementBase('cereportSession').selectedIndex = 0;
	libname = getElementValue('cereportLibname');
	get_string = "?libname=" + libname;
  ajax_q._in('../library/components/cereportSelectLibname.php', get_string, 'cereportSelectConferenceAjax');
	ajax_q._in('../library/components/cereportSelectSpeaker.php', get_string, 'cereportSelectSpeakerAjax');
	start_queue();
	getElementBase('cereportConference').disabled = false;
  getElementBase('cereportSpeaker').disabled = false;
}

function cereportPopulateConferenceList_ocl(){
	getElementBase('cereportSession').disabled = true;
	getElementBase('cereportConference').disabled = true;
	getElementBase('cereportSession').selectedIndex = 0;
	libname = getElementValue('cereportLibname');
	get_string = "?libname=" + libname;
  ajax_q._in('../library/components/cereportSelectLibname.php', get_string, 'cereportSelectConferenceAjax');
	start_queue();
	getElementBase('cereportConference').disabled = false;
}

function cereportPopulateSessionList(){
	getElementBase('cereportSession').disabled = true;
	getElementBase('cereportSession').selectedIndex = 0;
	libname = getElementValue('cereportLibname');
	conferenceID = getElementValue('cereportConference');
	get_string = "?libname=" + libname + "&conferenceID=" + conferenceID;
  ajax_q._in('../library/components/cereportSelectConference.php', get_string, 'cereportSelectSessionAjax');
  ajax_q._in('../library/components/cereportSelectSpeaker.php', get_string, 'cereportSelectSpeakerAjax');
  start_queue();
	getElementBase('cereportSession').disabled = false;
  getElementBase('cereportSpeaker').disabled = false;
}

function cereportPopulateSessionList_ocl(){
	getElementBase('cereportSession').disabled = true;
	getElementBase('cereportSession').selectedIndex = 0;
	libname = getElementValue('cereportLibname');
	conferenceID = getElementValue('cereportConference');
	get_string = "?libname=" + libname + "&conferenceID=" + conferenceID;
  ajax_q._in('../library/components/cereportSelectConference.php', get_string, 'cereportSelectSessionAjax');
  start_queue();
	getElementBase('cereportSession').disabled = false;
}

function cereportPopulateSpeakerList(){
	libname = getElementValue('cereportLibname');
	conferenceID = getElementValue('cereportConference');
  sessionID = getElementValue('cereportSession');
	get_string = "?libname=" + libname + "&conferenceID=" + conferenceID + "&sessionID=" + sessionID;
  ajax_q._in('../library/components/cereportSelectSpeaker.php', get_string, 'cereportSelectSpeakerAjax');
  start_queue();
}


function MM_openBrWindow(theURL,winName,features) { // cathcartinstitute/home.php only
	nw = window.open(theURL, winName, 'width=400,height=350,dependent=yes,titlebar=no,toolbar=no,location=no,directories=no,status=no,scrollbar=yes,resizable=no,copyhistory=no,menubar=no');
	nw.focus();
}

	

function select_library(){
	libname = getElementValue('select_library');
	goto_address = "http://www.prolibraries.com/" + libname + "/";
	window.location = goto_address;
}

function select_library_cf(){
	libname = getElementValue('select_library');
	goto_address = "http://www.onlinecelibrary.com/" + libname + "/";
	window.location = goto_address;
}

function select_library_aicpa(){
	libname = getElementValue('select_library');
	goto_address = "http://www.aicpaconferencematerials.com/" + libname + "/";
	window.location = goto_address;
}

function selectLibrary(location){
	libname = getElementValue('select_library');
	goto_address = location + libname + "/";
	window.location = goto_address;
}

function speaker_disclosure(theURL) { //v2.0
	open_popup_window(theURL, 'Speaker Disclosure', 400, 300, {'left':100, 'top':100, 'scrollbars':'yes'});
}

function numbersonly(myfield, e, dec) {
  var key;
  var keychar;

  if (window.event)
    key = window.event.keyCode;
  else if (e)
    key = e.which;
  else
    return true;
  keychar = String.fromCharCode(key);

  // control keys
  if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
    return true;

  // numbers
  else if ((("0123456789").indexOf(keychar) > -1))
    return true;

  // decimal point jump
  else if (dec && (keychar == ".")) {
    myfield.form.elements[dec].focus();
    return false;
  } else
    return false;
}

function showOnlySelectedDivOption(selectName, divList){
	divArray = divList.split(',');
	selected_div = getElementValue(selectName);
	
	for (i = 0; i < divArray.length; i++){
		document.getElementById(divArray[i]).style.display='none';	
	}
	
	if (selected_div == 'showall'){
		for (i = 0; i < divArray.length; i++){
			document.getElementById(divArray[i]).style.display = '';	 
		}
	}
	else
		document.getElementById(selected_div).style.display = '';
}

function selectExhibitor() {
	exhibitorID = getElementValue('select_exhibitor');
	goto_address = "?select=exhibitor&exhibitorID=" + exhibitorID;
	window.location = goto_address;
}

function searchJobs(searchString){
	searchString = '?select=jobs';
	var jsearch = document.getElementById('jsearch').value;
	var category = document.getElementById('category').value;	
	var city	= document.getElementById('city').value;
	var state	= document.getElementById('state').value;
	var zipcode	= document.getElementById('zipcode').value;
	var radius	= document.getElementById('radius').value;
	searchString += ((jsearch != '') && (jsearch != 'Enter Keywords')) ?
		'&jsearch=' + jsearch.replace( /\s/g, "+" ) : '';
	searchString += (category != 'all') ?
		'&cid=' + category : '';
	searchString += ((city != '') && (city != 'Enter City')) ?
		'&city=' + city.replace( /\s/g, "+" ) : '';
	searchString += (state != 'all') ?
		'&state=' + state : '';
	searchString += ((zipcode != '') && (zipcode != 'Zip Code')) ?
		'&zip=' + zipcode : '';
	searchString += (radius != 'all') ?
		'&rad=' + radius : '';
	window.location = searchString;
}

function updateCreditLimit(idx) {

  var newCredits = document.getElementById('currentCredits');
  var maxCredits = document.getElementById('maxCredits');

  newCreditsNum = parseInt(newCredits.value);
  maxCreditsNum = parseInt(maxCredits.value);

  if(newCreditsNum <= maxCreditsNum) {

    searchStr = "?select=myaccount&mygroupcredits=1&groupIdx=" + idx;
    searchStr += "&updateCredits=" + newCredits.value;
   	window.location = searchStr;
  }
  else {
    warnStr = "<b>Warning: The maximum number of applicable credits is " + maxCredits.value + "</b>";
    document.getElementById('errorTag').innerHTML = warnStr;
  }
}

function toggleLightBox(box_id, page, get_string){
  getElement('lightBoxContent').left = ((getElementBase('topBar_prolibraries_home_link').offsetLeft) + 96) + 'px';
  getElement('lightBoxBG').height = (getElementBase('footer').offsetTop + 25) + 'px';
  if (getElement(box_id).display == 'none'){
    makeRequest('../library/components/' + page, get_string, box_id);
    getElement('lightBoxBG').display = 'block';
    getElement('lightBoxContent').display = 'block';
  }
  else if (getElement(box_id).display == 'block'){
    makeRequest('../library/pages/blank.php', '?', box_id);
    getElement('lightBoxContent').display = 'none';
    getElement('lightBoxBG').display = 'none';
  }
}


var currentSecond = 1000;
var countDownTargetURL;
var countDownFrom;

function countDownRedirect(targetURL, cntDownFrom){
  countDownTargetURL = targetURL;
  countDownFrom = cntDownFrom;
  doCountDownRedirect();
}

function doCountDownRedirect(){
  if (currentSecond == 1000)
    currentSecond = countDownFrom;
  if (currentSecond != 1){
    currentSecond -= 1;
  }
  else{
    window.location = countDownTargetURL;
    return;
  }
  setTimeout("doCountDownRedirect()",1000);
}

var current_libraryID;
var current_conferenceID;
var current_sessionID;

function PopulateSelectLists(libname, conferenceID, sessionID, speakerID) {

  if(libname) {
    current_libraryID = libname;
    get_string = "?libname=" + libname;
    ajax_q._in('../library/components/show_library_selectlist.php', get_string, 'library_selectlist');
  }

  if(conferenceID) {
    current_conferenceID = conferenceID;
	  get_string = "?libname=" + libname + "&conferenceID=" + conferenceID;
	  ajax_q._in('../library/components/show_conference_selectlist.php', get_string, 'conference_selectlist');
  }

	if(sessionID) {
	  current_sessionID = sessionID;
	  get_string = "?libname=" + libname + "&conferenceID=" + conferenceID + "&sessionID=" + sessionID;
	  ajax_q._in('../library/components/show_session_selectlist.php', get_string, 'session_selectlist');
  }

  if(speakerID) {
    current_speakerID = speakerID;
    get_string = "?libname=" + libname + "&conferenceID=" + conferenceID + "&sessionID=" + sessionID + "&speakerID=" + speakerID;
    ajax_q._in('../library/components/show_speaker_checkbox.php', get_string, 'speaker_checkbox');
  }

  setTimeout("start_queue();", 100);
}

function PopulateConferenceSelectList(ObjValue) {
  current_libraryID = ObjValue;

  if(ObjValue) {
    get_string = "?libname=" + current_libraryID;
  	ajax_q._in('../library/components/show_conference_selectlist.php', get_string, 'conference_selectlist');
  }

  PopulateSessionSelectList(0);
}

function PopulateSessionSelectList(ObjValue) {
  current_conferenceID = ObjValue;

  if(ObjValue) {
    get_string = "?libname=" + current_libraryID + "&conferenceID=" + current_conferenceID;
    ajax_q._in('../library/components/show_session_selectlist.php', get_string, 'session_selectlist');
  }

  PopulateSpeakerCheckBox(0);
}

function PopulateSpeakerCheckBox(ObjValue) {
  current_sessionID = ObjValue;

  if(ObjValue) {
    get_string = "?libname=" + current_libraryID + "&conferenceID=" + current_conferenceID + "&sessionID=" + current_sessionID;
    ajax_q._in('../library/components/show_speaker_checkbox.php', get_string, 'speaker_checkbox');
  }

  setTimeout("start_queue();", 50);
}

function ValidateForm() {
  if(current_libraryID && current_conferenceID && current_sessionID) {
    getElementBase('submit').click();
  }
}

function myBriefcaseChooseLibrary() {
  document.getElementById('select_conference').innerHTML='';
  document.getElementsByName('content_list').innerHTML='<div style="font-weight: bold; text-align: center;">Loading Association Information...</div>';
  document.libname_form.submit();
}

function myBriefcaseChooseConference() {
  document.getElementsByName('content_list').innerHTML='<div style="font-weight: bold; text-align: center;">Loading Conference Information...</div>';
  document.libname_form.submit();
}

function myBriefcaseUpdateSessions(libname, conferenceID) {
  var resourceID = 0;

  var oResourceList = document.getElementById('resourceFilter');

  if(oResourceList) resourceID = oResourceList.value;

  $.get("../library/components/my_briefcase_sessions.php",
  { view: "my", libname: libname, conferenceID: conferenceID },
  function(responseData) {
    $('#list_my_sessions').html(responseData);
    $('#view_my_session_count').html(' ('+$('#my_session_count').html()+')');
  });

  $.get("../library/components/my_briefcase_sessions.php",
  { view: "all", libname: libname, conferenceID: conferenceID, resourceID: resourceID },
  function(responseData) {
    $('#list_all_sessions').html(responseData);
    $('#view_all_session_count').html(' ('+$('#all_session_count').html()+')');
  });
}

function myBriefcaseAddScheduleButton(libname, conferenceID, sessionID) {
    stopGotoSession=1;

    $.get("../library/components/my_briefcase_sessions.php",
      { action: "add", libname: libname, conferenceID: conferenceID, sessionID: sessionID},
      function(responseData) {
        $('a#add_to_schedule_'+libname+'_'+sessionID+' img').attr('src', '../library/images/buttons/button_view_schedule.gif');
        $("a#add_to_schedule_"+libname+"_"+sessionID).attr("onMouseOver", "$('a#add_to_schedule_"+libname+"_"+sessionID+" img').attr('src', '../library/images/buttons/button_view_schedule_over.gif');");
        $("a#add_to_schedule_"+libname+"_"+sessionID).attr("onMouseOut", "$('a#add_to_schedule_"+libname+"_"+sessionID+" img').attr('src', '../library/images/buttons/button_view_schedule.gif');");
        $("a#add_to_schedule_"+libname+"_"+sessionID).attr("onClick", "stopGotoSession=1; location.href='?select=my_briefcase&libname="+libname+"&conferenceID="+conferenceID+"&showMySchedule=1'");
      });

    setTimeout('stopGotoSession = 0;', 2000);
}

function emailFormSubmit(sSchedule) {
  var name = $("input#recipient").val();
  var email = $("input#subject").val();
  var phone = $("input#message").val();

  alert(name+''+email+''+phone+'');
}

function emailFormShow(sSchedule) {
  $(sSchedule).fadeIn(200).show();
}

function emailFormHide(sSchedule) {
  oSchedule = document.getElementById(sSchedule);
  oSchedule.style.display = "none";
}


function answerClick(libname, questionID, answerID) {
  //clear all answer spans...
  var questionName = 'question' + questionID;
  var answerElements = document.getElementsByName(questionName);

  for(var i = 0; i < answerElements.length; i++) {
    var answerElementID = 'wrongAnsSpan_' + questionID + '_' + answerElements[i].value;
    var answerElement = document.getElementById(answerElementID);
    answerElement.innerHTML = '&nbsp;';
  }

  //do the ajax request...
  var getString = '?libname=' + libname;
  getString += '&questionID=' + questionID;
  getString += '&answerID=' + answerID;

  var spanID = 'wrongAnsSpan_' + questionID + '_' + answerID;
  ajax_q._in('../library/components/ajaxWrongAnswer.php', getString, spanID);

  start_queue();
}

function review_clearUploader(){
  var uploader = document.getElementById('review_session');
  uploader.innerHTML = "<div style=\"width: 380px; font-size: 16px; text-align: center; font-weight: bold; color: #003399;\"><br /><br /><br /><br /><br />Now select your <br /><br />session from the list.</div>";
}


function multiChangeStyle(idList, exception, style, value){
  var idList_array = idList.split(";");
  for (id in idList_array){
    if ((idList_array[id] != '') && (idList_array[id] != exception)){
      if (style == 'border')
        document.getElementById(idList_array[id]).style.border = value;
      if (style == 'color')
        document.getElementById(idList_array[id]).style.color = value;
      if (style == 'background')
        document.getElementById(idList_array[id]).style.background = value;
    }
  }
}


var flashobject;
var reply;
var newElement = document.createElement("div");
var fdiv = document.createElement("div");
var progressdiv = document.createElement("div");
var statussdiv = document.createElement("div");
var file;
var status  = "";
var review_sessionID;
var review_libname;
var review_replace = "";

function MultiPowUpload_onSelect(){

  flashobject = document.getElementById('EmbedMultiPowUpload');
  if (flashobject == null){
    flashobject = document.getElementById('MultiPowUpload');
  }

  flashobject.style.height = '1px';
  document.getElementById('filelist').style.lineHeight = '17px';
  document.getElementById('filelist').style.height = '50px';

  flashobject.uploadAll();

}

function MultiPowUpload_onError(type, index, error){
  var file = MultiPowUpload.getFile(MultiPowUpload.fileList()[index].id);
  updateStatus(file,error);
}

function MultiPowUpload_onStart(type, index){
  addFile(flashobject.fileList()[index].id);
}

function MultiPowUpload_onProgress(type, index, fileBytesLoaded, fileBytesLength, totalBytesLoaded, totalBytesLength){
  updateFileInfo(flashobject.fileList()[index].id);
}
/*
function MultiPowUpload_onComplete(type, index, serverResponse){
  document.getElementById('review_current_no_files').style.display = 'none';
  updateFileInfo(flashobject.fileList()[index].id);

  reply = getElementBase("multipleUploadFileList");
  //reply.value = serverResponse;

  newElement.id = "multipleUploadFileList_1";
  newElement.innerHTML = serverResponse;
  reply.appendChild(newElement);

  review_sessionID = document.getElementById('review_sessionID').value;
  review_libname = document.getElementById('review_libname').value;

  replaceText = parseInt(document.getElementById('review_totalfiles').value);
  if($('#newFile').attr('checked')) {
    var file_count = $(".review_session_row.selected .file_count");
    var count = parseInt(file_count.html());

    file_count.html(count+1);
  }

  accessID = document.getElementById('accessID').value;

  review_replace = "";
  if (document.getElementById('replaceFileButton').checked == true){
    review_replace = '&replace=' + document.getElementById('review_replacefilelist').value;
  }

  setTimeout('makeRequest(\'../library/components/review_ajax.php\', \'?action=session&a=' + accessID + '&libname=' + review_libname + '&id=' + review_sessionID + review_replace + '\', \'review_session\');', 2000);
}
*/

function MultiPowUpload_onComplete(type, index, serverResponse){
  $('#review_current_no_files').hide();
  updateFileInfo(flashobject.fileList()[index].id);

  reply = getElementBase("multipleUploadFileList");
  //reply.value = serverResponse;

  newElement.id = "multipleUploadFileList_1";
  newElement.innerHTML = serverResponse;
  reply.appendChild(newElement);

  if($('#newFile').attr('checked')) {
    var file_count = $(".review_session_row.selected .file_count");
    var count = parseInt(file_count.html());

    file_count.html(count+1);
  }

  var sessionID = $('#review_sessionID').val();
  var libname = $('#review_libname').val();
  var accessID = $('#accessID').val();

  if (!$("#replaceFileButton option:selected").length) {
    replace = $('#review_replacefilelist').val();
  }

  $.get("../library/components/review_ajax.php",
  { action: "session", a: accessID, libname: libname, id: sessionID, replace: replace },
  function(data) {
    updateSessions(libname, sessionID, accessID);
  });
}

function addFile(fileID){

  if(document.getElementById(fileID) == null){
  	fdiv.innerHTML = flashobject.getFile(fileID).name;
  	fdiv.id = fileID;
  	fdiv.className = "fileInfo current";
  	fdiv.style.width = "348px";

  	progressdiv.id = "progressbar_"+fileID;
  	fdiv.appendChild(progressdiv);
  	progressdiv.className = "progressBar";

  	statussdiv.id = "status_" + fileID;
  	fdiv.appendChild(statussdiv);
  	document.getElementById("filelist").appendChild(fdiv);
  }
}

function updateFileInfo(fileID){
  fdiv = document.getElementById(fileID);
  if(fdiv != null){
    file = flashobject.getFile(fileID);
  	updateProgressBar(file);
  	updateStatus(file);
  }
}

function updateProgressBar(file){
  document.getElementById("progressbar_"+file.id).style.width = file.percentDone + "%";
}

function updateStatus(file, errorMessage){
  switch(file.status){
  	case 0:
  		status = "Ready for upload";
  		break;
  	case 1:
  		status = "Uploaded: " + Math.round(file.percentDone) + "%";
  		break;
  	case 2:
  		status = "Upload complete.";
  		document.getElementById(file.id).className = "fileInfo complete";
  		break;
  	case 3:
  		status = "Upload cancelled";
  		break;
  	case 4:
  		document.getElementById(file.id).className = "fileInfo error";
  		status = "Error occured: " + errorMessage;
  		break;
  }
  document.getElementById("status_" + file.id).innerHTML = status;
}

function popupfs(url, target) {
  if(!target) target = '_blank';
  var width = $(window).width();
  var height = $(window).height();

  newwin=window.open(url,target, 'width='+width+', height='+height+', top=0, left=0, fullscreen=yes, scrollbars=yes, resizable=yes');
  if (window.focus) { newwin.focus() }
  return false;
}

function popup(url) {
  var width = $(window).width();
  var height = $(window).height();

  newwin=window.open(url,'_blank', 'width='+width+', height='+height+', top=0, left=0, fullscreen=yes, scrollbars=yes, resizable=yes');
  if (window.focus) { newwin.focus() }
  return false;
}

function speakerPosUpDown(upDown, IS_CF, IS_CPA, libname, conferenceID, sessionID, speakerID, activeConferenceLink, linkColor, showSpeakerDisclosure) {
  var divID;

  var postString = 'upDown=' + (((upDown != '') && (upDown != '0')) ? 1 : 0);
  postString += '&IS_CF=' + (((IS_CF != '') && (IS_CF != '0')) ? 1 : 0);
  postString += '&IS_CPA=' + (((IS_CPA != '') && (IS_CPA != '0')) ? 1 : 0);
  postString += '&libname=' + libname;
  postString += '&conferenceID=' + (((conferenceID != '') && (conferenceID != '0')) ? conferenceID : 0);
  postString += '&sessionID=' + (((sessionID != '') && (sessionID != '0')) ? sessionID : 0);
  postString += '&speakerID=' + (((speakerID != '') && (speakerID != '0')) ? speakerID : 0);
  postString += '&activeConferenceLink=' + (((activeConferenceLink != '') && (activeConferenceLink != '0')) ? 1 : 0);
  postString += '&linkColor=' + (((linkColor != '') && (linkColor != '0')) ? linkColor : 0);
  postString += '&showSpeakerDisclosure=' + (((showSpeakerDisclosure != '') && (showSpeakerDisclosure != '0')) ? 1 : 0);

  var getString = '?ajaxFunction=speakerPosUpDown';
  $.ajax({
    type: 'POST',
    url: '../library/lib/sessions_class_ajax.php' + getString,
    data: postString,
    success: function(data) {
      if(data.success) {


        divID0 = 'session_' + sessionID + '_speakerID_' + data.speakerID0;
        $('#' + divID0).html(data.speakerID1html);

        divID1 = 'session_' + sessionID + '_speakerID_' + data.speakerID1;
        $('#' + divID1).html(data.speakerID0html);

        $('#' + divID0).attr('id', 'tmp_yea_tmp_ok_tmp_well_yea');
        $('#' + divID1).attr('id', divID0);
        $('#tmp_yea_tmp_ok_tmp_well_yea').attr('id', divID1);

/*
        divID = 'session_' + sessionID + '_speakerID_' + data.speakerID0;
        alert(divID);
        alert(data.speakerID0html);

        divID = 'session_' + sessionID + '_speakerID_' + data.speakerID1;
        alert(divID);
        alert(data.speakerID1html);
*/
        //alert(data.statusMsg);
      }
      else {
        alert('Error: the ajax call failed.');
      }
    },
    dataType: 'json'
  });

/*
  var getString = '';
  var targetID = 'session_' + sessionID + '_speakerID_' + speakerID;
  $.post('../library/lib/sessions_class_ajax.php' + getString, function(data) {
    $('#targetID').html(data);
  });
*/


}


