// stateNav.js
// v 0.8
// 2005-08-20
// leo@blixtsystems.com
// Part of statemanagement system for flash
// Full package available at:
// http://www.blixtsystems.com/index.html?page=downloads&pid=7&ss=pid
// Licensed under GNU GPL, see license.txt included with package for details
//
// browser detection
var ua        = navigator.userAgent.toLowerCase();
var is_pc_ie  = ( (ua.indexOf('msie') != -1 ) && ( ua.indexOf('win') != -1 ) && ( ua.indexOf('opera') == -1 ) && ( ua.indexOf('webtv') == -1 ) );
var is_ff =( (ua.indexOf('gecko') != -1 ) && ( ua.indexOf('opera') == -1 ) && ( ua.indexOf('safari') == -1 ));

var is_opera=(ua.indexOf('opera') != -1);
// set flashVariables courtesy of mustardlabs.com
// http://www.mustardlab.com/developer/flash/jscommunication/
/* -----------------------------------------------------------
function setFlashVariables(movieid, flashquery)

movieid: id of object tag, name of movieid passed in through FlashVars
flashquery: querystring of values to set. example( var1=foo&var2=bar )
----------------------------------------------------------- */
function setFlashVariables(movieid, flashquery){
	var i,values;
	// been testing with opera 8, but setFlashVariables fails, both in IE mode and not
	var chunk = flashquery.split("&");
	for(i in chunk){
		values = chunk[i].split("=");
		document[movieid].SetVariable(values[0],values[1]);
		if(values[0]=="page"){
			document.title = siteName + " " + values[1];
		}
	}
}
// function for parsing state string to an object
function getParams(){
	var o = new Object();
	var stateStr = new String(document.location.search.substr(1) || document.location.href.split("#")[1]);
	var states = stateStr.split("&");
	var len = states.length;
	for (var i=0; i<len; i++) {
		var p = states[i].split("=");
		o[p[0]] = p[1];
	}
	return o;
}
// at least FF  need this function to return to the page after address bar been updating
function getState() {
	var params = new String(window.document.location.hash.split("#")[1]);
	setFlashVariables('myMovie', params);
}
// non IE browser use this javascript to update hash and title
function putHref(stateStr, page) {
//document.location=document.location.protocol+'//'+document.location.host+document.location.pathname;
//document.location.search="?n=n";
	document.location.hash=stateStr;
	document.title = siteName + " " + page;
}
/*
// load html page in historyframe
function loadPage(params, page){
	// the string with the code for the head section of the historyframe
	var str="<title>"+page+"</title>";
	str+="<script language='JavaScript'>";
	str+="parent.setFlashVariables('myMovie','"+params+"');";
	str+="</" + "script>";
	// FF has a bug making double history entries with document.open
	// innerHTML has to be used instead, but might not be compatible with all browsers so we provide alternative code
	if(!is_ff){

		var doc = document.frames("historyframe");
		historyframe.document.open("text/html","replace");
		historyframe.document.write("<html><head>"+str+"</head><body></body></html>");
		historyframe.document.close();
	} else {
		window.frames["historyframe"].window.document.head.innerHTML=str;
	}
}
*/
