// JavaScript Document
function IsValidEmail(str) 
{
	if( str.indexOf(",") >=0 )
		return false;
	if( str.indexOf(";") >=0 )
		return false;
	if( str.indexOf("(") >=0 )
		return false;
	if( str.indexOf(")") >=0 )
		return false;
	if( str.indexOf("+") >=0 )
		return false;
	if( str.indexOf(" ") >=0 )
		return false;
	if( str.indexOf("?") >=0 )
		return false;
	if( str.indexOf("`") >=0 )
		return false;
	if( str.indexOf("#") >=0 )
		return false;
	if( str.indexOf("!") >=0 )
		return false;
	if( str.indexOf("$") >=0 )
		return false;
	if( str.indexOf("%") >=0 )
		return false;
	if( str.indexOf("*") >=0 )
		return false;
	if( str.indexOf("=") >=0 )
		return false;																										
		
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)return false
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)	return false
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)return false
		if (str.indexOf(at,(lat+1))!=-1) return false
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)return false
		if (str.indexOf(dot,(lat+2))==-1) return false
		if (str.indexOf(" ")!=-1)  return false
 		 return true					
}
function validate(form)
{
	if (form.fname.value.length == 0 ) 
	{
		alert("Introduceti \"Nume si prenume\".");
		form.fname.focus();
		return (false);
	}
	if (form.phone.value.length == 0 ) 
	{
		alert("Introduceti \"Telefon\".");
		form.phone.focus();
		return (false);
	}
	stremail=document.getElementById("email");
	if (stremail.value.length==0)
	{
		alert("Introduceti \"Adresa de email\".");
		stremail.focus();
		return (false);
	}
	if(!IsValidEmail(stremail.value))
	 {
		alert("Formatul \"Adresa de email\" este incorecta.");
		stremail.focus();
		return(false);
	}
	if (form.mesaj.value.length == 0 ) 
	{
		alert("Introduceti \"Mesaj\".");
		form.mesaj.focus();
		return (false);
	}
	if(form.captcha_code.value.length == 0 )
	{
		alert("Introduceti \"Codul din imagine\".");
		form.captcha_code.focus();
		return (false);
	}
}
function validate_contact(form)
{
	if (form.nume.value.length == 0 ) 
	{
		alert("Introduceti \"Nume si prenume\".");
		form.nume.focus();
		return (false);
	}
	if (form.telefon.value.length == 0 ) 
	{
		alert("Introduceti \"Telefon\".");
		form.telefon.focus();
		return (false);
	}
	stremail=document.getElementById("email");
	if (stremail.value.length==0)
	{
		alert("Introduceti \"Adresa de email\".");
		stremail.focus();
		return (false);
	}
	if(!IsValidEmail(stremail.value))
	 {
		alert("Formatul \"Adresa de email\" este incorecta.");
		stremail.focus();
		return(false);
	}
	if (form.mesaj.value.length == 0 ) 
	{
		alert("Introduceti \"Mesaj\".");
		form.mesaj.focus();
		return (false);
	}
	if(form.captcha_code.value.length == 0 )
	{
		alert("Introduceti \"Codul din imagine\".");
		form.captcha_code.focus();
		return (false);
	}
}
function validatesearchid(form)
{
	if(isEmpty(form.id.value))
	{
		 alert('Introduceti ID-ul ofertei');
		 form.id.focus();
		 return(false);
	}
	
}
function validatewant(form)
{
	if (form.fname.value.length == 0 ) 
	{
		alert("Introduceti \"Nume si prenume\".");
		form.fname.focus();
		return (false);
	}
	if (form.phone.value.length == 0 ) 
	{
		alert("Introduceti \"Telefon\".");
		form.phone.focus();
		return (false);
	}
	stremail=document.getElementById("email");
	if (stremail.value.length==0)
	{
		alert("Introduceti \"Adresa de email\".");
		stremail.focus();
		return (false);
	}
	if(!IsValidEmail(stremail.value))
	 {
		alert("Formatul \"Adresa de email\" este incorecta.");
		stremail.focus();
		return(false);
	}
	if(form.captcha_code.value.length == 0 )
	{
		alert("Introduceti \"Codul din imagine\".");
		form.captcha_code.focus();
		return (false);
	}
}
function isEmpty(s)
{
     return ((s == null) || (s.length == 0))
}
function isDigit (c)
   {
      return ((c >= "0") && (c <= "9"))
   }
function isInteger (s)
   {
      var i;

      if (isEmpty(s))
      if (isInteger.arguments.length == 1) return 0;
      else return (isInteger.arguments[1] == true);

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);

         if (!isDigit(c)) return false;
      }

      return true;
   }
