var obraz=null;
function zvetsi(base,cesta,titul,alt,x,y,jazyk) {
	var sb="no";
	if (x>(screen.width-50)) {
		x=(screen.width-50);
		sb="yes";
	}
	if (y>(screen.height-50)) {
		y=(screen.height-50);
		sb="yes";
	}
	var winl = (screen.width-x)/2;
	var wint = (screen.height-y)/2;
	obraz=window.open("/zvetsi_nav.php?nazev="+titul+"&cesta="+cesta+"&alt="+alt+"&jazyk="+jazyk, "obraz", "width="+(x)+", height="+(y)+", top="+wint+", left="+winl+", menubar=no, directories=no, toolbar=no, location=no, status=no, scrollbars="+sb+", resizable=yes");
	obraz.window.focus();
}
var vokno=null;
function okno(prm, x, y) {
	var sb="yes";
	if (!x) var x=500;
	if (!y) var y=600;
	if (x>(screen.width-100)) {
		x=(screen.width-100);
		sb="yes";
	}
	if (y>(screen.height-100)) {
		y=(screen.height-100);
		sb="yes";
	}
	var winl = (screen.width-x)/2;
	var wint = (screen.height-y)/2;
	vokno=window.open("/okno.php"+prm, "vokno", "width="+(x)+", height="+(y)+", top="+wint+", left="+winl+", menubar=no, directories=no, toolbar=no, location=no, status=no, scrollbars="+sb+", resizable=yes");
	vokno.window.focus();
}
function wind(prm, x, y, title) {
	var sb="yes";
	if (!title) var title="Shirley";
	if (!x) var x=500;
	if (!y) var y=600;
	if (x>(screen.width-100)) {
		x=(screen.width-100);
		sb="yes";
	}
	if (y>(screen.height-100)) {
		y=(screen.height-100);
		sb="yes";
	}
	var winl = (screen.width-x)/2;
	var wint = (screen.height-y)/2;
	vokno=window.open("http://shirleyofhollywood.cz/window.php"+prm+"&title="+title, "vokno", "width="+(x)+", height="+(y)+", top="+wint+", left="+winl+", menubar=no, directories=no, toolbar=no, location=no, status=no, scrollbars="+sb+", resizable=yes");
	vokno.window.focus();
}

function chtext(prm) {
	var ch = document.getElementById(prm);
	ch.innerHTML="Data budou aktualizována po znovu načtení stránky.";
}

function chboxtd(prm) {
	var ch = document.getElementById(prm);
	if (ch.checked==true) ch.checked=false;
	else ch.checked=true;
}

function getEM(name, parent) {
     var output = Array();
     if (!parent) parent = document;
     var tags = parent.getElementsByTagName('*');
     for (i = 0; i<tags.length; i++){
          if (tags[i].name == name){
               output[output.length] = tags[i];
          }
     }
     return output;
}
function MMenu() {
	var msmenu = document.getElementById('wmenu');
	for (i = 0; i < msmenu.childNodes.length; i++) {
		var ul = msmenu.childNodes[i];
		alert(ul.name);
	}
}

