function popupBlockerOn() {
	try{
		var oWin = window.open("","testpopupblocker","width=10,height=10,top=5000,left=5000");
		if (oWin==null || typeof(oWin)=="undefined") {
			return true;
		} else {
			oWin.close();
			return false;
		}
	}catch(e){
		return true;
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
	document.MM_popUpWin = window.open(theURL,winName,features);
}
function checkClientWindow(valid,theURL,winName,features){
	if(valid){
		clientWindow = window.open(theURL,winName,features);
	}else{
		try{
			clientWindow.close();
		}catch(e){}
	}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function addRemoveClass(id,className){
	domObj = document.getElementById(id);
	currentClass = domObj.className;
	if (currentClass.indexOf(className)<0){
		currentClass = currentClass+" "+className;
		domObj.className = currentClass;
	}else{
		currentClass = currentClass.replace(className, "");
		domObj.className = currentClass;
	}
}
flashDebugMode = false;
function flashDebugSetMode(mode){
	flashDebugMode = mode;
}

function flashDebugClear(){
	if(flashDebugMode){
		//if((debugWindow)) debugWindow.close();
		if(typeof debugWindow == "undefined" || debugWindow==null){
			var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=yes,width='+600+',height='+440+'';//,left='+left+',top='+top+',screenX='+left+',screenY='+top;
			debugWindow = window.open("debug.html","debugWindow", styleStr);
			//debugWindow.moveTo(-100,400);
		}else{
			try{
				var debugEcho = debugWindow.document.getElementById("debugEcho");
				debugEcho.innerHTML = "";
			}catch(e){}
		}
		//debugWindow.moveTo(0,100);//browserInfo.posY(browserInfo.posX-600)
		//debugWindow.opener.focus();
	}
}
function flashDebug(msg){
	if(flashDebugMode){
		if(typeof debugWindow == "undefined" || debugWindow==null){
			var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=yes,width='+600+',height='+440+'';//,left='+left+',top='+top+',screenX='+left+',screenY='+top;
			debugWindow = window.open("debug.html","debugWindow", styleStr);
		}else{
			try{
				var debugEcho = debugWindow.document.getElementById("debugEcho");
				var lBr = "\n";
				if (navigator.appName.indexOf("Microsoft") != -1) {
					lBr = "<br />";
				}
				debugEcho.innerHTML = msg + lBr + debugEcho.innerHTML;
			}catch(e){}
		}
	}
}

function replaceCharacters(conversionString,inChar,outChar){
	var convertedString = conversionString.split(inChar);
	convertedString = convertedString.join(outChar);
	return convertedString;
}
function mailto(email,subject,body){
	body = replaceCharacters(body,"<br>","%0A%0D");
	body = replaceCharacters(body,"\r","%0A%0D"); 
	body = replaceCharacters(body,"\n","%0A%0D");
	window.location.href = "mailto:"+email+"?subject="+subject+"&body="+body;
}

confirmIt = function(msg,fx){
	if(confirm(msg)){
		fx.call();
	}
};
comfirmDelete = function(msg){
	if(confirm(msg)){
		return true;
	}else{
		return false;
	}
};

function checkFieldNumber(field_Id,length,displayName){
	var field = document.getElementById(field_Id);
	if(isNaN(field.value)){
		alert("Please make sure "+displayName+" is a number.");
		field.focus();
		field.select();
		return false;
	}else{
		if(length<0){
			if(field.value.length > 0){
				return true;
			}else{
				alert("Please make sure "+displayName+" has a value.");
				field.focus();
				field.select();
				return false;	
			}
		}else if(field.value.length != length){
			alert("Please make sure "+displayName+" has "+length+" number(s).");
			field.focus();
			field.select();
			return false;
		}else{
			return true;	
		}
	}
}
function optionalNumber(field_Id,displayName){
	var field = document.getElementById(field_Id);
	if(replaceCharacters(field.value," ","").length>0 && isNaN(field.value)){
		alert("Please make sure "+displayName+" is a number.");
		field.value = "";
	}
}
function initSelectValue(selectID,selectValue){
	var selectObj = document.getElementById(selectID);
	for(var i=0;i<selectObj.options.length;i++){
		if(selectValue == selectObj.options.item(i).value){
			selectObj.selectedIndex = i;
		}
	}
}
function setInnerHTML(id,html,doc){
	doc = (doc==null)?document:doc;
	doc.getElementById(id).innerHTML = html;
}
setHash = function(hash){
	window.location.hash = hash;
};
getMetaData = function(key){
	var meta = document.getElementsByTagName("meta");
	return meta.namedItem(key).content;
};
setMetaData = function(key,value){
	var meta = document.getElementsByTagName("meta");
	meta.namedItem(key).content = value;
};

function BrowserInfo(){
  this.name = navigator.appName;
  this.codename = navigator.appCodeName;
  this.version = navigator.appVersion.substring(0,4);
  this.platform = navigator.platform;
  this.javaEnabled = navigator.javaEnabled();
  this.screenWidth = screen.width;
  this.screenHeight = screen.height;
  this.posX = (typeof window.screenX!="undefined")?window.screenX:window.screenLeft;
  this.posY = (typeof window.screenY!="undefined")?window.screenY:window.screenTop;
  //this._width = (typeof window.outerWidth!="undefined")?window.outerWidth:window.document.body.clientWidth+30;
 // this._height = (typeof window.outerHeight!="undefined")?window.outerHeight:window.document.body.clientHeight+120;
  
}
browserInfo = new BrowserInfo();

//alert("window.innerHeight: "+typeof window.innerHeight);
//alert("window.outerHeight: "+typeof window.outerHeight);
//alert("window.document.clientHeight: "+typeof window.document.clientHeight);
//alert("window.document.body.clientHeight: "+typeof window.document.body.clientHeight);
/*
currentPageID = -1;
setCurrentPID = function(pid){
	currentPageID = pid;
};
*/
//#key:value|key:value
getHashParameter = function(param) {
	try{
		var q = document.location.hash;
		var pairs = q.substring(1).split("|");
		for (var i=0; i < pairs.length; i++) {
			if (pairs[i].substring(0, pairs[i].indexOf(":")) == param) {
				return pairs[i].substring((pairs[i].indexOf(":")+1));
			}
		}
	}catch(e){}
	return "";
};
goToPage = function(newHash){
	window.location.hash = newHash;
};

