// ************************************************ DuppScripts

//_____________________________________________________________
//                                          Recall Query String
// Usage:
// <a href="myPage.html?name=thom">click me</a>
//
// <script type="text/javascript">
//   	alert(qs("name"));
// </script>
function qs(search_for) {
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i=0; i<parms.length; i++) {
        var pos = parms[i].indexOf('=');
        if (pos > 0 && search_for == parms[i].substring(0,pos)) {
       		 return parms[i].substring(pos+1);;
   			}
		}
    return "";
}

//_____________________________________________________________
//                                    Set Dynamic Text in a SWF
// Usage:
// - Flash
// In Flash you must have a dynamic text box and set the Variable field with a name.
// Note: The Variable name is different from an instance name.
// you can then have Flash read the text and act accordingly...
/*
		function changeType(prop, oldval, newval) {
			trace("I have been activated.");
			strType = "";
		return newval;
		}
		var strType = "";
		this.watch("strType", changeType);
*/
//
// - HTML
// in the <embed> tage you must set the name to 'thisFlash'....
// <embed name='myFlash'>
//
// <script type="text/javascript">
//   	setText('myFlash', 'strType', 'myNewValue');
// </script>
function setText(FlashObj, myTextVar, str){
		//if(window.myFlash) window.document["myFlash"].SetVariable(myTextVar, str);
		//if(document.myFlash) document.sample.SetVariable(myTextVar, str);
		document.getElementById( FlashObj ).setVariable( myTextVar, str);
}

//_____________________________________________________________
//                                        Toggle Layer On & Off
// Usage:
// toggleLayer ('myLayer',1);
function toggleLayer(szDivID, iState) // 1 visible, 0 hidden
	{
		if(document.layers)	   //NN4+
		{
		   document.layers[szDivID].visibility = iState ? "show" : "hide";
		}
		else if(document.getElementById)	  //gecko(NN6) + IE 5+
		{
			var obj = document.getElementById(szDivID);
			obj.style.visibility = iState ? "visible" : "hidden";
		}
		else if(document.all)	// IE 4
		{
			document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
		}
	}

//_____________________________________________________________
//                                                      Cookies
	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);
}

//_____________________________________________________________
//                                    Changing text within HTML
// Usage:
// - HTML
// <p> Your score is <b id='score'>10%</b></p>
//
// setHTML('score', '100%');
function setHTML(myID, myText)	{
		document.getElementById(myID).innerHTML = myText;
}


