// remove the registerOverlay call to disable the controlbar
hs.registerOverlay({
	thumbnailId: null,
	overlayId: 'controlbar',
	position: 'top right',
	hideOnMouseOut: true
});
hs.graphicsDir = 'js/highslide/graphics/';
hs.outlineType = 'rounded-white';
// Tell Highslide to use the thumbnail's title for captions
hs.captionEval = 'this.thumb.title';

function trim(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function validateEmail(val)
{
	var expr=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var result=expr.test(val);
	return result;
}

function validatePrice(val)
{

	//checking number validation 
	//--------------------------------------------------------- 

	var cur = /^-?\d{1,3}(,\d{3})*(\.\d{1,2})?$/; 
	var anum= /(^-?\d+$)|(^-?\d+\.\d+$)/; 
	var ret = false; 
	
	if(val.indexOf(",")>-1)
	{
		
		val=val.replace(",",".");

	}

	if(val.indexOf(",")>-1) 
	ret = cur.test(val); 
	else 
	ret = anum.test(val); 

	if(!ret) return false;  
	else return true;

}

function is_number(nr)
{
	
	var expr=/\D/g; 
	var result=expr.test(nr);
	
	if(result) return false; 
	else return true;
	
}

function in_array(string, array2)
{
	 
	var r=false;
	for(j=0;j<array2.length;j++)
	{	
		if(array2[j]==string) r=true;
	}

	return r;
}

function getExtensionByName(filename)
{
	
	var text=filename.split(".");
	var len=text.length-1;
	var ext=text[len];

	return ext.toLowerCase();

}

function openBox(type, boxid)
{
	
	var boxtop=document.getElementById(type+"top_"+boxid);
	var boxmiddle=document.getElementById(type+"middle_"+boxid);
	var boxbottom=document.getElementById(type+"bottom_"+boxid);
	
	boxtop.className=type+"top"+" open";
	boxmiddle.style.display="block";
	boxbottom.style.display="block";

}

function closeBox(type, boxid)
{
	
	var boxtop=document.getElementById(type+"top_"+boxid);
	var boxmiddle=document.getElementById(type+"middle_"+boxid);
	var boxbottom=document.getElementById(type+"bottom_"+boxid);
	
	boxtop.className=type+"top";
	boxmiddle.style.display="none";
	boxbottom.style.display="none";
	
}


function pressProdTab(tabnr)
{

	if(document.getElementById("prodtab1"))
	{
		document.getElementById("proddetails1").style.display="none";
		document.getElementById("prodtab1").className="tab";
		document.getElementById("prodtablink1").className="";
	}

	if(document.getElementById("prodtab2"))
	{
		document.getElementById("proddetails2").style.display="none";
		document.getElementById("prodtab2").className="tab";
		document.getElementById("prodtablink2").className="";
	}
	
	if(document.getElementById("prodtab3"))
	{
		document.getElementById("proddetails3").style.display="none";
		document.getElementById("prodtab3").className="tab";
		document.getElementById("prodtablink3").className="";
	}
	
	if(document.getElementById("prodtab4"))
	{
		document.getElementById("proddetails4").style.display="none";
		document.getElementById("prodtab4").className="tab";
		document.getElementById("prodtablink4").className="";
	}
	
	if(document.getElementById("prodtab5"))
	{
		document.getElementById("proddetails5").style.display="none";
		document.getElementById("prodtab5").className="tab";
		document.getElementById("prodtablink5").className="";
	}
	
	if(document.getElementById("prodtab6"))
	{
		document.getElementById("proddetails6").style.display="none";
		document.getElementById("prodtab6").className="tab";
		document.getElementById("prodtablink6").className="";
	}

	document.getElementById("prodtab"+tabnr).className="tab selected";
	document.getElementById("prodtablink"+tabnr).className="selected";
	document.getElementById("proddetails"+tabnr).style.display="block";

}

function getRegionNameFromFlash(region)
{
	if(document.getElementById("regionsSelect"))
	{
		for(i=0;i<document.getElementById("regionsSelect").options.length;i++)
		{
			var text=document.getElementById("regionsSelect").options[i].text;
			var val=document.getElementById("regionsSelect").options[i].value;
			if(text==region)
			{
				document.getElementById("regionsSelect").value=val;
				break;
			}
		}
	}
}

function popUp(urlnow, namenow, widthnow, heightnow, activation) 
{ 
	mywindowopen = window.open(urlnow, "ramzes", 'width='+widthnow+',height='+heightnow+',toolbar=no,focus=yes,menubar=no,location=no,scrollbars=yes,resizable=yes,status'); 
	if(activation) mywindowopen.focus(); 
}

function printSite(server)
{
	if(document.getElementById("middlecol"))
	{
		popUp(server+"/print_site.php?id=middlecol&sitename=ramzes","ramzes",590,500,1);
	}
}


// TOP SEARCH //
function fillTopSearchField()
{
	var d=document.topsearchform;
	if(trim(d.key.value)=="szukaj...") d.key.value="";
	else if(trim(d.key.value)=="") d.key.value="szukaj...";
}

function checkTopSearachForm()
{
	var d=document.topsearchform;
	if(trim(d.key.value)=="szukaj..." || !trim(d.key.value))
	{
		alert("Wpisz słowo do wyszukania!");
		d.key.focus();
		return false;
	}
	return true;
}

/* search in subpage */
function fillSearchField()
{
	var d=document.searchform;
	if(trim(d.key.value)=="szukaj...") d.key.value="";
	else if(trim(d.key.value)=="") d.key.value="szukaj...";
}

function checkSearchForm()
{
	var d=document.searchform;
	if(trim(d.key.value)=="szukaj..." || !trim(d.key.value))
	{
		alert("Wpisz słowo do wyszukania!");
		d.key.focus();
		return false;
	}
	return true;
}

function Browser() 
{

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var ns = (navigator.appName.indexOf("Netscape") != -1);
var browser = new Browser();

function JSFX_FloatDiv(id, sx, sy)
{
	
	var d = document;
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	//var px = document.layers ? "" : "px";
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;
	el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};

	el.floatIt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0) 
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.floatIt()", 20);
	}
	return el;
}


function JSFX_FloatDivLeftRightColumns(id, sx, sy)
{
	
	var d = document;
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	//var px = document.layers ? "" : "px";
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;
	el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};

	el.floatIt4LeftRightColumns=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		
		if(this.sy<0) 
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		
		var maxpY=document.getElementById("columns").offsetHeight*1-document.getElementById(id).offsetHeight*1;
		
		maxpY*=1;
		
		//alert(maxpY);

		var countPY=0;

		if(pY-350>maxpY) countPY=maxpY;
		else if(pY>350) countPY=pY-350;

		this.cx += (pX + this.sx - this.cx)/8;
		this.cy += (countPY + this.sy - this.cy)/8;
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.floatIt4LeftRightColumns()", 20);
	}
	return el;
}

function checkFlash()
{
	var flashPlayerExists=1;
	if(flashPlayerExists)
	{
		document.body.className = 'bodyflash';
	}
}
