// Global Variable Declarations
var isLoaded = false;

// Global Functions

// Adds appropriate targets to anchor tags.
function processAnchorTargets()
{
	if (!document.getElementsByTagName) return;

	var anchors = document.getElementsByTagName("a");
	
	for (var i=0; i < anchors.length; i++)
	{
		var anchor = anchors[i];
		
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "popup")
		{
			anchor.target = "_blank";
		}
	}
}

// Submits form[0]
function submitForm()
{
	document.forms[0].submit();
	return true;
}

// Submit Target Form
function submitTargetForm(in_formIndex)
{
	document.forms[in_formIndex].submit();
	return true;
}


// Image Swaps
function imageSwap(in_Name, in_State)
{
	if (!isLoaded)
	{
		return true;
	}
	document.images[in_Name].src = eval(in_Name + "_" + in_State + ".src");
}

  
// Window Openders
function popWindow(in_target, in_WindowParameters)
{
	//windowParameters are very browser dependent.  Be sure to test in all browswers when
	//changing window parameters.

	//For instance for Both IE and Netscape browsers to absolutely position a window properly 2 sets
	// of dimensions should be included example: screenX=0,screenY=0,left=0,top=0
	//To set the height and width of the windows example: width=625,height=400
	//A Good PopupWindow in all browsers with no toolbar, no scrollbar, and not resizable.
	//windowParameters = "scrollbars=no,width=625,height=400";
	
	if ( in_WindowParameters.length == 0 )
	{
		in_WindowParameters = "resizable,dependent,toolbar,scrollbars,location,status,menubar";
	}
	
	popupWin = window.open(in_target,'PopupWindow',in_WindowParameters);
}

function speakingTopicPopup(in_target)
{
	speakingTopicWin = window.open(in_target,'SpeakingTopicWindow','width=520,height=500,location=no,menubar=no,resizable=yes,status=no,toolbar=no,scrollbars=yes');
	return false;
}

// Global Initialization

function blurInputs()
{
	if (!document.getElementsByTagName) return;

	var inputs = document.getElementsByTagName("input");
	
	for (var i=0; i < inputs.length; i++)
	{
		var inp = inputs[i];
		inp.blur();
	}
	
}

function globalInit()
{
    //window.onresize = function () {location.reload(); };
	processAnchorTargets();
	
	var languageCode = "";

	find_a_speaker_search_off = new Image;
	find_a_speaker_search_off.src = appRoot + "images/common/find_a_speaker_search_off" + languageCode + ".jpg";
    find_a_speaker_search_roll = new Image;
	find_a_speaker_search_roll.src = appRoot + "images/common/find_a_speaker_search_on" + languageCode + ".jpg";

	top_menu_speakers_off = new Image;
	top_menu_speakers_off.src = appRoot + "images/common/top_menu_speakers_off" + languageCode + ".gif";
	top_menu_speakers_roll = new Image;
	top_menu_speakers_roll.src = appRoot + "images/common/top_menu_speakers_on" + languageCode + ".gif";

	top_menu_about_us_off = new Image;
	top_menu_about_us_off.src = appRoot + "images/common/top_menu_about_us_off" + languageCode + ".gif";
	top_menu_about_us_roll = new Image;
	top_menu_about_us_roll.src = appRoot + "images/common/top_menu_about_us_on" + languageCode + ".gif";

	top_menu_faq_off = new Image;
	top_menu_faq_off.src = appRoot + "images/common/top_menu_faq_off" + languageCode + ".gif";
	top_menu_faq_roll = new Image;
	top_menu_faq_roll.src = appRoot + "images/common/top_menu_faq_on" + languageCode + ".gif";

	top_menu_contact_us_off = new Image;
	top_menu_contact_us_off.src = appRoot + "images/common/top_menu_contact_us_off" + languageCode + ".gif";
	top_menu_contact_us_roll = new Image;
	top_menu_contact_us_roll.src = appRoot + "images/common/top_menu_contact_us_on" + languageCode + ".gif";

	top_content_more_info_off = new Image;
	top_content_more_info_off.src = appRoot + "images/home/top_content_more_info_off" + languageCode + ".jpg";
	top_content_more_info_roll = new Image;
	top_content_more_info_roll.src = appRoot + "images/home/top_content_more_info_on" + languageCode + ".jpg";

	bottom_content_view_all_off = new Image;
	bottom_content_view_all_off.src = appRoot + "images/home/bottom_content_view_all_off" + languageCode + ".gif";
	bottom_content_view_all_roll = new Image;
	bottom_content_view_all_roll.src = appRoot + "images/home/bottom_content_view_all_on" + languageCode + ".gif";

	bottom_content_learn_more1_off = new Image;
	bottom_content_learn_more1_off.src = appRoot + "images/home/bottom_content_learn_more_off" + languageCode + ".gif";
	bottom_content_learn_more1_roll = new Image;
	bottom_content_learn_more1_roll.src = appRoot + "images/home/bottom_content_learn_more_on" + languageCode + ".gif";

	bottom_content_learn_more2_off = new Image;
	bottom_content_learn_more2_off.src = appRoot + "images/home/bottom_content_learn_more_off" + languageCode + ".gif";
	bottom_content_learn_more2_roll = new Image;
	bottom_content_learn_more2_roll.src = appRoot + "images/home/bottom_content_learn_more_on" + languageCode + ".gif";

	bottom_content_learn_more3_off = new Image;
	bottom_content_learn_more3_off.src = appRoot + "images/home/bottom_content_learn_more_off" + languageCode + ".gif";
	bottom_content_learn_more3_roll = new Image;
	bottom_content_learn_more3_roll.src = appRoot + "images/home/bottom_content_learn_more_on" + languageCode + ".gif";

	bottom_content_learn_more4_off = new Image;
	bottom_content_learn_more4_off.src = appRoot + "images/home/bottom_content_learn_more_off" + languageCode + ".gif";
	bottom_content_learn_more4_roll = new Image;
	bottom_content_learn_more4_roll.src = appRoot + "images/home/bottom_content_learn_more_on" + languageCode + ".gif";

	in_the_news_read_more1_off = new Image;
	in_the_news_read_more1_off.src = appRoot + "images/common/in_the_news_read_more_off" + languageCode + ".gif";
	in_the_news_read_more1_roll = new Image;
	in_the_news_read_more1_roll.src = appRoot + "images/common/in_the_news_read_more_on" + languageCode + ".gif";

	in_the_news_read_more2_off = new Image;
	in_the_news_read_more2_off.src = appRoot + "images/common/in_the_news_read_more_off" + languageCode + ".gif";
	in_the_news_read_more2_roll = new Image;
	in_the_news_read_more2_roll.src = appRoot + "images/common/in_the_news_read_more_on" + languageCode + ".gif";

	bottom_menu_privacy_policy_off = new Image;
	bottom_menu_privacy_policy_off.src = appRoot + "images/common/bottom_menu_privacy_policy_off" + languageCode + ".gif";
	bottom_menu_privacy_policy_roll = new Image;
	bottom_menu_privacy_policy_roll.src = appRoot + "images/common/bottom_menu_privacy_policy_on" + languageCode + ".gif";

	bottom_menu_harper_collins_off = new Image;
	bottom_menu_harper_collins_off.src = appRoot + "images/common/bottom_menu_harper_collins_off" + languageCode + ".gif";
	bottom_menu_harper_collins_roll = new Image;
	bottom_menu_harper_collins_roll.src = appRoot + "images/common/bottom_menu_harper_collins_on" + languageCode + ".gif";
	
	isLoaded = true;
}