function show_basket() {
	var arrayPageSize = getPageSize();
	var top_okna = 0;
	document.getElementById('dark_div').style.top = top_okna +"px";
	document.getElementById('dark_div').style.width = arrayPageSize[0] +"px";
	document.getElementById('dark_div').style.height = arrayPageSize[1]- top_okna +"px";
	document.getElementById('dark_div').style.display = 'block';
	document.getElementById('basket_div').style.display = 'block';
	document.getElementById('dark_div').onmouseover = hide_basket;
}

function hide_basket() {
	if (document.getElementById('search_div').style.display != 'block') {
		document.getElementById('dark_div').style.top = "0px";
		document.getElementById('dark_div').style.display = 'none';
		document.getElementById('basket_div').style.display = 'none';
		document.getElementById('dark_div').onmouseover = '';
	} else {
		document.getElementById('dark_div').onmouseover = '';
		document.getElementById('basket_div').style.display = 'none';
	}
} 

function show_uprava(pocet, radek_kose, event) {
	var arrayPageSize = getPageSize();
	document.getElementById('tab_dark').style.top = "0px";
	document.getElementById('tab_dark').style.width = arrayPageSize[0] +"px";
	document.getElementById('tab_dark').style.height = arrayPageSize[1] +"px";
	document.getElementById('tab_dark').style.display = '';
		document.getElementById('upravawin').style.left = (event.clientX + document.body.scrollLeft-200) +'px';
		document.getElementById('upravawin').style.top = (event.clientY + document.body.scrollTop) +'px';
		document.getElementById('upravawin').style.display = '';
		document.getElementById('pocetkusu').value = pocet;
		document.form_kosik.kos_id.value = radek_kose;
}

function hide_uprava() {
	document.getElementById('tab_dark').style.top = "0px";
	document.getElementById('tab_dark').style.display = 'none';
	document.getElementById('upravawin').style.display = 'none';
} 

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
					
				//var old_links = new Array();
					
function open_picture(obrazek, event) {
	var arrayPageSize = getPageSize();
	document.getElementById('dark_div').style.width = arrayPageSize[0]+'px';
	document.getElementById('dark_div').style.height = arrayPageSize[1]+'px';
	document.getElementById('dark_div').style.display = 'block';
	moje_okno = document.getElementById('pict_div');
	if (moje_okno.style.display == 'none') {
		souradniceY = event.clientY + document.body.scrollTop;
		souradniceX = event.clientX + document.body.scrollLeft; // dorovnani pri posunu posuvniku
		moje_okno.style.left = souradniceX +'px';
		moje_okno.style.top = souradniceY +'px';
		moje_okno.style.display = 'block';
		document.images['full_picture'].src=obrazek;
	}
	return false;
}

function close_picture() {
	document.getElementById('dark_div').style.display = 'none';
	moje_okno = document.getElementById('pict_div');
	moje_okno.style.display = 'none';
	document.images['full_picture'].src='/product_pics/waitfoto.gif';
} 

function open_gift(obrazek, event) {
	var arrayPageSize = getPageSize();
	document.getElementById('dark_div').style.width = arrayPageSize[0]+'px';
	document.getElementById('dark_div').style.height = arrayPageSize[1]+'px';
	document.getElementById('dark_div').style.zIndex = '6';	
	document.getElementById('dark_div').style.display = 'block';
	moje_okno = document.getElementById('pict_div');
	if (moje_okno.style.display == 'none') {
		if (event.pageY) souradniceY = event.pageY; // dorovnani pri posunu posuvniku
			else souradniceY = event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
		if (event.pageX) souradniceX = event.pageX; 
			else souradniceX = event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
		moje_okno.style.left = souradniceX +'px';
		moje_okno.style.top = souradniceY +'px';
		moje_okno.style.display = 'block';
		document.images['gift_picture'].src=obrazek;
	}
	return false;
}

function close_gift() {
	document.getElementById('dark_div').style.display = 'none';
	document.getElementById('dark_div').style.zIndex = '2';	
	moje_okno = document.getElementById('pict_div');
	moje_okno.style.display = 'none';
	document.images['gift_picture'].src='/product_pics/waitfoto.gif';
} 

function open_dark() {
		var arrayPageSize = getPageSize();
		document.getElementById('dark_div').style.width = arrayPageSize[0]+'px';
		document.getElementById('dark_div').style.height = arrayPageSize[1]+'px';
		document.getElementById('dark_div').style.display = 'block';	
}
function close_dark() {
	document.getElementById('dark_div').style.display = 'none';
}

var obj_httpRequest;

function ajax(stranka, kam) {
   if (!obj_httpRequest) { 
	   if (window.ActiveXObject) {
	    	try {
	    	    	//alert('Msxml2.XMLHTTP');
	    		obj_httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
	    	} catch (eror) {
	    	    	//alert('XMLHTTP');
	    		obj_httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	    	}
	    } else if (window.XMLHttpRequest) {
	    	//alert('XMLHttpRequest()');
	    	obj_httpRequest = new XMLHttpRequest();
	    } else alert('Rozšířené funkce vyžadují povolený JavaScript ...');
   }
   if (obj_httpRequest.readyState != 0) obj_httpRequest.abort(); 
   obj_httpRequest.onreadystatechange= function () {
        processRequest(obj_httpRequest, kam);
    };
   obj_httpRequest.open("GET", stranka, true);
   obj_httpRequest.send(null);
}


function processRequest(httpRequest, kam) 
{
    if (httpRequest.readyState == 4)
    {
        if(httpRequest.status == 200)
        {
            if (typeof kam == 'string') 
            {
            	var xDoc = httpRequest.responseXML.documentElement;
            	var alltext = xDoc.getElementsByTagName('alltext')[0].childNodes[0].nodeValue;
            	document.getElementById(kam).innerHTML = alltext;
            	window.status = (xDoc.getElementsByTagName('resultcount')[0].childNodes[0].nodeValue);
            	//alert(n_text);
                //document.getElementById(kam).innerHTML = httpRequest.responseText;
            }
            if (typeof kam == 'function') 
            {
                kam(httpRequest.responseText);
            }
        }
        else
        {
            //alert("Chyba pri nacitani stanky " + httpRequest.status +" : "+ httpRequest.statusText);
        	//alert("Chyba pri nacitani stanky " + httpRequest.status);
        }
    }
    else
    {
        if (typeof kam == 'string' && kam != '') 
        {
            document.getElementById(kam).innerHTML = '<img src="/_design/waiting.gif" id="waitingimg"/> probíhá rychlé hledání';
        }
    }
       
} 

var last_hledano;
var last_timeout;

function instant_search(hledano) {
	if (hledano.length && (hledano!=last_hledano)) {
		last_hledano = hledano;
		clearTimeout(last_timeout);
		last_timeout = setTimeout("open_dark();document.getElementById('search_div').style.display = 'block';ajax('/?pid=200&q="+hledano+"','search_div');", 200);
		//open_dark();
	}
	if (!hledano.length) clearTimeout(last_timeout);
}
function instant_search_close() {
	document.getElementById('search_div').style.display = 'none';
	close_dark();
}

// podchytime jiny ty fontu pro win WP :
//alert(navigator.userAgent);
if (navigator.userAgent.indexOf("Windows NT 6.0") == -1) { 
	// no Windows vista
	document.write('<style>#logo h1 {font-size: 22px;}</style>');
	} 


