//** Tab Content script- � Dynamic Drive DHTML code library (http://www.dynamicdrive.com)

//** Last updated: June 29th, 06



var enabletabpersistence=1 //enable tab persistence via session only cookies, so selected tab is remembered?



////NO NEED TO EDIT BELOW////////////////////////

var tabcontentIDs=new Object()



function expandcontent(linkobj){
var ulid=linkobj.parentNode.parentNode.id //id of UL element
var ullist=document.getElementById(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents
for (var i=0; i<ullist.length; i++){
ullist[i].className=""  //deselect all tabs
if (typeof tabcontentIDs[ulid][i]!="undefined") //if tab content within this array index exists (exception: More tabs than there are tab contents)
document.getElementById(tabcontentIDs[ulid][i]).style.display="none" //hide all tab contents
}

linkobj.parentNode.className="selected"  //highlight currently clicked on tab
document.getElementById(linkobj.getAttribute("rel")).style.display="block" //expand corresponding tab content
saveselectedtabcontentid(ulid, linkobj.getAttribute("rel"))
}



function savetabcontentids(ulid, relattribute){// save ids of tab content divs
if (typeof tabcontentIDs[ulid]=="undefined") //if this array doesn't exist yet
tabcontentIDs[ulid]=new Array()
tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute

}

function saveselectedtabcontentid(ulid, selectedtabid){ //set id of clicked on tab as selected tab id & enter into cookie
if (enabletabpersistence==1) //if persistence feature turned on
setCookie(ulid, selectedtabid)

}



function getullistlinkbyId(ulid, tabcontentid){ //returns a tab link based on the ID of the associated tab content
var ullist=document.getElementById(ulid).getElementsByTagName("li")
for (var i=0; i<ullist.length; i++){
if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
return ullist[i].getElementsByTagName("a")[0]
break

}

}

}



function initializetabcontent(){
for (var i=0; i<arguments.length; i++){ //loop through passed UL ids
if (enabletabpersistence==0 && getCookie(arguments[i])!="") //clean up cookie if persist=off
setCookie(arguments[i], "")
var clickedontab=getCookie(arguments[i]) //retrieve ID of last clicked on tab from cookie, if any
var ulobj=document.getElementById(arguments[i])
var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
for (var x=0; x<ulist.length; x++){ //loop through each LI element
var ulistlink=ulist[x].getElementsByTagName("a")[0]
if (ulistlink.getAttribute("rel")){
savetabcontentids(arguments[i], ulistlink.getAttribute("rel")) //save id of each tab content as loop runs
ulistlink.onclick=function(){
expandcontent(this)
return false
}

if (ulist[x].className=="selected" && clickedontab=="") //if a tab is set to be selected by default
expandcontent(ulistlink) //auto load currenly selected tab content
}
} //end inner for loop
if (clickedontab!=""){ //if a tab has been previously clicked on per the cookie value
var culistlink=getullistlinkbyId(arguments[i], clickedontab)
if (typeof culistlink!="undefined") //if match found between tabcontent id and rel attribute value
expandcontent(culistlink) //auto load currenly selected tab content

else //else if no match found between tabcontent id and rel attribute value (cookie mis-association)
expandcontent(ulist[0].getElementsByTagName("a")[0]) //just auto load first tab instead
}
} //end outer for loop
}

