/*

*/

function toggleDiv(id,flagit) {
	if (flagit=="1"){
		if (document.layers) document.layers[''+id+''].visibility = "show"
		else if (document.all) document.all[''+id+''].style.visibility = "visible"
		else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
	}

	else
	if (flagit=="0"){
		if (document.layers) document.layers[''+id+''].visibility = "hide"
		else if (document.all) document.all[''+id+''].style.visibility = "hidden"
		else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
	}
}


function changeImage(filename, name){
    document.mainimage.src = filename;
    nameV = document.getElementById('pictName');
    
    if (document.all) { // IE;
		nameV.innerText = name;
	} else {
		nameV.textContent = name;
	} 
    
}

function doDelete(what) {
	var q;
	q = 'Opravdu chcete koupit tuto položku? \n Položka bude závazně objednána. ';
    if(confirm(q)){
        return true;
    } else {
        return false;
    }
}
function doMessage(what) {
    if(confirm(what)){
        return true;
    } else {
        return false;
    }
}

function extpict(picture)
{
	titlename = 'BLUE-STYLE - obrázek';
	defwidth  = 350;
	defheight = 350;
	bgcolor   = '#ffffff'; // barva pozadí
	text      = '#000000'; // barva textu
	alttext   = 'Kliknutím na obrázek zavřete okno'; // text, ktery nabidk
	winname   = ''; // jmeno oteviraneho okna

	// fyzické rozlisení obrazovky
	scw = window.screen.availWidth-29;
	sch = window.screen.availHeight;

	// pozice na středu otevřeného okna
	wleft = scw/2-defwidth/2;
	wtop = sch/2-defheight/2;

	Preview = window.open('', winname, 'resizable=1, status=0, menubar=0, location=0, directories=0, scrollbars=1, width='+defwidth+', height='+defheight+', top='+wtop+', left='+wleft);
	Preview.document.write('<html><head><title>'+titlename+' ('+picture+')</title></head>');
	Preview.document.write('\n<script language="JavaScript">\n');
	Preview.document.write('function sizeImg(){\n');
	Preview.document.write('winwidth=document.all.foto.width+28;\n');
	Preview.document.write('winheigh=document.all.foto.height+31;\n');
	Preview.document.write('if (winwidth>'+scw+') winwidth='+scw+';\n');
	Preview.document.write('if (winheigh>'+sch+') winheigh='+sch+';\n');
	Preview.document.write('wtop='+(sch/2)+'-winheigh/2;\n');
	Preview.document.write('wleft='+(scw/2)+'-winwidth/2;\n');
	Preview.document.write('if (wtop<0) wtop=0;\n');
	Preview.document.write('if (wleft<0) wleft=0;\n');
	Preview.document.write('window.moveTo(wleft, wtop);\n'); // změna velikosti okna
	Preview.document.write('window.resizeTo(winwidth,winheigh);\n'); // změna velikosti okna
//	Preview.document.write('window.scrollbars=1;\n');
	Preview.document.write('}\n');
	Preview.document.write('</script>\n');
	Preview.document.write('<body onLoad="sizeImg()" bgcolor="'+bgcolor+'" text="'+text+'" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" bottommargin="0">');
	Preview.document.write('<a href="javascript:window.close();">');
	Preview.document.write('<img src="' + picture + '" border="0" id="foto" alt="' + alttext + '" hspace="0" vspace="0">');
	Preview.document.write('</a>');
	Preview.document.write('</body></html>');
	Preview.document.close();
}


	/**
	 * Set active bookmark and div
	 */
	function Zalozka(i, id) {
		if (!id) id = '';
		var z = document.getElementById('zalozky'+id);
		var nodes = z.childNodes;
		var pocet = 0;
		for (ii=0;ii<nodes.length;ii++) {
			x = nodes.item(ii);
			if (x.nodeType == 1) {
				if (x.className.indexOf('act') == 0) pocet += 1;
				if (pocet == i) {
					x.className = x.className.replace('1', '2');
				} else {
					x.className = x.className.replace('2', '1');
				}
			}
		}
		z = document.getElementById('zalozky'+id+'obsah');
		nodes = z.childNodes;
		pocet = 0;
		for (ii=0;ii<nodes.length;ii++) {
			x = nodes.item(ii);
			if (x.nodeType == 1) {
				pocet += 1;
				if (x.className == 'show') x.className = 'hide';
				if (pocet == i) x.className = 'show';
			}
		}
	}
	
	function blockActivate(elm) {
		elm.className += ' blockactive';
	}
	
	function blockDeactivate(elm) {
		elm.className = elm.className.replace(' blockactive','');
	}

	/**
	 * Reset value if empty or default
	 * 
	 */
	function resetValue(elm, text) {
		if(elm.value == '' || elm.value == text) {
			elm.value = '';
		} 
	}
	
	/**
	 * Set value on onblur action
	 * Only if is empty, or default 
	 */
	function setIfEmpty(elm, text) {
		if(elm.value == '' || elm.value == text) {
			elm.value = text;
		}
	}
	
	/**
	 * CallBack 
	 */
	function call_back()
    {
		var phonee = document.getElementById('cb_phone');
		var messagee = document.getElementById('cb_message');
				
    	if (phonee.value.length == 0 || phonee.value == 'Váš telefon') { vypisText('<div class="alert">Zadejte telefon!</div>', 'callBackMessage'); return; };
    	if (messagee.value.length == 0 || messagee.value == 'Váš dotaz') { vypisText('<div class="alert">Vyplňte dotaz!</div>', 'callBackMessage'); return; };
    	do_call_back(phonee.value, messagee.value);
    }
	
	function do_call_back(phonee, messagee) {

	    var hlavicka = document.getElementsByTagName('head')[0];
	    var dataLoader = document.getElementById('scriptLoader');
	    if(dataLoader) hlavicka.removeChild(dataLoader);
	
	    script = document.createElement('script');
	    script.id = 'scriptLoader';
	    script.src = '/utils/callBack.php?phone='+phonee+'&message='+messagee;

	    x = document.getElementsByTagName('head')[0];
	    x.appendChild(script);

	    return false;
	}
	
	/**
	 * CallBack in web page
	 */
	function user_call_back()
    {
		var phonee = document.getElementById('cb_phone');
		var messagee = document.getElementById('cb_message');
				
    	if (phonee.value.length == 0 || phonee.value == 'Váš telefon') { vypisText('<div class="alert">Zadejte telefon!</div>', 'callBackMessage'); return; };
    	if (messagee.value.length == 0 || messagee.value == 'Váš dotaz') { vypisText('<div class="alert">Vyplňte dotaz!</div>', 'callBackMessage'); return; };
    	do_user_call_back(phonee.value, messagee.value);
    }
	
	function do_user_call_back(phonee, messagee) {

	    var hlavicka = document.getElementsByTagName('head')[0];
	    var dataLoader = document.getElementById('scriptLoader');
	    if(dataLoader) hlavicka.removeChild(dataLoader);
	
	    script = document.createElement('script');
	    script.id = 'scriptLoader';
	    script.src = '/utils/callBack.php?phone='+phonee+'&message='+messagee+'&type=user';

	    x = document.getElementsByTagName('head')[0];
	    x.appendChild(script);

	    return false;
	}
	
	/**
	 * Newsletter in web page
	 */
	function user_newsletter()
    {
		var emaill = document.getElementById('cb_email');
				
    	if (emaill.value.length == 0 || emaill.value == 'Váš e-mail') { vypisText('<div class="alert">Zadejte e-mail!</div>', 'newsletterMessage'); return; };
    	do_user_newsletter(emaill.value);
    }
	
	function do_user_newsletter(emaill) {

	    var hlavicka = document.getElementsByTagName('head')[0];
	    var dataLoader = document.getElementById('scriptLoader');
	    if(dataLoader) hlavicka.removeChild(dataLoader);
	
	    script = document.createElement('script');
	    script.id = 'scriptLoader';
	    script.src = '/utils/newsletter.php?email='+emaill;

	    x = document.getElementsByTagName('head')[0];
	    x.appendChild(script);

	    return false;
	}
	
	function over_jmeno()
    {
		var domain = document.getElementById('domain_name');
    	if (domain.value.length == 0) return;
        over_login(domain.value);
    }
	
	function over_login(jmenoe) {

	    var hlavicka = document.getElementsByTagName('head')[0];
	    var dataLoader = document.getElementById('scriptLoader');
	    if(dataLoader) hlavicka.removeChild(dataLoader);
	
	    script = document.createElement('script');
	    script.id = 'scriptLoader';
	    script.src = '/utils/checkLogin.php?domain_name='+jmenoe;

	    x = document.getElementsByTagName('head')[0];
	    x.appendChild(script);

	    return false;
	}
	
	function vypisText(txt, elm) {
		vystup = document.getElementById(elm);
	    vystup.innerHTML = txt;
	}
	
	function sortGo(name, url) {
        box = document.getElementById('sort_'+name);
        location.href = url+box.options[box.selectedIndex].value;
    }


	function AddFavourite(linkObj,addUrl,addTitle)
	{
	  if (document.all && !window.opera)
	  {
	    window.external.AddFavourite(addUrl,addTitle);
	    return false;
	  }
	  else if (window.opera && window.print)
	  {
	    linkObj.title = addTitle;
	    return true;
	  }
	  else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))
	  {
	    if (window.confirm('Přidat oblíbenou stránku jako nový panel?'))
	    {
	      window.sidebar.addPanel(addTitle,addUrl,'');
	      return false;
	    }
	  }
	  window.alert('Po potvrzení stiskněte CTRL-D,\nstránka bude přidána k vašim oblíbeným odkazům.');
	  return false;
	}

	