
function validate()
{
	if ( ( document.form_contact.text.value == "" ) || ( document.form_contact.subject.value == "" ) || ( document.form_contact.name.value == "" ) || ( document.form_contact.email.value.search("@") == -1 ) || ( document.form_contact.email.value.search("[.*]" ) == -1 ) )
	{
		alert( "Asigura-te ca formularul este completat in intregime corect." );
		return false;
	}
	else
	{
		return true;
	}
}

function validateReportAgency()
{
	if ( ( document.form_report_agency.name.value == "" ) || ( document.form_report_agency.email.value.search("@") == -1 ) || ( document.form_report_agency.email.value.search("[.*]" ) == -1 ) )
	{
		alert( "Asigura-te ca ai introdus numele si o adresa de e-mail valida." );
		return false;
	}
	else
	{
		document.form_report_agency.submit();
	}
}

function validateReportBadPost()
{
	if ( ( document.form_report_bad_post.name.value == "" ) || ( document.form_report_bad_post.email.value.search("@") == -1 ) || ( document.form_report_bad_post.email.value.search("[.*]" ) == -1 ) )
	{
		alert( "Asigura-te ca ai introdus numele si o adresa de e-mail valida." );
		return false;
	}
	else
	{
		document.form_report_bad_post.submit();
	}
}

function checkValue()
{
	// get category
	//var offerSelect = $F( 'idCategory' );
	var tmp = $( 'idCategory' );
	var offerSelect = tmp.value;
	
	// depend on category selected show/hide fields to complete
	if( offerSelect == '8' )
	{
		$( 'area_options' ).style.display = '';
		$( 'options_for_slots' ).style.display = '';
	}
	if( offerSelect != '8')
	{
		$( 'area_options' ).style.display = 'none';
		$( 'options_for_slots' ).style.display = 'none';
	}
	if( offerSelect == '1' || offerSelect == '2' || offerSelect == '3' || offerSelect == '4' || offerSelect == '5')
	{
		$( 'options_for_apartments' ).style.display = '';
	}
	if( offerSelect != '1' && offerSelect != '2' && offerSelect != '3' && offerSelect != '4' && offerSelect != '5')
	{
		$( 'options_for_apartments' ).style.display = 'none';
	}
	
	if( offerSelect == '6' )
	{
		$( 'options_for_houses' ).style.display = '';
	}
	if( offerSelect != '6')
	{
		$( 'options_for_houses' ).style.display = 'none';
	}
	
	if( offerSelect == '7' )
	{
		$( 'options_for_lands' ).style.display = '';
	}
	if( offerSelect != '7')
	{
		$( 'options_for_lands' ).style.display = 'none';
	}
	
	// get offer type 
	//var offerType = $F( 'offerType' );
	tmp = $( 'offerType' );
	var offerType = tmp.value;
	
	// depend on offer type selected show/hide fields to complete
	if( offerType == 'RENT' || offerType == '' )
	{
		$( 'options_for_offerType' ).style.display = 'none';
	}
	else
	{
		$( 'options_for_offerType' ).style.display = '';
	}
}

function favorite( idPost )
{
	popupWidth = 400;
	popupHeight = 300;
	
	// displays the pop-up in the left corner of the screen
	popupLeft = 0;
	popupTop = 0;

	popupProps = "width=" + popupWidth + ", height=" + popupHeight + ", status=yes, resizable=no, scrollbars=yes, location=no, menubar=no, top=" + popupTop + ", left=" + popupLeft;
	popupHref = "/site_files/postOptions.php?action=addToFavorites&idPost=" + idPost;

	// pops the windows and focuses on it.
	addFavoritePopup = window.open( popupHref, "addFavorite", popupProps );
	addFavoritePopup.focus();	
	if( !addFavoritePopup.opener )
	addFavoritePopup.opener = self;
}

function reportAgency( idPost )
{
	popupWidth = 400;
	popupHeight = 300;
	
	// displays the pop-up in the left corner of the screen
	popupLeft = 0;
	popupTop = 0;

	popupProps = "width=" + popupWidth + ", height=" + popupHeight + ", status=yes, resizable=no, scrollbars=yes, location=no, menubar=no, top=" + popupTop + ", left=" + popupLeft;
	popupHref = "/site_files/postOptions.php?action=reportAgency&idPost=" + idPost;

	// pops the windows and focuses on it.
	addFavoritePopup = window.open( popupHref, "addFavorite", popupProps );
	addFavoritePopup.focus();	
	if( !addFavoritePopup.opener )
	addFavoritePopup.opener = self;
}

function reportBadPost( idPost )
{
	popupWidth = 400;
	popupHeight = 300;
	
	// displays the pop-up in the left corner of the screen
	popupLeft = 0;
	popupTop = 0;

	popupProps = "width=" + popupWidth + ", height=" + popupHeight + ", status=yes, resizable=no, scrollbars=yes, location=no, menubar=no, top=" + popupTop + ", left=" + popupLeft;
	popupHref = "/site_files/postOptions.php?action=reportBadPost&idPost=" + idPost;

	// pops the windows and focuses on it.
	addFavoritePopup = window.open( popupHref, "addFavorite", popupProps );
	addFavoritePopup.focus();	
	if( !addFavoritePopup.opener )
	addFavoritePopup.opener = self;
}

function delPost( idPost )
{
	if( confirm( "Esti sigur ca vrei sa stergi acest anunt?" ) )
	{
		document.location = "/index.php?page=anunturileMele&delPost=" + idPost;
	}
}

function delFavoritePost( idPost )
{
	if( confirm( "Esti sigur ca vrei sa stergi acest anunt?" ) )
	{
		document.location = "/index.php?page=anunturiFavorite&delPost=" + idPost;
	}
}

function pageNumber( idSelect, idSelect2 )
{
	var tmp = $( idSelect );
	var valueSelected = tmp.value;
	$(idSelect2).value = valueSelected;
}
