function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function onUnloadHandler(){
	if (powerbelt_login_window_ref != null) {
		powerbelt_login_window_ref.close();
	}
}

function onSubmitProductForm(){
	return true;
}

function onSubmitFulesLancForm() {
	return true;
}

function openShoppingCart(){
	powerbelt_cart_window_ref = open('index.php?page=Cart', 'powerbelt_cart_window', 'width=760, height=650, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, screenX=5, left=5, screenY=10, top=10, status=yes'); return false;
}


powerbelt_login_window_ref = null;
powerbelt_cart_window_ref = null;

function showFloatingImage(imageName, xo, yo){
	var imgText = "<table border='1' cellpadding='0' cellspacing='0' class='tellureRotaTable'><tr><td><img src='images/specific/tr/" + imageName+ ".jpg'></td></tr></table>";
	writeH('floatingImage', imgText);
	var obj = getE('linkID' + imageName, this);
	setX('floatingImage', getMouseX() + getScrollX() + xo);
	setY('floatingImage', getMouseY() + getScrollY() + yo);
}

function hideFloatingImage(){
	writeH('floatingImage', '');
}

function loginButtonClicked() {
	if ((powerbelt_login_window_ref != null) &&(!powerbelt_login_window_ref.closed)) {
		powerbelt_login_window_ref.focus();
	} else {
		powerbelt_login_window_ref = open('index.php?page=Login', 'powerbelt_login_window', 'width=400, height=250, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no');
	}
	return false;
}

function mainMenuClicked(id) {
	var td = document.getElementById('TD_' + id);
	if (td != null) {
		td.style.backgroundImage = '';
	}
	var lid = 'LastL2_' + id;
	//alert(lid);
	var lastDiv = getE(lid);
	if (lastDiv != null) {
		//alert(lastDiv);
		var posL = getElementPosition(lid);
		//alert(pos.left + " " + pos.top);

		//var posF = getElementPosition('FirstL2_' + id;);

		window.scroll(0, posL.top + 50 - getWindowSize().h);
	}
	
	return;
}

var performMainpageNewsShowHide = 0;
var crossfaderPerforming = 0;

var timerShowCategory = null;
var timerShowNews = null;
var timerInjectHideToFlash = null;

var overId = null;

function mainMenuOver(id, css) {
	if (timerInjectHideToFlash != null) {
		clearInterval(timerInjectHideToFlash);
		timerInjectHideToFlash = null;
	}
	//alert(overId + " " + id);
	if (overId == id) {
		//alert("egy");
		return false;
	}
	overId = id;
	var td = document.getElementById('TD_' + id);
	if (td != null) {
		var imgSrc = "url('/images/v2/left_menu_l1_bg.png')";
		if (css != null) {
			if (css.indexOf('firstL1MenuOnWhitePage') != -1) {
				imgSrc = "url('/images/v2/left_menu_l1_first_on_mainpage_bg.png')"
			} else if (css.indexOf('firstL1Menu') != -1) {
				imgSrc = "url('/images/v2/left_menu_l1_first_on_bg.png')";
			} else if (css.indexOf('lastL1Menu') != -1) {
				imgSrc = "url('/images/v2/left_menu_l1_last_on_bg.png')"
			}
		}
		td.style.backgroundImage = imgSrc;
	}
	//return;
	// serverPath is written only on the mainpage into the js section of the page
	if (typeof(serverPath) == "undefined") {
		return;
	}
	hidediv('mainPageNewsContainerId');
	var div = showdiv('flashDiv');
	if (timerShowNews != null) {
		clearInterval(timerShowNews);
		timerShowNews = null;
	}
	timerShowCategory = setTimeout('showCategory("'+id+'")', 100);
	return false;
	//alert(div);
}

function showCategory(id) {
	var flm = getFlashMovieObject("categoriesMovie");
	flm.SetVariable("id",id);
	flm.SetVariable("actionToPerform",1);
}

function getFlashMovieObject(movieName){
  	
  if (window.document[movieName]) {
	  return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1){
	return null;
  }else{
	return document.getElementById(movieName);
  }
}


function mainMenuOut(id) {
	//overId = null;
	var td = document.getElementById('TD_' + id);
	if (td != null) {
		td.style.backgroundImage = '';
	}
	if (typeof(serverPath) == "undefined") {
		return;
	}
	timerInjectHideToFlash = setTimeout('injectHideToFlash("'+id+'")', 100);
	return false;
}

function injectHideToFlash(id) {
	overId = null;
	var flm = getFlashMovieObject("categoriesMovie");
	flm.SetVariable("id",id);
	flm.SetVariable("actionToPerform",-1);
}

function flashAnimationStopped() {
	hidediv('flashDiv');
	timerShowNews = setTimeout('showNews()', 1000);
	//overId = null;
}

function showNews() {
	showdiv('mainPageNewsContainerId');
}


function writeToLayer(id, sHTML) {
  //if (!page_loaded) return;
  var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
  if (!el) return;
  var cntnt = '<div class="info">' + sHTML + '</div>';
  if (typeof el.innerHTML!="undefined") {
      el.innerHTML = cntnt;
  } else if (document.layers) {
			el.document.write(cntnt);
			el.document.close();
  }
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
    //safe function to show an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
    	var element = document.getElementById(id);
        element.style.display = 'block';
        return element;
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
            return document.id;
        }
        else { // IE 4
            document.all.id.style.display = 'block';
            return document.all.id;
        }
    }
}

function toggle_visibility(id) {
	var e = document.getElementById(id);
	if(e.style.display == 'block')
		e.style.display = 'none';
	else
		e.style.display = 'block';
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}