function ShowImage(imageLink, imageWidth)
{
	document.getElementById('bigImage').src = ru + imageLink;
	document.getElementById('bigImage').width = imageWidth;
}
function ToggleView(showDiv)
{
	document.getElementById('poze').style.display = 'none';
	document.getElementById('harta').style.display = 'none';
	
	document.getElementById(showDiv).style.display = 'block';
	
	document.getElementById('buttonpoze').className = 'button-anunt';
	document.getElementById('buttonharta').className = 'button-anunt';
	
	document.getElementById('button' + showDiv).className = 'button-anunt-hover';

	if(first_initialize) 
	{
		initialize();
		first_initialize = false;
	}
}
function MakeSearch(el)
{
	if(el)
	{
		if(el == 'sCamere1' || el == 'sCamere2' || el == 'sCamere3' || el == 'sCamere4' || el == 'sCamere5')
		{
			document.forms['searchform'].elements['sCamere1'].checked = false;
			document.forms['searchform'].elements['sCamere2'].checked = false;
			document.forms['searchform'].elements['sCamere3'].checked = false;
			document.forms['searchform'].elements['sCamere4'].checked = false;
			document.forms['searchform'].elements['sCamere5'].checked = false;
			
			document.forms['searchform'].elements[el].checked = true;
		}
		if(el == 'sPret1' || el == 'sPret2' || el == 'sPret3' || el == 'sPret4' || el == 'sPret5' || el == 'sPret6' || el == 'sPret7')
		{
			document.forms['searchform'].elements['sPret1'].checked = false;
			document.forms['searchform'].elements['sPret2'].checked = false;
			document.forms['searchform'].elements['sPret3'].checked = false;
			document.forms['searchform'].elements['sPret4'].checked = false;
			document.forms['searchform'].elements['sPret5'].checked = false;
			document.forms['searchform'].elements['sPret6'].checked = false;
			document.forms['searchform'].elements['sPret7'].checked = false;
			
			document.forms['searchform'].elements[el].checked = true;
		}
		if(el == 'sSuprafata1' || el == 'sSuprafata2' || el == 'sSuprafata3' || el == 'sSuprafata4' || el == 'sSuprafata5' || el == 'sSuprafata6')
		{
			document.forms['searchform'].elements['sSuprafata1'].checked = false;
			document.forms['searchform'].elements['sSuprafata2'].checked = false;
			document.forms['searchform'].elements['sSuprafata3'].checked = false;
			document.forms['searchform'].elements['sSuprafata4'].checked = false;
			document.forms['searchform'].elements['sSuprafata5'].checked = false;
			document.forms['searchform'].elements['sSuprafata6'].checked = false;
			
			document.forms['searchform'].elements[el].checked = true;
		}
	}
	document.forms['searchform'].submit();
	
}


function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	//popUpDiv_height = (blanket_height/2) - 150; /* 150 is half popup height*/
	popUpDiv_height = 150;
	popUpDiv.style.top = popUpDiv_height + 'px';
}

function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2 - 250;//150 is half popups width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}

function SetZona(zona, nr, from)
{
	if(zona)
	{
		if(from == 'link')
			if(document.forms['searchform'].elements['sZona' + nr].checked)
				document.forms['searchform'].elements['sZona' + nr].checked = false;
			else
				document.forms['searchform'].elements['sZona' + nr].checked = true;
		
		zonainput = document.getElementById('sZona');
		zonafinal = zonainput.value;
		
		if(document.forms['searchform'].elements['sZona' + nr].checked)
		{
			// pune zona in sZona
			//alert('adaug ' + zona + ' in ' + zonafinal);
			
			if(zonafinal != '') zonafinal = zonafinal + ', ';
			zonafinal = zonafinal + zona;
		}
		else
		{
			// scoate zona din sZona
			//alert('sterg ' + zona + ' din ' + zonafinal);
			
			if(zonafinal.indexOf(", " + zona) != "-1")
				//alert('fount cu virgula');
				zonafinal = zonafinal.replace(", " + zona, "");
			else if(zonafinal.indexOf(zona) != "-1")
				//alert('fount fara virgula');
				zonafinal = zonafinal.replace(zona, "");
			
			if(zonafinal.indexOf(", ") == "0")
				zonafinal = zonafinal.replace(", ", "");
		}
		
		zonainput.value = zonafinal;
	}
}















function ChangePos(NewValue)
{
	Pos = document.getElementById('Pos');		
	Pos.value = parseInt(NewValue);
}
function open_win(file,wid,hei)
{
	window.open(file,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=yes, width="+parseInt(wid)+", height="+parseInt(hei))
}

function ShowAccType(type)
{
	//alert(type);
	div = document.getElementById('agentie');
	if(type == 'f') div.style.display = 'block';
	else div.style.display = 'none';
}
function ShowSearch()
{		
	divTip = document.getElementById('sTip');
	Tip = divTip.value;
	
	divSearchAp = document.getElementById('searchAp');
	divSearchT = document.getElementById('searchT');
	divSearchCSH = document.getElementById('searchCSH');
		
	
	divSearchAp.style.display = 'none';
	divSearchT.style.display = 'none';
	divSearchCSH.style.display = 'none';
			
					
	if(Tip == 'a') divSearchAp.style.display = 'block';
	if(Tip == 't') divSearchT.style.display = 'block';
	if(Tip == 'c') divSearchCSH.style.display = 'block';
	if(Tip == 's') divSearchCSH.style.display = 'block';
	if(Tip == 'r') divSearchCSH.style.display = 'block';

}
function ShowUser(divID)
{		
	divUser = document.getElementById(divID);
	
	if(divUser.style.display == 'none')	divUser.style.display = 'block';
	else divUser.style.display = 'none';
}
function getConfirm(message, url) 
{
	if (confirm(message)) {
		window.location = url;
	}
}

function postConfirm(message) {
	if (confirm(message) == false) {
		return false;
	}
}
