// JavaScript functions set
// VMD Team (2006)
var iAlert = '';

function setAlert( iMsg ){
	 iAlert=iMsg;
}

function showAlert(){
	 if(iAlert!='')alert('\n'+iAlert);
}

function showHelp(id){
	ob=document.getElementById(id);
	if(ob.style.display!="block"){
		ob.style.display="block";
    	setOpacity(id,90); 
	}else {
		hideHelp(id);
	}
}

function hideHelp(id){
	ob=document.getElementById(id);
	ob.style.display="none";
}

function setOpacity(id,opacity){
	el=document.getElementById(id).style;
	el.opacity=(opacity / 100);
	el.MozOpacity=(opacity / 100);
	el.KhtmlOpacity=(opacity / 100);
	el.filter="alpha(opacity=" + opacity + ")";
	el.visibility="visible";
}

function showCategories( Count ){
	sel=document.getElementById('down_cat');
	for(var i=1; i<=Count; i++){
		if(i==sel.value){
			obs=document.getElementById('cate_'+sel.value);
			obs.style.display="block";
			obs.style.visibility="visible";
		}else if(sel.value=='all'){
			obss=document.getElementById('cate_'+i);
			obss.style.display="block";
			obss.style.visibility="visible";
		}else{
			obh=document.getElementById('cate_'+i);
			obh.style.display="none";
			obh.style.visibility="hidden";
		}
	}
}

function iLeft(text,separator) {
  var i=text.indexOf(separator);
  if (i>0)
    return(text.substr(0,i));
  else
    return(text);
}

function iRight(text,separator) {
  var i=text.indexOf(separator);
  if (i>0)
    return(text.substr(i+separator.length));
  else
    return('');
}

function iLeftBack(text,separator) {
  var i=text.lastIndexOf(separator);
  if (i>0)
    return(text.substr(0,i));
  else
    return(text);
}

function iRightBack(text,separator) {
  var i=text.indexOf(separator);
  if (i>0)
    return(text.substr(i+separator.length));
  else
    return('');
}

var iWindow = {};
document.iSwitch=0;

function iShow(id) {
	var href=iLeft(document.location.href,'?');
	//href=iPath+'products/show.jsp?id='+id;
	href+='?language=pl&site=pages&name=product%2Fshow&__rid='+id;
	if(id=='test'){
		iWindow=window.open("popup.html",'','toolbar=no,menubar=no,scrollbars=yes,resizable=yes,height=520,width=440,left=100,top=100');
	} else {
		iWindow=window.open(href,'','toolbar=no,menubar=no,scrollbars=yes,resizable=yes,height=520,width=440,left=100,top=100');
	}
	window.onfocus=iClose;
}

function iClose(){
  if (document.iSwitch==0){
    iWindow.close();
    window.onfocus='';
    iWindow={};
  } else {
    return true;
  }
}