function show_big_image(image){
	var big_image = document.getElementById('big_image');
	var lightbox = document.getElementById('lx');
	if(big_image){
		big_image.src=image;
		
	}
	if(lightbox)
	{
		
		lightbox.href= image.replace(/bigimage/,'largeimage');
	}
}
function toogle_city(c,id){
	try{
		if(c.checked) document.getElementById(id).className='citychecked';
		else 
		{
			document.getElementById(id).className='cityunchkecked';
			unckeck_wards(document.getElementById(id),0);
			
		}
	}
	catch(e){}
}
function unckeck_wards(parent,level){
	for(var i=0;i<parent.childNodes.length;i++){
		var child = parent.childNodes[i];
		if(child.nodeName=="INPUT" && child.type=='checkbox') child.checked = false;
		if(child.nodeName=='DIV') unckeck_wards(child,level+1); 
	}
}
function toogle_nrrooms(c,id){
	try{
		if(c.checked) document.getElementById(id).className='search_rooms_checked';
		else 
		{
			document.getElementById(id).className='search_rooms_unchecked';
		}
	}
	catch(e){}
}
function toogle_all()
{
	document.getElementById('search_ap').className='search_rooms_unchecked';
	document.getElementById('search_house').className='search_rooms_unchecked';
	document.getElementById('search_teren').className='search_rooms_unchecked';
	document.getElementById('search_spatii').className='search_rooms_unchecked';

}
function addInput() { 
	var parent = document.getElementById('pictures')
	var element = null;
	try { // IE
	    element.innerHTML += '<div class="caption">&nbsp;</div>\n\r<div class="caption_input"><input type="file" name="poza[]" value=""/></div>';
	    } 
	catch (e) { // W3C
	    element = document.createElement("input");
	    element.setAttribute("type", "file");
	    element.setAttribute("name", "poza[]");
	    }
	parent.appendChild(element);
}
//menu.js
function HMenu(id){
	this.init = function(el){
		if(!el) return;
		for(var i=0;i<el.childNodes.length;i++){
			if(el.childNodes[i].nodeName=='LI')
				el.childNodes[i].onmouseover = function() {
													if(!this.className.match('/_hover$/i')) this.className = this.className+'_hover';
												
												}
				el.childNodes[i].onmouseout  = function(){
													if(this.className.match('/_hover$/i')) this.className.substring(0,this.className.lenght-"_hover".lenght);
												}
		}
	}
	
	this.id = id;
	var el = document.getElementById(id);
	if(el){	
		if(el.tagName.toLowerCase()=='ul'){
			this.init(el);
		}else{
			for(var i=0;i<el.childNodes.length;i++){
				if(el.childNodes[i].nodeName=='UL')
					this.init(el.childNodes[i]);
			}
		}
	}
}
//top_menu.js
function HMenu(id){
	this.init = function(el){
		if(!el) return;
		for(var i=0;i<el.childNodes.length;i++){
			if(el.childNodes[i].nodeName=='LI')
				el.childNodes[i].onmouseover = function() {
													this.className = 'hmenu_hover';
												
												}
				el.childNodes[i].onmouseout  = function(){
													this.className = '';
												}
		}
	}
	
	this.id = id;
	var el = document.getElementById(id);
	if(el){	
		if(el.tagName.toLowerCase()=='ul'){
			this.init(el);
		}else{
			for(var i=0;i<el.childNodes.length;i++){
				if(el.childNodes[i].nodeName=='UL')
					this.init(el.childNodes[i]);
			}
		}
	}
}
menuHover=function(id){
	var name = navigator.appVersion;
	var version=name.substring(17,25);
	var menu_hover = document.getElementById(id);	
	if(version=="MSIE 6.0"){
		menu_hover.style.backgroundImage='url(images/link_on.png)';
	    menu_hover.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader('',sizingMethod='scale')";
		}
	else{
		menu_hover.style.backgroundImage='url(images/link_on.png)';
		menu_hover.style.backgroundPosition='top';
		menu_hover.style.backgroundRepeat='repeat-x';
		}
	}

	menuOut=function(id,id2){
	var name = navigator.appVersion;
	var version=name.substring(17,25);
	var menu_out = document.getElementById(id);
	var smenu_out = document.getElementById(id2);
	if(version=="MSIE 6.0"){
		if(smenu_out.style.display!='block'){
			menu_out.style.filter='none';
			menu_out.style.backgroundImage='url(images/spacer_gri.gif)';
			}
		}
	else{
		if(smenu_out.style.display!='block'){
			menu_out.style.backgroundImage='url(images/spacer_gri.gif)';
			menu_out.style.backgroundPosition='bottom';
			menu_out.style.backgroundRepeat='repeat-x';
			}
		
		}
	}

	function show_menu(id) {
	var name = navigator.appVersion;
	var version=name.substring(17,25);
	var smenu_open = document.getElementById(id);
		for (var i = 1; i<=10; i++) {

			if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
			if(menu_on=document.getElementById('menu'+i)){
			menu_on.style.background='url(images/spacer_gri.gif) repeat-x bottom';
			menu_on.style.filter='none';
			}
			if(smenu_open == document.getElementById('smenu'+i)){
				menu_on=document.getElementById('menu'+i);
				if(version=="MSIE 6.0"){
					 menu_on.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/link_on.png',sizingMethod='scale')";
					}
				else{
					menu_on.style.backgroundImage='url(images/link_on.png)';
					}
			}
		}
	if (smenu_open) {
		smenu_open.style.display='block';
		}
	}