function getCookie(Name){ 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

function setCookie(name, value){

document.cookie = name+"="+value //cookie value is domain wide (path=/)

}

function zobrazskryt(id){
	el=document.getElementById(id).style;
	el.display = 'block';
}
function skry(id){
	el=document.getElementById(id).style;
	el.display = 'none';
}


function trim(str)
{
    return str.replace(/^\s+|\s+$/g,'');
}


function checkOBJ()
{
	var spravny = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	with(window.document.obj)
	{	
		if(document.getElementById('pzp1').checked==true)
		{
			
			if(trim(vek.value)=='')
			{
				alert('Vyplňte vek.');
				return false;
			}
			else if(trim(objem.value)=='')
			{
				alert('Vyplňte objem.');
				return false;
			}
			else if(trim(vykon.value)=='')
			{
				alert('Vyplňte výkon.');
				return false;
			}
			else if(document.getElementById('pre1').checked==false && document.getElementById('pre2').checked==false)
			{
				alert('Vyplňte prehlásenie.');
				return false;
			}
			else if(trim(email.value)=='')
			{
				alert('Vyplňte email.');
				return false;
			}
			else if(!(spravny.test(email.value)))
			{
				alert('Zlý formát emailovej adresy.');
				return false;
			}
			else if(trim(meno.value)=='')
			{
				alert('Vyplňte meno a priezvisko.');
				return false;
			}
			else if(trim(mesto.value)=='')
			{
				alert('Vyplňte mesto.');
				return false;
			}
		}
		else if(document.getElementById('pzp2').checked==true)
		{
			if(trim(email2.value)=='')
			{
				alert('Vyplňte email.');
				return false;
			}
			else if(!(spravny.test(email2.value)))
			{
				alert('Zlý formát emailovej adresy.');
				return false;
			}
			else if(trim(meno2.value)=='')
			{
				alert('Vyplňte meno.');
				return false;
			}
			else if(trim(priezvisko.value)=='')
			{
				alert('Vyplňte priezvisko.');
				return false;
			}
			else if(trim(ico.value)=='')
			{
				alert('Vyplňte R.č./IČO.');
				return false;
			}
			else if(trim(adresa.value)=='')
			{
				alert('Vyplňte adresu.');
				return false;
			}
			else if(trim(telefon.value)=='')
			{
				alert('Vyplňte telefón.');
				return false;
			}
			else if(platba.options[platba.selectedIndex].value=='0')
			{
				alert('Zvoľte typ platby.');
				return false;
			}			
			else if(trim(znacka.value)=='')
			{
				alert('Vyplňte továrenskú značku.');
				return false;
			}
			else if(trim(typ.value)=='')
			{
				alert('Vyplňte typ (vozidla).');
				return false;
			}
			else if(trim(rokvyroby.value)=='')
			{
				alert('Vyplňte rok výroby.');
				return false;
			}
			else if(trim(spz.value)=='')
			{
				alert('Vyplňte ŠPZ.');
				return false;
			}
			else if(trim(seria.value)=='')
			{
				alert('Vyplňte Séria a číslo TP.');
				return false;
			}
			else if(trim(vin.value)=='')
			{
				alert('Vyplňte VIN.');
				return false;
			}
			else if(trim(farba.value)=='')
			{
				alert('Vyplňte farbu/metalízu.');
				return false;
			}
			else if(trim(miest.value)=='')
			{
				alert('Vyplňte počet miest na sedenie.');
				return false;
			}
			else if(trim(seria.value)=='')
			{
				alert('Vyplňte Séria a číslo TP.');
				return false;
			}
			else if(trim(maxr.value)=='')
			{
				alert('Vyplňte max. rýchlosť.');
				return false;
			}
			else if(trim(seria.value)=='')
			{
				alert('Vyplňte Séria a číslo TP.');
				return false;
			}
			else if(trim(objem2.value)=='')
			{
				alert('Vyplňte objem.');
				return false;
			}
			else if(trim(vykon2.value)=='')
			{
				alert('Vyplňte výkon.');
				return false;
			}
			else if(trim(hmotnost2.value)=='')
			{
				alert('Vyplňte hmotnosť vozidla.');
				return false;
			}
			else if(trim(druhpaliva2.value)=='')
			{
				alert('Vyplňte druh paliva.');
				return false;
			}
				
		}	
	}
	return true;
}

function zobraz(poziadavka)
{
	if(poziadavka.options[poziadavka.selectedIndex].value=='0' || poziadavka.options[poziadavka.selectedIndex].value=='2')
	{
		document.getElementById('sfoto').style.display = 'none';
		document.getElementById('foto').style.display = 'none';
		document.getElementById('odmena').style.display = 'none';
	}
	else{
		document.getElementById('sfoto').style.display = 'block';
		document.getElementById('foto').style.display = 'block';
		document.getElementById('odmena').style.display = 'block';
	}
}

function check_reality(form)
{
	var spravny = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	with(form){
		if(poziadavka.options[poziadavka.selectedIndex].value=='0')
		{
			alert('Zvoľte typ požiadavky.');
			return false;
		}
		else if(typ.options[typ.selectedIndex].value=='0')
		{
			alert('Zvoľte typ nehnuteľnosti.');
			return false;
		}
		else if(kraj.options[kraj.selectedIndex].value=='0')
		{
			alert('Zvoľte kraj.');
			return false;
		}
		else if(trim(lokalita.value)=='')
		{
			alert('Vyplňte lokalitu.');
			return false;
		}
		else if(trim(popis.value)=='')
		{
			alert('Vyplňte popis nehnuteľnosti.');
			return false;
		}
		else if(trim(cena.value)=='')
		{
			alert('Vyplňte cenu.');
			return false;
		}
		else if(trim(heslo.value)=='' || (trim(heslo.value)).length < 5)
		{
			alert('Vyplňte heslo - minimálne 5 znakov.');
			return false;
		}
		else if(trim(heslo.value)!=trim(heslo2.value))
		{
			alert('Hesla nesúhlasia.');
			return false;
		}
		else if(trim(meno.value)=='')
		{
			alert('Vyplňte meno a priezvisko.');
			return false;
		}
		else if(trim(adresa.value)=='')
		{
			alert('Vyplňte adresu.');
			return false;
		}
		else if(trim(telefon.value)=='')
		{
			alert('Vyplňte telefón.');
			return false;
		}
		else if(trim(email.value)=='')
		{
			alert('Vyplňte email.');
			return false;
		}
		else if(!(spravny.test(email.value)))
		{
			alert('Zlý formát emailovej adresy.');
			return false;
		}
		else if(poziadavka.options[poziadavka.selectedIndex].value=='1' && trim(odmena.value)=='')
		{
			alert('Vyplňte odmenu za sprostredkovanie.');
			return false;
		}
		else if(s1.checked==false || s2.checked==false || s3.checked==false)
		{
			alert('Musíte súhlasiť s podmienkami vo všetkých troch bodoch!');
			return false;
		}
		else return true;
	}	
}