//PROPERTIES

// EVENTS		
$(document).ready(function(){					   
	
	//FIX ZINDEX FOR MAIN MENU ITEMS
	var _menuZ = 350;
	$("#mainBody #navigation ul#mainMenu > li").each(function(){
		$(this).css("z-index",_menuZ);
		_menuZ--;
	});
	//SET TITLE = ALT FOR CROSS PLATFORM STUFF
	$("#mainBody img").each(function(){
		if  ( ($(this).attr("title") == undefined) || ($(this).attr("title") == "") )  {
			if  ( ($(this).attr("alt") != undefined) && ($(this).attr("alt") != "") )  {
				$(this).attr( {title: $(this).attr("alt") });	
			}
		}
	});	
	// Dynamically add target="_blank" to a tags inside li tags with 'openNewWindow'
	// class applied as well as to a tags with the same class applied directly
	$("li.openNewWindow > a, a.openNewWindow").attr("target","_blank");
	$(".faqDetail").hide();
	$(".faqQuestion").click(function(){
		$(".faqDetail").hide(100);
		$(this).parent().next().slideToggle(100);
	});
});

// FUNCTIONS

// WRAPPER - THICKBOX CASE CHANGED, THIS KEEPS OLD CODE WORKING
function TB_show(caption, url, imageGroup){
	tb_show(caption, url, imageGroup);
}

function tb_open_special(_url, _w, _h, _padW, _padH){
	var _size = get_viewport_size();
	if(_padW == undefined || _padW == 0 || _padW == ''){
		_padW = 100;
	}
	if(_padH == undefined || _padH == 0 || _padH == ''){
		_padH = 100;
	}
	if(_w == undefined || _w  == 0 || _w  == ''){
		_w = _size["w"] - _padW;
	}		
	if(_h == undefined || _h == 0 || _h == ''){
		_h = _size["h"] - _padH;
	}		
	// var _w = $("#mainBody").width() - 90;
	tb_show('',_url + '&amp;height=' + _h + '&amp;width=' + _w,'');
}

function get_viewport_size(){
	var viewportwidth;
	var viewportheight;
	if (typeof window.innerWidth != 'undefined')
	{
		viewportwidth = window.innerWidth,
		viewportheight = window.innerHeight
	}
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)		
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	{
		viewportwidth = document.documentElement.clientWidth,
		viewportheight = document.documentElement.clientHeight
	}
	// older versions of IE		 
	else
	{
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
	var _size = new Array();
	_size["w"] = viewportwidth;
	_size["h"] = viewportheight;
	return _size;
}

