<!--

var w;
if (self.innerWidth) w = self.innerWidth;
else if (document.documentElement && document.documentElement.clientWidth) w = document.documentElement.clientWidth;
else if (document.body) w = document.body.clientWidth;
else w = 0;

//if (w>900) document.body.style.paddingRight = "95px";

// display the login area instead of the banner
function showLoginArea(){
	document.getElementById("banner_loginarea").style.backgroundColor = "#141414";
	document.getElementById("banner_loginarea").innerHTML = document.getElementById("banner_loginarea_div").innerHTML;
	document.getElementById('login_email').focus();
}

function loginCheckTop(){
	if (IsEmail(document.getElementById('login_email').value)){
		if (document.getElementById('login_pass').value!=''){
			// ajax
			doAjax("login.enter.ajax.php",loginCheckTop_Done,"email="+document.getElementById('login_email').value+"&pass="+document.getElementById('login_pass').value);
		}else{
			alert(_LANG_NoPass);
			document.getElementById('login_pass').select();
		}
	}else{
		alert(_LANG_NoEmail);
		document.getElementById('login_email').select();
	}
}

function loginCheckTop_Done(data){
	if (data=="<ok/>"){
		document.getElementById("banner_loginarea").innerHTML = "<b>Redirecting... Please wait</b>";
		document.location.href = '/mybox';
	}else{
		alert(_LANG_LoginFailed);
		document.getElementById('login_email').select();
	}
}

function loginResubmit(){
	if (confirm(_LANG_PassResetQ)){
		if (IsEmail(document.getElementById('login_email').value)){
			doAjax("login.resubmit.ajax.php",loginResubmit_Done,"email="+document.getElementById('login_email').value);
		}else{
			alert(_LANG_NoEmail);
			document.getElementById('login_email').select();
		}
	}else{
		//
	}
}

function loginResubmit_Done(data){
	if (data=="<ok/>"){
		alert(_LANG_RSOK);
	}else{
		alert(_LANG_LoginFailed);
		document.getElementById('login_email').select();
	}
}

function doSearch_Main(mdlstr){
	if (typeof mdlstr == "undefined") mdlstr = '';
	if ((document.getElementById("txtSearchBox_Main").value!='') && (document.getElementById("txtSearchBox_Main").value!=mdlstr)){
		document.location.href = _html_base + "search/" + document.getElementById("txtSearchBox_Main").value;
	}else{
		document.getElementById("txtSearchBox_Main").value = mdlstr;
		document.getElementById("txtSearchBox_Main").select();
	}
}

// show or hide the given object by id, according to the current state
function showblock(divid){
	if (document.getElementById(divid).style.display=='block') document.getElementById(divid).style.display='none';
	else document.getElementById(divid).style.display='block';
}
	
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
	if (typeof pos == 'undefined') pos='center';
	if (typeof scroll == 'undefined') scroll='auto';
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);
}

// do print by javascript, mainly inteded for flash objects
function doPrint (){
	window.print(); 
}

var tmpImgElement;
function imagesCache_New(srcImg){
/*	try{
		//eval("var tmpImageLoader_"+srcImg.replace(".","_")+" = new Image();");
		//eval("tmpImageLoader_"+srcImg.replace(".","_")+".src = '"+web_path+"images/"+srcImg+"';");
		tmpImgElement = document.createElement("img");
		tmpImgElement.id = "tmpImageLoader_"+srcImg.replace(".","_");
		tmpImgElement.src = _html_base+_images_base+srcImg;
		tmpImgElement.width=0;
		tmpImgElement.height=0;
		document.appendChild(tmpImgElement);
	}catch(e){
		alert("Error pre-loading images: \n\n"+e.message);
	}
*/
}

function imagesCache_Get(srcImg){
/*	//srcImg = srcImg.replace(".","_");
	//return (eval("tmpImageLoader_"+srcImg+".src"));
	return (document.getElementById("tmpImageLoader_"+srcImg.replace(".","_")).src);
*/
}

function getKeyCode(evt){
	evt = (evt) ? evt : event;
	return ((evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0)));
}

function popupImage(src,scroll){
	if (typeof scroll == "undefined") scroll = "yes";
	src = src.substring(0,src.length-4) + "_big" + src.substring(src.length-4);
	NewWindow(_html_base+"showimage/"+URL.Encode(src),"showimage",20,10,scroll);
}

function printPage(objType,objID){
	if (typeof objType == "undefined") objType = "";
	if (typeof objID == "undefined") objID = 0;
	if (objType=="" || objID==0){
		window.print();
	}else{
		//alert("print "+objType+" with id "+objID);
		NewWindow(_html_base+"print/"+objType+"/"+objID,"print",650,560,'yes');
	}
}

function sendToFriend(url){
	// popup window
	NewWindow(_html_base+"sendtofriend/"+URL.Encode(url),"send_to_friend",560,390,'yes');
}

// type: inner,offset | dim: x,y
function getDocHeight(type,dim){
	if (type=="offset"){
		if (self.pageYOffset) // all except Explorer
		{
			if (dim=="h") return(self.pageXOffset);
			if (dim=="w") return(self.pageYOffset);
		}
		else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict
		{
			if (dim=="h") return(document.documentElement.scrollLeft);
			if (dim=="w") return(document.documentElement.scrollTop);
		}
		else if (document.body) // all other Explorers
		{
			if (dim=="h") return(document.body.scrollLeft);
			if (dim=="w") return(document.body.scrollTop);
		}

	}else{
		if (self.innerHeight) // all except Explorer
		{
			if (dim=="h") return(self.innerHeight);
			if (dim=="w") return(self.innerWidth);
		}
		else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
		{
			if (dim=="h") return(document.documentElement.clientHeight);
			if (dim=="w") return(document.documentElement.clientWidth);
		}
		else if (document.body) // other Explorers
		{
			if (dim=="h") return(document.body.clientHeight);
			if (dim=="w") return(document.body.clientWidth);
		}
	}
}

function setBannersHeight(h){
	document.getElementById("banners_iframe").style.height = h + "px";
}

function setSelectedCombo(cmb,val,by){
	if (typeof by == "undefined") by = 'text';
	for (var no = 0; no < cmb.options.length; no++){
		if (by=='text'){
			if (cmb.options[no].text == val){
				cmb.selectedIndex = no;
				break;
			}
		}else{
			if (cmb.options[no].value == val){
				cmb.selectedIndex = no;
				break;
			}
		}
	}
}

function addToMyBox(type,oid){
	document.location.href = '/mybox/add/' + type + '/' + oid;
}

//-->