function rovnej() {
	if ($('w1')) var w1=$('w1').getStyle('height').toInt();
	if ($('w2')) var w2=$('w2').getStyle('height').toInt();
	if ($('w3')) var w3=$('w3').getStyle('height').toInt();
	if ($('top')) var top=$('top').getStyle('height').toInt();
	if ($('bottom')) var bottom=$('bottom').getStyle('height').toInt();
	var stred;

	var w1width=$('w1').getStyle('width').toInt();
	if ($('w3')) {
		var w3width=$('w3').getStyle('width').toInt();
		w1width=w1width-w3width;
		$('w1').setStyle("width", w1width+"px");
		w1=$('w1').getStyle('height').toInt();
		w3left=w1width;
		if ($('w2')) {
			var w2width=$('w2').getStyle('width').toInt();
			w1left=w2width;
			w1width=w1width-w2width;
			w3left=w1width+w2width;
			$('w1').setStyle("width", w1width+"px");
			w1=$('w1').getStyle('height').toInt();
			if ((w3>w2) && (w3>w1)) stred=w3;
			if ((w2>w1) && (w2>w3)) stred=w2;
			if ((w1>w2) && (w1>w3)) stred=w1;
		}
		else {
			if (w2>w1) stred=w2;
			else stred=w1;
		}
	}
	else {
		if ($('w2')) {
			var w2width=$('w2').getStyle('width').toInt();
			w1width=w1width-w2width;
			$('w1').setStyle("width", w1width+"px");
			w1=$('w1').getStyle('height').toInt();
			w1left=w2width;
			if (w2>w1) stred=w2;
			else stred=w1;
		}
		else {
			stred=w1;
		}
	}

	if ($('w3')) {
		$('w3').setStyle("height", stred+"px");
		$('w3').setStyle("margin-top", top+"px");
		$('w3').setStyle("margin-left", w3left+"px");
	}
	if ($('w2')) {
		$('w2').setStyle("height", stred+"px");
		$('w2').setStyle("margin-top", top+"px");
	}
	if ($('w1')) {
		$('w1').setStyle("height", stred+"px");
		$('w1').setStyle("margin-top", top+"px");
		if ($('w2') || $('w3')) {
			$('w1').setStyle("margin-left", w1left+"px");
			//$('w1').setStyle("width", w1width+"px");
		}
	}
	$('bottom').setStyle("margin-top", stred+top+"px");
//	alert(w3width+'/'+w3left);
}

