// JavaScript Document

var msg_arr = Array();
msg_arr['default'] = '';
msg_arr['mOver_Active'] = '<img src="http://adobeeseminars.com.au/images/sessions/icon_cart.gif" align="left"/>Click to add this live eSeminar to your cart.';
msg_arr['mOver_OnDemand'] = '<img src="http://adobeeseminars.com.au/images/sessions/icon_newWindow.gif" align="left"/>Click to view this recorded eSeminar right now in a new window.';
msg_arr['loading'] = 'Working on your request...';
msg_arr['add'] = 'This session has been added to your cart.  Select more live sessions or register to attend the sessions in your cart.';
msg_arr['add_exists_already'] = 'This session is already in your cart.';
msg_arr['delete'] = 'This session has been deleted from your cart.';
msg_arr['clear'] = 'Your cart has been cleared.';
msg_arr['none'] = '';
msg_arr['noSessions'] = 'Sorry, no sessions were found. Please select other combinations from the dropdowns above.';

function ID(id) { return window.document.getElementById(id);}

function roll(obj) {
	if(obj.src.search(/_out\./) > 0){
		obj.src = obj.src.replace(/_out./g, "_over.");
	}else{
		obj.src = obj.src.replace(/_over./g, "_out.");
	}
}

function updateDisplay(id,view){
	if(view=='block'||view=='none'){
		ID(id).style.display = view;
		if(id=='rego'){
			if(view == 'block'){
				document.forms['option'].skill.style.visibility="hidden";
				document.forms['option'].audience.style.visibility="hidden";
				document.forms['option'].product.style.visibility="hidden";
				document.forms['option'].speaker.style.visibility="hidden";
				document.forms['option'].type.style.visibility="hidden";
				var id = 'rego_form_cont';
				var url = '/ajax/rego';
				new Ajax.Updater(id,url,{asynchronous:true});
			}else{
				document.forms['option'].skill.style.visibility="visible";
				document.forms['option'].audience.style.visibility="visible";
				document.forms['option'].product.style.visibility="visible";
				document.forms['option'].speaker.style.visibility="visible";
				document.forms['option'].type.style.visibility="visible";
			}
		}
	}else{
		ID(id).style.visibility = view;
	}
}

function updateMsgBox(msg,id){
	if(id){
		updateEntryBG(msg,id);
	}
	if(!msg){msg='default';}
	ID('msg_box').innerHTML = msg_arr[msg];
	
}
function updateEntryBG(msg,id){
		if(msg){
			colorFade('session_'+id,'background','52585b','62676a',5,30)
		}else{
			colorFade('session_'+id,'background','62676a','52585b',25,30)
		}
}

function onSessionClick(sid,status,surl,trackstring){
	if(status == 'Active'){
		updateMsgBox('loading');
		var id = "cart_cont";
		var url = "/ajax/cart/add/"+sid;
		new Ajax.Updater(id,url,{asynchronous:true});
	}else{
		window.open(surl,"onDemand");
	}
	pageTracker._trackPageview("/sessions/sessionsClicked/"+trackstring);
}

function onFormSubmit(id,url){
	var url = "/ajax/"+url;
		new Ajax.Request(url,{
				parameters: $('regoForm').serialize(true),
				onSuccess: function(transport){      
					var response = transport.responseText || "no response text";
					ID(id).innerHTML =  response;
   				 },
   				 onFailure: function(){ 
				 	alert('An Asynchronous Error Occured.  Please try again.') }
			});
}
function onCartDelete(sid){
		updateMsgBox('loading');
	var id = "cart_cont";
	var url = "/ajax/cart/delete/"+sid;
	new Ajax.Updater(id,url,{asynchronous:true});
}
function onCartClear(){
		updateMsgBox('loading');
	var id = "cart_cont";
	var url = "/ajax/cart/clear/none";
	new Ajax.Updater(id,url,{asynchronous:true});
}
function loadCart(type){
	var id = "cart_cont";
	var url = "/ajax/cart/none/none";
	new Ajax.Updater(id,url,{asynchronous:true});
	if(type){getEntries('type')}
}

function getEntries(opt, opt_with_type) {
	updateMsgBox('loading');
	if(opt == 'live' || opt == 'ondemand' || opt == ''){
		var saveStr = opt;
		updateTabs(opt);
		if(opt_with_type){
			if(opt == ''){opt='view';}
			var saveStr = opt+"/type/"+ID("main_type").options[ID("main_type").selectedIndex].text;
		}
	}else{
		if(ID("main_"+opt).options[ID("main_"+opt).selectedIndex].text == "--SELECT--"){
			var saveStr = "view/"+opt+"/All";
			ID("main_"+opt).remove(ID("main_"+opt).selectedIndex);
		}else{
			var saveStr = "view/"+opt+"/"+ID("main_"+opt).options[ID("main_"+opt).selectedIndex].text;
		}
	}
	var id = "content";
	var url = "/ajax/"+saveStr;
	new Ajax.Updater(id,url,{asynchronous:true});
	pageTracker._trackPageview("/sessions/search/"+opt+"/"+ID("main_"+opt).options[ID("main_"+opt).selectedIndex].text)
} 

function updateCounter(){
	ID('entry_count').innerHTML = " Search resulted in "+ID('hidden_count_input').value + " eSeminars";
	if(ID('hidden_count_input').value == 0){
		updateMsgBox('noSessions');
	}else{
		updateMsgBox();
	}
}

function updateTabs(opt){
	var tabs = ID("main_tabs");
	switch(opt){
		case "":
			tabs.childNodes[0].src = tabs.childNodes[0].src.replace(/_over./, "_selected.");
			tabs.childNodes[1].src = tabs.childNodes[1].src.replace(/_selected./, "_out.");
			tabs.childNodes[2].src = tabs.childNodes[2].src.replace(/_selected./, "_out.");
			break;
		case "live":
			tabs.childNodes[0].src = tabs.childNodes[0].src.replace(/_selected./, "_out.");
			tabs.childNodes[1].src = tabs.childNodes[1].src.replace(/_over./, "_selected.");
			tabs.childNodes[1].src = tabs.childNodes[1].src.replace(/_out./, "_selected.");
			tabs.childNodes[2].src = tabs.childNodes[2].src.replace(/_selected./, "_out.");
			break;
		case "ondemand":
			tabs.childNodes[0].src = tabs.childNodes[0].src.replace(/_selected./, "_out.");
			tabs.childNodes[1].src = tabs.childNodes[1].src.replace(/_selected./, "_out.");
			tabs.childNodes[2].src = tabs.childNodes[2].src.replace(/_over./, "_selected.");
			tabs.childNodes[2].src = tabs.childNodes[2].src.replace(/_out./, "_selected.");
			break;
	}
}
 
 
 