/***************************************************************************
# File: lib_window_effects.js - JavaScript Window Effects
# Version: 1.2.1
***************************************************************************/

/**** Window Load Functions ****/
window.onload = function()
{
	base_directory_script = '/resources/javascript/';
	base_directory_css = '/resources/stylesheets/';

	if(window.bjs_debugger_flag != undefined) // JavaScript Debugger
		ob_win_bjs = new JS_Debug();

	ob_win_eff = new WindowEffects();
	ob_bro_det = new BrowserDetails();

	if(window.popup_window_flag != undefined)
		ob_win_eff.PopUpsInit(); // <a href="page.html" class="open_popup" rel="normal"> OR <a href="page.html" class="open_popup" rel="450x350">

	if(window.toggle_display_flag != undefined) // Toogle block elements
		ob_win_eff.ToggleDisplayInit();

	if(window.sliding_content != undefined) // Sliding content
		ob_win_eff.SlideContentInit();
		
	if(window.image_rollovers != undefined) // Image Rollovers
		ob_win_eff.RollOverInit();

	if(window.image_slideshow != undefined) // Image Slideshow
		ob_win_eff.SlideShowInit();
		
	if(window.toggle_tabs_flag != undefined) // Tabs
	{
		var current_tab_sets = window.toggle_tabs_flag.split("|");
		for(var i=0; i < current_tab_sets.length; i++)
			ob_win_eff.ToggleTabsInit(current_tab_sets[i]);
	}

	if(window.drag_drop_flag != undefined) // Drag and drop
	{
		ob_dnd = new DragAndDrop();
		
		var dnd_boxes = window.drag_drop_flag.split("|");
		for(var i=0; i < dnd_boxes.length; i++)
		{
			ob_dnd.CreateDragContainer(document.getElementById(dnd_boxes[i]));
			ob_dnd.UpdateHiddenField(dnd_boxes);
		}
	}

	if(window.confirm_click_flag != undefined) // Confirm Clicks
		ob_win_eff.ConfirmClickInit(); // <a href="page.html" class="confirm_click" title="Confirm message here?"> OR <input type="submit" name="whatever" value="" class="confirm_click" title="Confirm message here?">

	if(window.print_onload_flag != undefined) // Print page onload
		window.print();

	if(window.lightbox_flag != undefined) // Lightbox
		initLightbox();

	if(window.be_enabled_flag != undefined) // Bourbon Editor
	{  // Add to textarea class -- be_editor
		if(ob_bro_det.is_safari)
		{
			alert("Support for Safari is not yet enabled");
		}
		else
		{
			ob_be_cleaner = new BourbonEditorCode();
			ob_be = new BourbonEditor();		
			ob_be.LoadBourbonEditors();
		}
	}

	if(window.ajax_flag != undefined) // Start your AJAX
	{
		ob_ajax = new AjaxEngine();
		ob_ajax.InitXmlRequest();
		
		if(window.ajax_anchor_onclick_flag != undefined)
			ob_ajax.AjaxAnchorOnClickInit();
			
		if(window.ajax_input_onclick_flag != undefined)
			ob_ajax.AjaxInputOnClickInit();
	}

	if(window.menu_hovers_flag != undefined && ob_bro_det.is_msie === true) // Drop down menus for IE6
		ob_win_eff.SetMenuHoversInit('site_nav_menu');

	if(window.page_form_flag != undefined) // Form Effects
	{
		ob_for_eff = new FormEffects();
		
		if(window.copy_form_fields_flag != undefined) // Copy form fields from one to another
			ob_for_eff.CopyFormFieldsInit();

		if(window.check_all_flag != undefined) // Check all checkboxes
			ob_for_eff.CheckAllInit();
			
		if(window.click_fields != undefined) // Click fields
			ob_for_eff.ClickFieldsInit();
			
		if(window.clear_fields_flag != undefined) // Clear fields
			ob_for_eff.ClearFormFields();
			
		if(window.clear_fields_submit_flag != undefined) // Clear fields and then submit
			ob_for_eff.ClearFormAndSubmitInit();
		
		if(window.required_fields_flag != undefined) // Check for required fields
		{
			ob_for_eff.RequiredFieldsInit();
			ob_for_eff.FormSubmitInit();
		}
	}

	/* if(window.resize_div_height != undefined)
	{
		ob_win_eff.GetViewPort();
		section_wrapper_shadow_nh = ob_win_eff.page_y - 20;
		setTimeout("ob_win_eff.SetElementHeight('section_wrapper_shadow', section_wrapper_shadow_nh)", 100);
	} */
}


/**** Visitor Browser ****/
function BrowserDetails()
{
	this.ua = navigator.userAgent;

	// MS MSIE
	this.match_msie = "MSIE";
	this.is_msie = false;
	
		this.match_msie7 = "MSIE 7";
		this.is_msie7 = false;

	// Mozilla Gecko
	this.match_gecko = "Gecko";
	this.is_gecko = false;

		// Mozilla Firefox
		this.match_firefox2 = "Firefox/2";
		this.is_firefox2 = false;
	
		this.match_firefox3 = "Firefox/3";
		this.is_firefox3 = false;


	// Webkit
	this.match_webkit = "AppleWebKit";
	this.is_webkit = false;
	
		// Apple Safari
		this.match_safari = "Safari";
		this.is_safari = false;
		
		// Google Chrome
		this.match_chrome = "Chrome/1";
		this.is_chrome = false;

	// Opera
	this.match_opera = "Opera";
	this.is_opera = false;

	if(this.ua.match(this.match_opera))
		this.is_opera = true;

	else if(this.ua.match(this.match_gecko))
	{
		this.is_gecko = true;

		if(this.ua.match(this.match_firefox2))
		{
			this.is_firefox2 = true;
			this.is_gecko = false;
		}
		
		if(this.ua.match(this.match_firefox3))
		{
			this.is_firefox3 = true;
			this.is_gecko = false;
		}
	}

	else if(this.ua.match(this.match_msie))
	{
		this.is_msie = true;
		if(this.ua.match(this.match_msie7))
		{
			this.is_msie7 = true;
			this.is_msie = false;
		}
	}

	else if(this.ua.match(this.match_safari))
		this.is_safari = true;

	//ob_win_bjs.AddItem("this.ua = " + this.ua);
	
	return this;
}


/**** Window Error Functions ***
if(window.bjs_debugger_flag != undefined)
	window.onerror = handle_error;

function handle_error(msg, url, l)
{
	txt  = "There was an error on this page.\n\n";
	txt += "Error: " + msg + "\n";
	txt += "URL: " + url + "\n";
	txt += "Line: " + l + "\n\n";
	
	ob_win_bjs.AddDebug(txt);
	return true;
}
*/

