jQuery.noConflict();
(function($){
	$(function() {
										 
	$('#selectInteresForm div.paginare a').click(function() { $('#selectInteresForm').attr('action',$(this).attr('href')); $('#selectInteresForm').submit(); return false; });
	$('form table input:submit').addClass('submitType');
 	//menu and submenus
	$('#menu li ul').hide();
	$('#menu li').hoverIntent( {over: function() { $(this).addClass('over'); $(this).find('ul:first').slideDown('fast') },
								timeout:0,
								interval:50,
								out: function()  { $(this).removeClass('over'); $(this).find('ul:first').slideUp(2)} 
							});	
	
	$(':submit[@name="btn_cauta"]').wrap('<div class="submitWrapper"></div>');
	$(':submit[@name="formtype_mail"]').wrap('<div class="submitWrapper"></div>');
	
	$('a.dmmjobcontrol_apply_link').click(function() { $(this).remove(); }); 
	//console.log("ok"+$('a').hasClass('print'));
	if($('a').hasClass('print')){
		//$('#contact').removeClass("over");
		$('.contact').hide();
		$('#contact').toggle(function() {$('.contact').slideDown('slow'); $(this).addClass("over")}, function() { $('.contact').slideUp('slow'); $(this).removeClass("over")}); 
	}else{
		$('#contact').addClass('over');
		$('#contact').toggle( function() { $('.contact').slideUp('slow'); $(this).removeClass("over")},  function() {$('.contact').slideDown('slow'); $(this).addClass("over")}); 
	}
	$("#tooltips a").tooltip({ showURL: false, track: true });
	$("#tooltips2 a").tooltip({ showURL: false, track: true });
	$("#tooltips3 a").tooltip({ showURL: false, track: true });
});
})(jQuery);

function OpenForm(url) {
	var newurl = url;
	if ( url.indexOf("?") > -1 ) newurl = newurl + '&form=1';
	else newurl = newurl + '?form=1';
	document.getElementById('selectInteresForm').submit();
	window.open(newurl,'Form','menubar=0,scrollbars=1,width=660,height=500');
}

function PrintLink() {
	var url = document.location.href;  
	var newurl = url;
	newurl = newurl.replace('?recomanda=1', '');
	newurl = newurl.replace('recomanda=1', '');
	if ( newurl.indexOf("?") > -1 ) newurl = newurl+'&typeP=1';
	else  newurl = newurl+'?typeP=1';
	window.open(newurl,'PrintPage','scrollbars=1,width=810,height=500');
}

function check_email(str){
	var filter=/^.+@.+\..{2,3}$/
	var result = 0;
	
	if (filter.test(str)) result = 1;
	return result;
}

function CheckForm() {
	var done = false;
	var name = document.getElementById("name").value;
	var email = document.getElementById("email").value;
	var strHref = window.location.href;

	var pleaseComplete = "Va rugam sa completati:\n";	
	var errNoEmail = "Email!\n";
	var errEmail = "Email incorect!";
	if (strHref.indexOf('/en/') > -1) {
		var pleaseComplete = "Please type in:\n";		
		var errNoEmail = "Email!\n";
		var errEmail = "Incorrect email!";
	}
	
	var k=1; var err='';	
	if (email=="") {k=0;err=err+errNoEmail;}

	if (k==0) {
		alert(pleaseComplete + err);
	} else {
		if (check_email(email)==0) alert(errEmail);
		else done = true;
	}
	return done;
}

function changeCartier(object)
{
	var i,j;
	for(i=0; i<localitati.length; i++)
	{
		if (localitati[i][0] == object.options[object.selectedIndex].value)
		{
			document.getElementById('cartier').options.length = 0;
			for(j=0; j<localitati[i][2].length; j++)
			{
				document.getElementById('cartier').options[j] = new Option(localitati[i][2][j][1], localitati[i][2][j][0])
			}
			return;
		}
	}
	return;
}

function validareCautare()
{
	var camere_min = document.getElementById('camere_min').value;
	var camere_max = document.getElementById('camere_max').value;
	document.getElementById('camere_min_error_neg').style.display = 'none';
	document.getElementById('camere_max_error_neg').style.display = 'none';
	var error = 0;
	if(camere_min && (parseInt(camere_min).toString() != camere_min  || (parseInt(camere_min)<=0)))
	{
		document.getElementById('camere_min_error_neg').style.display = 'block';
		error = 1;
	}
	if(camere_max && (parseInt(camere_max).toString() != camere_max  || (parseInt(camere_max)<=0)))
	{
		 document.getElementById('camere_max_error_neg').style.display = 'block';
		 error = 1;
	}
	if(error == 1) return false;
	if(parseInt(camere_min) >= parseInt(camere_max))
	{
		 document.getElementById('camere_max_invalid').style.display = 'block';
		 return false;
	}
	return true;
}
function hideInteres(id)
{	
	if(document.getElementById('intereseaza_'+id) )
		document.getElementById('intereseaza_'+id).style.display = 'none';
	if(document.getElementById('intereseaza_'+id+'_btm'))
		document.getElementById('intereseaza_'+id+'_btm').style.display = 'none';	
}
function showInteres(id)
{
	if(document.getElementById('intereseaza_'+id))
		document.getElementById('intereseaza_'+id).style.display = 'inline';
	if(document.getElementById('intereseaza_'+id+'_btm'))
		document.getElementById('intereseaza_'+id+'_btm').style.display = 'inline';
}