// JavaScript Document

///*********** JQuery Action ***********///
///*********** JQuery No Conflict*******///
jQuery.noConflict();

///******* STYLESHEET SWITCHING ***********///

(function($)
{
	$(document).ready(function() {
		$('.styleswitch').click(function()
		{
			switchStylestyle(this.getAttribute("rel"));
			return false;
		});
		var c = readCookie('style');
		if (c) switchStylestyle(c);
	});

	function switchStylestyle(styleName)
	{
		$('link[@rel*=style][title]').each(function(i) 
		{
			this.disabled = true;
			if (this.getAttribute('title') == styleName) this.disabled = false;
		});
		createCookie('style', styleName, 365);
	}
})(jQuery);
// cookie functions http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}


///******** JS TO AS CONNECTOR *********///
function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window['ie_'+movieName] : document['ff_'+movieName];
}

function callToAS(str) 
{
	
	getFlashMovie("flashReader").sendToAS(str);
}

function sendToJS(val)
{
	document.getElementById('boxX').value = "ROM";
	document.getElementById('boxX').value = val;
}

///******** KEYPRESS DETECTOR *********///

//process this function whenever a key is pressed
$(document).keypress(function (e) {

	//a & A
	if (e.keyCode == 65 || e.charCode == 65 || e.keyCode == 97 || e.charCode == 97){
		callToAS('all.0000');
	}

	//H & h
	if (e.keyCode == 104 || e.charCode == 104 || e.keyCode == 72 || e.charCode == 72){
		callToAS('hl.0000');
	}
	

});

///******** EXPANDING DIV CONTAINER *********////*


jQuery(document).ready(function() {})
function resizeDiv(adjustment){
	var browser = navigator.appName;
	var b_ver = navigator.appVersion;
	var $left_col = jQuery("#content_left").height();
	var $right_col = jQuery("#content_right").height();
	if( $left_col >= $right_col){
		var $content_h = $left_col;
	}else{
		var $content_h = $right_col;
	}
	var $home_content_h = $content_h;
	var $inner_h = $content_h + 300;
	var $outer_h = $inner_h + 200;
	if(browser == "Microsoft Internet Explorer"){
		jQuery("#content_right").height($content_h+adjustment)
		jQuery("#content_left").height($content_h)
		jQuery("#inner_wrap").height($inner_h);
		jQuery("#outer_btm_wrap").height($outer_h);
		jQuery("#outer_right_wrap").height($outer_h);
		jQuery("#outer_left_wrap").height($outer_h);
		jQuery("#outer_top_wrap").height($outer_h);
	}else{
		jQuery('#content_right').height($content_h+adjustment)
		jQuery('#content_left').height($content_h)
		jQuery('#home_content').height($home_content_h);
		jQuery('#inner_wrap').height($inner_h);
		jQuery('#outer_btm_wrap').height($outer_h);
		jQuery('#outer_right_wrap').height($outer_h);
		jQuery('#outer_left_wrap').height($outer_h);
		jQuery('#outer_top_wrap').height($outer_h);
	}

}


