/**
 * funkce prohozeni divu
 */
function copyDiv2Div(elSrcId, elDstId) {
	src = document.getElementById(elSrcId);
	dst = document.getElementById(elDstId);

	// check source, destination
	if((src == null) || (dst == null)) {
	    return;
	}

	// check content
	var srcContent = src.innerHTML;
	if(srcContent.replace(/^\s+|\s+$/g, '') == '') {
		return;
	}

	// src content is put before dst content
	var tmpDst = dst.innerHtml;
	dst.innerHTML = ''; // ie bug
	dst.innerHTML = srcContent + dst.innerHTML;
}

/**
 * ad 'opona' height check
 */
function checkAdCurtainHeight() {
	var curtain = document.getElementById('chCurtain');
	if(curtain == null) {
		return;
	}
	if((curtain.offsetHeight >= 0) && (curtain.offsetHeight < 40)) {
		curtain.style.display = 'none';
	}
}

/**
 * init all ad positions
 */
function adInit() {
	// copy 'opona'
	copyDiv2Div('chCurtain_tmp', 'chCurtain');

	// check 'opona' height
	checkAdCurtainHeight();
}

function ss(w){ window.status = w; return true; }
function cs() { window.status = ''; }

function fill_form() {
	/*
	if(document.kontaktni.predmet.value == 'Problém se stažením tapety na mobil') {
		alert('Zákaznickou podporu pro posílání obrázku na mobil zajištuje MujObrazek.cz, obratte se prosím s popisem problému na tyto stránky.');
	}
	*/

	if(document.kontaktni.predmet.value == 'Helpdesk - mobilní hry') {
		if(document.kontaktni.zprava.value == '') {
			data = "Datum objednávky hry: <br>zeme objednávky(CR/SR):     <br>objednací metoda(SMS,zavoláním):      <br>telefonní císlo, ze kterého byla hra objednána:     <br>znacka a model telefonu: <br>podrobnejší popis problému: ";

			function BRtoN(myString) {
     			myString = myString.replace(/<br.*?>/ig, "\n");
     			return myString;
     		}

			document.kontaktni.zprava.value = BRtoN(data);
		}
	}

	if(document.kontaktni.predmet.value == 'Helpdesk - VIP clenství') {
		if(document.kontaktni.zprava.value == '') {
			data = "přihlašovací jméno na Superhry.cz:  <br>datum objednávky VIP:    <br>zeme objednávky(CR/SR):     <br>objednací metoda(SMS,zavoláním):     <br>telefonní císlo, ze kterého bylo VIP objednáno:     <br>podrobnejší popis problému: ";

			function BRtoN(myString) {
     			myString = myString.replace(/<br.*?>/ig, "\n");
     			return myString;
     		}

			document.kontaktni.zprava.value = BRtoN(data);
		}
	}
}

function CreateBookmarkLink() {
	title = "Superhry.cz - Online hry zdarma";
	url = "http://www.superhry.cz";

	if(window.sidebar) {							// Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url, "");
	} else if(window.external) {					// IE Favorite
		window.external.AddFavorite(url, title);
	} else if(window.opera && window.print) {		// Opera Hotlist
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
	return true;
}

function setasHome() {
	document.body.style.behavior = 'url(#default#homepage)';
	document.body.setHomePage('http://www.superhry.cz');
}

function vyhledej(submitForm) {
	if (document.vyhledavani.kde_hledat.value=='0') {
		document.vyhledavani.target='_top';
		document.vyhledavani.action='http://www.superhry.cz/search/search.php';

	} else if (document.vyhledavani.kde_hledat.value=='1') {
		document.vyhledavani.target='_blank';
		document.vyhledavani.action='http://www.superhry.cz/aukce.php?c=4&string='+document.vyhledavani.key.value;
	}

	if (document.vyhledavani.kde_hledat.value=='2')
	{
		document.vyhledavani.target='_top';
		document.vyhledavani.action='http://videa.superhry.cz/hledej/';
	}

	if (document.vyhledavani.kde_hledat.value=='5') {
		document.vyhledavani.target='_top';
		document.vyhledavani.action='http://mp3.superhry.cz';
	}

	if (document.vyhledavani.kde_hledat.value=='7')
	{
		if (document.vyhledavani.inSearch.value.length < 3) {
			window.alert('Hledaný výraz musí mít délku nejméně tři znaky');
			submitForm = false;
		}
		document.vyhledavani.target='_top';
		document.vyhledavani.action='http://profily.superhry.cz';
		document.vyhledavani.inSearch.name='name';
	}

	if(submitForm) {
		document.vyhledavani.submit();
	}
}

function nav(url) {
	top.location.href = url;
}

function postform() {
	document.nastaveni.submit();
}

function podtrhni(_prvek, _status, _c_on, _c_off) {
	if((document.getElementById)&& (document.getElementById(_prvek)!=null)) {
		var myElement = document.getElementById(_prvek);
	 	if ((myElement.style)&& (myElement.style.color!=null))
		{
			if (_status==1)
			{
				document.getElementById(_prvek).style.color = _c_on;
				document.getElementById(_prvek).style.textDecoration = 'underline';
			}
			else
			{
				document.getElementById(_prvek).style.color = _c_off;
				document.getElementById(_prvek).style.textDecoration = 'none';
			}
  		}else
		{
			return;
  		}
	}else
	{
		return;
	}
}

function Uncheckall(formid,xid) {
	frm_len = formid.length;
	for(i = 0; i < frm_len; i++) {
		if(formid.elements[i].type == "radio") {
			formid.elements[i].checked = false;
		}
	}

	if(xid==1) formid.answer1.checked=true;
	if(xid==2) formid.answer2.checked=true;
	if(xid==3) formid.answer3.checked=true;
	if(xid==4) formid.answer4.checked=true;
	if(xid==5) formid.answer5.checked=true;
	if(xid==6) formid.answer6.checked=true;
	if(xid==7) formid.answer7.checked=true;
	if(xid==8) formid.answer8.checked=true;
	if(xid==9) formid.answer9.checked=true;
	if(xid==10) formid.answer10.checked=true;
}

