// JavaScript Document


function is_valid_email(str) {

	return (str.indexOf(".") > 0) && (str.indexOf("@") > 0) && (str.indexOf("@")<str.lastIndexOf("."));
}

function highlight(divlayer) {
	divlayer.style.backgroundImage ="url(micro/imgs/selectedbg.png)";
}

function restore(divlayer) {
	divlayer.style.backgroundImage ="";
}

function activatelink(linknum, linkurl, type, apid) {
	document.getElementById('loading').style.visibility = 'visible';
	
	if (type=="fla") {
		var so = new SWFObject("micro/bg/"+linkurl, "gmlayer", "700", "500", "9", "#000000");
		so.addVariable("module", "main");
		so.addParam("wmode", "transparent");
		so.write("gm_layer");
	}
	if (type=="imgs") {
		document.getElementById('gm_layer').style.backgroundRepeat ="no-repeat";
		document.getElementById('gm_layer').style.backgroundImage ="url(micro/bg/"+linkurl+")";
	}
	document.getElementById('remote').innerHTML = '<iframe src="micro/remote.php?infodata=1&app='+linknum+'&apid='+apid+'"></iframe>';
	this.currentapp = linknum;
	this.currentapid = apid;
	
}

function return_info(info1, info2) {
	document.getElementById('loading').style.visibility = 'hidden';
	
	document.getElementById('headercontentd').innerHTML = info1;
	document.getElementById('minicontentd').innerHTML = info2;
	document.getElementById('contentd').style.visibility = 'visible';
}

function goapp() {
	if (!this.currentapid || !this.currentapp) return;
	
	document.getElementById('remote').innerHTML = '<iframe src="micro/remote.php?goapp=1&app='+this.currentapp+'&apid='+this.currentapid+'"></iframe>';
}

function authorize(success, murl, sessid) {
	if (success)
		document.location.href = murl+"?sessid="+sessid;
}

function add_app() {
	document.getElementById('hostlyer').style.display = 'block';
	document.getElementById('blocker').style.display = 'block';
}

function close_add_app() {
	document.getElementById('hostlyer').style.display = 'none';
	document.getElementById('blocker').style.display = 'none';
}

function create_app(appid) {
	document.getElementById('remote').innerHTML = '<iframe src="micro/remote.php?gonewapp=1&app='+appid+'"></iframe>';
}

function get_checked_radio(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function importXML(fname, funcname) {
	
	if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.onload = funcname;
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.onreadystatechange = function () {
			if (xmlDoc.readyState == 4) funcname()
		};
 	}
	else
	{
		return;
	}
	xmlDoc.load(fname);
}

function remote_call (url) {
	var rc = document.createElement('div');
	rc.style.display = 'none';
	var rciframe = document.createElement('iframe');
	rciframe.setAttribute('width', 1);
	rciframe.setAttribute('height', 1);
	rc.appendChild(rciframe);
	document.getElementsByTagName('body')[0].appendChild(rc);
	
	rciframe.src = url;
}

function gotoURL (url) {
	document.location.href = url;
}

function contains (container, containee) {
	while (containee) {
		if (container == containee) {
			return true;
		}
		containee = containee.parentNode;
	}
	return false;
}
