﻿//**************************************************
function gObject(oName){
	return document.getElementById(oName);
}

//**************************************************
function runMailClient(mMail){
	if(!mMail) return;
	var eAdd = new String("") + mMail.replace(" zavinac ", "@");
	eAdd = eAdd.replace(/\$/igm, ".");
	document.location = "mailto:" + eAdd;
	
}


//**************************************************
// SEARCH BOX
//**************************************************
function getSearchOptions(){
	var sart="";
	var ssec="";
	for (var i = 0; i < document.forms[0].length; i++){
		if (document.forms[0].elements[i].type == "checkbox" && document.forms[0].elements[i].checked){
			if(document.forms[0].elements[i].id.indexOf("searchsection")!=-1){
				if(ssec.length>0)
					ssec=ssec+",";
				ssec=ssec+document.forms[0].elements[i].value;
			}			
	    	}    		
	}
	hideSearchDetails();
	
	if(document.forms[0].elements["searchforum"].checked){
		var swin = window.open("http://forum.mobilmania.cz/search.php?search_keywords=" + document.forms[0].elements["txtSearch"].value, "fesearch", "");
		document.forms[0].txtSearch.value = ""
		if(ssec!=""){
			swin.focus();
		}
	}	

	return (ssec!="") ? ("&sart="+escape(sart)+"&ssec="+escape(ssec)) : null;
}
//**************************************************
function hideSearchDetails(){
	var oObj = gObject("searchdispdetail");
	if(oObj){
		oObj.style.visibility = "hidden";
	}
}
//**************************************************
function showSearchDetails(){
	var oObj = gObject("searchdispdetail");
	if(oObj){
		oObj.style.visibility = "visible";
	}
	return
}
//**************************************************
function startSearch(){
	var sOptions = getSearchOptions();
	if(sOptions!=null){
		document.location='/hledani/default.asp?EXPS='+escape(document.forms[0].txtSearch.value)+sOptions;
	}
}
//**************************************************
function checkSearch(){
	return true
}

document.onkeypress = checkENTER;
//**************************************************
function checkENTER(e){
	if(!e){
		if(event.keyCode && event.keyCode == 13 && event.srcElement.name == "txtSearch"){
			//enter MS
			startSearch();
			event.cancelBubble = false;
			return false;
		}
	}else{
		if(e.which && e.which == 13 && event.srcElement.name == "txtSearch"){
			//enter OTHER
			startSearch();
			e.cancelBubble = false;
			return false
		}
	}
	return true
}


//**************************************************
// LAYOUT
//**************************************************
function reposLayout(){
	var oLC 	= gObject("mlcolumn");
	var oMC 	= gObject("mmcolumn");
	var oRC		= gObject("mrcolumn");

	var oHeight = Math.max(oLC.offsetHeight, oMC.offsetHeight);
	    oHeight = Math.max(oHeight, oRC.offsetHeight);

	if(oHeight>oLC.offsetHeight){
		oLC.style.height  = oHeight + "px";
	}

	if(oHeight>oMC.offsetHeight){
		oMC.style.height  = oHeight + "px";
		gObject("hpflashender").style.height  = (oHeight - gObject("hpflashnews").offsetHeight) + "px";
	}
	if(oHeight>oRC.offsetHeight){
		oRC.style.height  = oHeight + "px";
		gObject("hpbannender").style.height  = (oHeight - gObject("bnrskyr").offsetHeight) + "px";
	}

	var lBott	= gObject("hpmainarlist");
	var rBott	= gObject("hpadtext");
	var oFR      	= gObject("adrtextframe");

	oFR.style.height  	= lBott.offsetHeight + "px";
	rBott.style.height 	= lBott.offsetHeight + "px";

	return true

}
//**************************************************
function reposComparer(){ 
	var oLC      = gObject("hpadtext"); 
	var oRC      = gObject("hpcomp"); 
	var oFR      = gObject("adrtextframe"); 
 	if(!oRC) return true;
	if(oRC.offsetHeight>oLC.offsetHeight){ 
		oFR.style.height  = (oRC.offsetHeight-oLC.offsetHeight+oFR.offsetHeight+10) + "px";
		oLC.style.height  = (oRC.offsetHeight+10) + "px"; 
	} 
	return true 
}
//**************************************************
function reposLevel(){ 
	var oRC      = gObject("hpadtext"); 
	var oLC      = gObject("hpdata"); 
	var oFR      = gObject("adrtextframe"); 
 	if(!oLC) return true;
	if(oRC.offsetHeight<oLC.offsetHeight){ 
		oFR.style.height  = (oLC.offsetHeight-oRC.offsetHeight+oFR.offsetHeight) + "px";
		oRC.style.height  = (oLC.offsetHeight) + "px"; 
	} 
	return true 
}

//**************************************************
// THUMBNAILS
//**************************************************
function BigImg(ARI,IMI)
{
	var URL;
	URL="/Article/BigImg.asp?ARI="+ARI+"&IMI="+IMI
	window.open(URL,'','status=1,scrollbars=1,width=650,height=560,resizable=1')
}

//**************************************************
// ETARGET
//**************************************************
function show_link(a){
	window.status=a;return true;
}
function hide_link(){
	window.status=' ';
}