function updateHistory() {
	var info = updateHistory.arguments[0];
	var q_str = new String();
	q_str = urlEncodeObject(info);
	
	window.flashHistory.AddBookmark(q_str) ;
}


function parseQuery(){
	var pairHalves;
	var queryVars = {};
	var q_str = parseQuery.arguments[0];
	
	if(q_str == '') return;
	
	var N_V_pairs = q_str.split("&");
	var l = N_V_pairs.length;
	for(var i=0; i<l; i++){
		pairHalves = N_V_pairs[i].split("=");
		queryVars[pairHalves[0]] = unescape(pairHalves[1]);
	}
	return queryVars;
}

function urlEncodeObject() {
	var obj = urlEncodeObject.arguments[0]
	var q_str = ''; 
	for (var key in obj) {
		q_str += key + '=' + escape(obj[key]) + '&';
	} 

	q_str = q_str.substr(0, q_str.length - 1);
	return q_str
}

function setScrollTop(){
	self.scrollTo(0,0);
}
function setScrollBottom(){
	self.scrollTo(0,3000);
}
function setScrollPos(numPos){
	self.scrollTo(0,numPos);
}

function setFocus() {
	window.focus();
}
function notFound(){
	parent.window.location = "404.html";
}
function addBookmark(){
	
	var appName = navigator.appName.toLowerCase(); 
	var userAgent = navigator.userAgent.toLowerCase();
	
	if (appName.indexOf("explorer") != -1){
		window.external.AddFavorite(parent.window.location, parent.document.title);
	} else {
		var info;
		if (userAgent.indexOf("mac") != -1){
			info = "Please use Cmd-D or the menu to bookmark this site";
		} else {
			info = "Please use Ctrl-D or the menu to bookmark this site";
		}
		alert(info);		
	}
	
}

function openCustomWindow(URL,w,h, name){
	name = (name == undefined)? "Window" : name;	
	window.open(URL, name, "toolbar=no, location=no, status=yes, menubar=no,  resizable=no, scrollbars=no, width=" + w + ",height=" + h); 	
}

// not required if using the JS2F kit
// getURL is used by JSF2 for all browsers except IE (although it seems to be broken since EOLAS patent spat)
function addFSCommand(swfId) {
	document.body.innerHTML += "<script language=\"javascript\">// <![CDATA[ function " + swfId + "_DoFSCommand(command, args){eval(command+'('+args+')');} // ]]></script>";
}

function addToOnLoad(f) {
    var prev=window.onload;
    window.onload=function(){ if(prev)prev(); f(); }
}

function alertthis() {
	alert(alertthis.arguments[0]);	
}
function trace(traceStr){
	var trace=document.getElementById("trace");
	trace.innerHTML +=traceStr+"<br>";
}
function setDivWidth(divid, newW){
	document.getElementById(divid).style.width = newW+"px";
}
function setDivHeight(divid, newH){
	document.getElementById(divid).style.height = newH+"px";	
}
function setDivSize(divid, newW, newH){
	setDivWidth(divid, newW);
	setDivHeight(divid, newH);
}
function canResizeDiv(){
	var ua = navigator.userAgent.toLowerCase();
	var opera = ua.indexOf("opera");
	if( document.getElementById ){
		if(opera == -1) return true;
		else if(parseInt(ua.substr(opera+6, 1)) >= 7) return true;
	}
	return false;
}


function getWindowSize(){
var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
 // window.alert( 'Width = ' + myWidth );
 // window.alert( 'Height = ' + myHeight );
  
  if (myWidth && myHeight){
  	return {w:myWidth, h:myHeight}
  } else {
 	 return false;
  }
	
}
