var cur_lyr;	// holds id of currently visible layer

function swapLayers(id) {
	if (cur_lyr) hideLayer(cur_lyr);
	showLayer(id);
	cur_lyr = id;
}

function showLayer(id) {
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
	var lyr = getElemRefs(id);
	if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function faijzingPopup(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function faijzingResize(iW,iH) {
		window.resizeBy(iW-windowWidth(),iH-windowHeight());
}

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
		anchor.target = "_blank";
	}
}

/*
function faijzingSearchHash2() {
	if ((window.location.hash) == '#tl') {
	swapLayers('sk1');
	}
	else if ((window.location.hash) == '#mis') {
		swapLayers('sk2');
	}
	else if ((window.location.hash) == '#res') {
		swapLayers('sk3');
	}
	else if ((window.location.hash) == '#vlv') {
		swapLayers('sk4');
	}
	else if ((window.location.hash) == '#mbs') {
		swapLayers('sk5');
	}
	else if ((window.location.hash) == '#vld') {
		swapLayers('sk6');
	}
	else if ((window.location.hash) == '#tb') {
		swapLayers('sk7');
	}
	else if ((window.location.hash) == '#fps') {
		swapLayers('sk8');
	}
}
*/

function faijzingSearchHash() {
	if ((window.location.hash) != null) {
	var visa_sk = document.location.hash.substr(1,document.location.hash.length);
	swapLayers(visa_sk);
//	alert (new_pos);
	}
}

function faijzingWindowWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;}

function faijzingWindowHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;}
 
function faijzingCheckWinSize() {
	var winh = faijzingWindowHeight();
	var winw = faijzingWindowWidth();

	if (winh < 548 && winw >= 772 ) {
		document.getElementById("global").style.marginTop = 0;
		document.getElementById("global").style.marginLeft = "-386px";
		document.getElementById("global").style.top = 0;
		document.getElementById("global").style.left = "50%";
	}
	else if (winh >= 548 && winw >= 772) {
		document.getElementById("global").style.marginTop = "-274px";
		document.getElementById("global").style.marginLeft = "-386px";
		document.getElementById("global").style.top = "50%";
		document.getElementById("global").style.left = "50%";
	}
	
	else if (winh >= 548 && winw < 772) {
		document.getElementById("global").style.marginTop = "-274px";
		document.getElementById("global").style.marginLeft = 0;
		document.getElementById("global").style.top = "50%";
		document.getElementById("global").style.left = 0;
	}
	
	else if (winh < 548 && winw < 772) {
		document.getElementById("global").style.marginTop = 0;
		document.getElementById("global").style.marginLeft = 0;
		document.getElementById("global").style.top = 0;
		document.getElementById("global").style.left = 0;
	}
}

window.onresize = faijzingCheckWinSize;