function sendRequest2(data,kam,url,method,mode,header){
    var objhttp=(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');
    if(!objhttp){alert('Vas prohlizec nepodporuje pozadovane funkce.');return;}
    if(!url) url='helper2.php';
    if(!data) data='';
    if(!method) method='POST';
    if(!mode) mode=true;
    if(!header) header='Content-Type:application/x-www-form-urlencoded; charset=windows-1250';

    objhttp.open(method,url,mode);
    objhttp.setRequestHeader(header.split(':')[0],header.split(':')[1]);
    objhttp.onreadystatechange=function() {
        if (objhttp.readyState==4 && objhttp.status==200) {
			var back=objhttp.responseText;
			if (!kam) {
				alert(back);
			}
			else writeCont(back, kam);
		}
    }
    objhttp.send(data);
    //loading();
}
function writeCont(co, kam) {
//	alert(co);
	if (co) kam.innerHTML=co;
	else kam.innerHTML+="Bohužel, problém s daty.";
	//loadingOff();
}
function makeRequest(url, kam) {
    var httpRequest;
    if (window.XMLHttpRequest) {
        httpRequest = new XMLHttpRequest();
        if (httpRequest.overrideMimeType) {
            httpRequest.overrideMimeType('text/xml');
        }
    }
    else if (window.ActiveXObject) {
        try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch (e) {
            try {httpRequest = new ActiveXObject("Microsoft.XMLHTTP");}
        	catch (e) {}
    	}
	}
    if (!httpRequest) {return false;}
    httpRequest.onreadystatechange = function() { writeContents(httpRequest, kam); };
    httpRequest.open('GET', url, true);
    httpRequest.send('');
}
function writeContents(httpRequest, kam) {
    if (httpRequest.readyState == 4) {
		if (httpRequest.status == 200) kam.innerHTML=httpRequest.responseText;
		else kam.innerHTML+="Bohužel, problém s daty.";
    }
}
function chbasketm(vclient) {
	var kam=document.getElementById("kosik");
	makeRequest('helper.php?basket='+vclient+'&main=1', kam);
}
function is_empty(prom) {
	if ((prom=='undefined') || (prom=='') || (prom==false) || (prom==0) || (prom=='0')) return true;
	return false;
}
function is_integer(prom) {
	var vzor=/^[\d]*\.?\d+$/;
	if (vzor.test(prom)==false) return false;
	return true;
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
function remN() {
	var prm=document.getElementById("remname");
	var prm2=document.getElementById("j");
	if (prm.checked) {
		if (prm2.value!='') createCookie("aol", prm2.value, 360);
	}
	else eraseCookie("aol");
}
function remH() {
	var prm=document.getElementById("rempass");
	var prm2=document.getElementById("h");
	if (prm.checked) {
		if (prm2.value!='') createCookie("aop", prm2.value, 360);
	}
	else eraseCookie("aop");
}
function remcheck() {
	var a=readCookie("aol");
	if (a) {
		var prm=document.getElementById("j");
		var prm2=document.getElementById("remname");
		prm.value=a;
		prm2.checked=true;
	}
	var b=readCookie("aop");
	if (b) {
		var prm=document.getElementById("h");
		var prm2=document.getElementById("rempass");
		prm.value=b;
		prm2.checked=true;
	}
}
function remgone() {
	remN();
	remH();
}
function uObsah(prm) {
	overlib("<img src='/files/loader.gif' width='66' height='66' id='loading' alt='nahrávám..' />", STICKY, RELY, '10', CENTER);
	var data="itemlist="+prm;
	var kam=document.getElementById("overDiv");
	sendRequest2(data, kam);
}
function sObsah() {
	nd();
}
function Nokno(x, y) {
	if (!x) x=400;
	if (!y) y=400;
	if (x>(screen.width-100)) x=(screen.width-100);
	if (y>(screen.height-100)) y=(screen.height-100);
	var winl=screen.width/2-x/2;
	var wint=y/2;
	var ScrollTop = document.body.scrollTop;
	if (ScrollTop == 0) {
		if (window.pageYOffset)
		ScrollTop = window.pageYOffset;
		else ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	//wint=wint-ScrollTop;
	var kam=document.getElementById("KK");
	kam.style.visibility='visible';
	kam.style.top='50%';
	kam.style.left=winl+'px';
	kam.style.marginTop="-"+(wint-ScrollTop)+'px';
	kam.style.width=x+'px';
	kam.style.height=y+'px';
	window.scrollTo(winl, wint);
}
function NoknoX() {
	document.getElementById("KK").style.visibility='hidden';
}
function uDopo(prm) {
	//overlib("<img src='/files/loader.gif' width='66' height='66' id='loading' alt='nahrávám..' />", STICKY);//, WIDTH, '320', RELY, '100', CENTER
	var data="dopo="+prm;
	var kam=document.getElementById("KK");
	sendRequest2(data, kam);
	Nokno(400, 400);
}
function showStock(prm, show) {
	var data="stock="+prm+"&showstock="+show;
	var kam=document.getElementById("stockTable");
	sendRequest2(data, kam);
}
function chOpi(proid, sid) {
	//alert(sid);
	var data="chopi="+proid+"&sid="+sid;
	var kam=document.getElementById("bopi");
	sendRequest2(data, kam);
}
function markOK(pom) {
	prm=document.getElementById(pom);
	prm.style.backgroundColor='Green';
	prm.style.color='White';
	prm2=document.getElementById(pom+'ico');
	if (prm2) {
		prm2.src='files/micoOK.gif';
		prm2.title='Vyplněno správně.';
	}
}
function markNO(pom) {
	prm=document.getElementById(pom);
	prm.style.backgroundColor='Red';
	prm.style.color='White';
	prm2=document.getElementById(pom+'ico');
	if (prm2) {
		prm2.src='files/micoNO.gif';
		prm2.title='Vyplňte správně.';
	}
}
function checkemail(prm) {
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(prm)) return true;
	return false;
}
function addLinkMsg() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName('a');
	var pis='';
	for (var i=0; i < anchors.length; i++) {
		anchors[i].onmouseover = function() {
			//if (this.title) pis=this.title;
			//else pis='';
			window.status = pis;
			return true;
		}
		anchors[i].onmouseout = function() {window.status = ''; return true;}
	}
}
function pozor() {
	var ch = document.getElementById("pozor");
	if (!ch) return;
	var winW = document.documentElement.clientWidth;
	var winH = document.documentElement.clientHeight;
	var x = winW/2-100;
	var y = winH/2-150;
	ch.style.width = '200px';
	ch.style.padding = '20px';
	ch.style.border = '5px solid Red';
	ch.style.position = 'absolute';
	ch.style.top = '10%';
	ch.style.left = '50%';
	ch.style.marginLeft = '-100px';
	ch.onclick='pozoroff();';
	var zavripozor = setTimeout("pozoroff()", 5000);
}
function pozoroff() {
	var ch = document.getElementById("pozor");
	ch.style.display = 'none';
}
function prihlaseni() {
	$('KK').set('styles', {
		'width': '300px',
		'height': '200px',
		'padding': '15px',
		'top': '-200px',
		'left': '50%',
		'margin-left': '-150px',
		'visibility': 'visible',
		'background-color': 'white',
		'border': '5px solid Black',
		'opacity': '100'
	});

	var sunkk = new Fx.Morph($('KK'), {duration: '1500', transition: Fx.Transitions.Expo.easeOut});
	sunkk.start({
	    'top': ['-200', $(document.body).getScroll().y+100]
	});
	var Adotaz = new Request({link: 'chain', method: 'post', url: 'helper2.php', onSuccess: function() { $('KK').innerHTML=Adotaz.response.text; }});
	Adotaz.send("prihlaseni=1");
	return false;
}
function buy(tform, prod, vel, bar) {
	$('KK').set('styles', {
		'width': '300px',
		'height': '200px',
		'padding': '15px',
		'top': '-200px',
		'left': '50%',
		'margin-left': '-150px',
		'visibility': 'visible',
		'background-color': 'white',
		'border': '5px solid Black',
		'opacity': '100'
	});

	var sunkk = new Fx.Morph($('KK'), {duration: '1500', transition: Fx.Transitions.Expo.easeOut});
	sunkk.start({
	    'top': ['-200', $(document.body).getScroll().y+100]
	});
	var Ele='buy['+vel+']['+bar+']';
	var Adotaz = new Request({link: 'chain', method: 'post', url: 'helper2.php', onSuccess: function() { $('KK').innerHTML=Adotaz.response.text; obnovkos(); }});
	Adotaz.send("product="+prod+"&vel="+vel+"&bar="+bar+"&ks="+$(Ele).value);
	return false;
}
function clbuy() {
	var sunkk = new Fx.Morph($('KK'), {duration: '1000', transition: Fx.Transitions.Expo.easeIn});
	sunkk.start({
	    'top': ['-300']
	});
}
function obnovkos() {
	var Adotaz = new Request({link: 'chain', method: 'post', url: 'helper2.php', onSuccess: function() { $('kosik').innerHTML=Adotaz.response.text; }});
	Adotaz.send("obnovkos=341");
}
function sfil(dal, cat) {
	$('KK').set('styles', {
		'width': '90%',
		'height': 'auto',
		'padding': '15px',
		'top': '-200px',
		'left': '50%',
		'margin-left': '-47%',
		'visibility': 'visible',
		'background-color': 'white',
		'border': '5px solid Black',
		'opacity': '100'
	});

	var sunkk = new Fx.Morph($('KK'), {duration: '1500', transition: Fx.Transitions.Expo.easeOut});
	sunkk.start({
	    'top': ['-200', $(document.body).getScroll().y+100]
	});
	var Adotaz = new Request({link: 'chain', method: 'post', url: 'helper2.php', onSuccess: function() { $('KK').innerHTML=Adotaz.response.text; }});
	Adotaz.send("filtr="+dal+"&cat="+cat);
	return false;
}
function sfilbar(dal, cat) {
	$('KK').set('styles', {
		'width': '91%',
		'height': 'auto',
		'padding': '15px',
		'top': '-200px',
		'left': '50%',
		'margin-left': '-47%',
		'visibility': 'visible',
		'background-color': 'white',
		'border': '5px solid Black',
		'opacity': '100'
	});

	var sunkk = new Fx.Morph($('KK'), {duration: '1500', transition: Fx.Transitions.Expo.easeOut});
	sunkk.start({
	    'top': ['-200', $(document.body).getScroll().y+100]
	});
	var Adotaz = new Request({link: 'chain', method: 'post', url: 'helper2.php', onSuccess: function() { $('KK').innerHTML=Adotaz.response.text; }});
	Adotaz.send("filtrbar="+dal+"&cat="+cat);
	return false;
}
function sfilvel(dal, cat) {
	$('KK').set('styles', {
		'width': '91%',
		'height': 'auto',
		'padding': '15px',
		'top': '-200px',
		'left': '50%',
		'margin-left': '-47%',
		'visibility': 'visible',
		'background-color': 'white',
		'border': '5px solid Black',
		'opacity': '100'
	});

	var sunkk = new Fx.Morph($('KK'), {duration: '1500', transition: Fx.Transitions.Expo.easeOut});
	sunkk.start({
	    'top': ['-200', $(document.body).getScroll().y+100]
	});
	var Adotaz = new Request({link: 'chain', method: 'post', url: 'helper2.php', onSuccess: function() { $('KK').innerHTML=Adotaz.response.text; }});
	Adotaz.send("filtrvel="+dal+"&cat="+cat);
	return false;
}
function sfilprd(dal, cat) {
	$('KK').set('styles', {
		'width': '91%',
		'height': 'auto',
		'padding': '15px',
		'top': '-200px',
		'left': '50%',
		'margin-left': '-47%',
		'visibility': 'visible',
		'background-color': 'white',
		'border': '5px solid Black',
		'opacity': '100'
	});

	var sunkk = new Fx.Morph($('KK'), {duration: '1500', transition: Fx.Transitions.Expo.easeOut});
	sunkk.start({
	    'top': ['-200', $(document.body).getScroll().y+100]
	});
	var Adotaz = new Request({link: 'chain', method: 'post', url: 'helper2.php', onSuccess: function() { $('KK').innerHTML=Adotaz.response.text; }});
	Adotaz.send("filtrprd="+dal+"&cat="+cat);
	return false;
}
function cfil() {
	var sunkk = new Fx.Morph($('KK'), {duration: '1000', transition: Fx.Transitions.Expo.easeIn});
	var end=-$('KK').getStyle('height').toInt()-200;
	sunkk.start({
	    'top': [end]
	});
}
sfHover = function() {
	sfTemplate("menu");
}
sfHover2 = function() {
	sfTemplate("menujr");
}
function sfTemplate(menuname) {
	if (!document.getElementById(menuname)) return;
	var sfEls = document.getElementById(menuname).getElementsByTagName("li");
	for (var i = 0; i < sfEls.length; i++) {
		if (sfEls[i].id == "search") continue;
		sfEls[i].onmouseover = function() {
			this.className += " sfhover";
		}
		sfEls[i].onmouseout = function() {
			this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
function logincheck(ch) {
	//alert ($('j').value);
	if (($('j').value==ch) || ($('j').value=='')) return false;
	if ($('h').value=='') return false;
}
function mazser(prm) {
	prm.value="";
}

new SmoothScroll();
if (window.attachEvent) {
	window.attachEvent('onload', pozor);
	window.attachEvent('onload', addLinkMsg);
//	window.attachEvent("onload", sfHover);
//	window.attachEvent("onload", sfHover2);
}
else window.onload = function() {
		addLinkMsg();
		pozor();
}


