$(document).ready(function() {
	$("#menu .top_parent").mouseover(function(){
		$(this).animate({opacity: 0.85}, 150);
	});
	
	$("#menu .top_parent").mouseout(function(){
		$(this).animate({"opacity": 1}, 150);
	});
	
	
	$(".pagination").click(function(){
		page_number = this.id.substring(10, this.id.length);
		
		$('.pagination').each( function() {
			$(this).animate({opacity: 1}, 50);
			hide_nr = this.id.substring(10, this.id.length);
			$("#page_" + hide_nr).hide();
		}); // end for each
				
		$("#page_" + page_number).show();
		$(this).animate({opacity: 0.6}, 150);
	});
});

function show_container(color)
{
	$("#" + color + "_container").fadeIn();
	$("#" + color + "_container .quote").animate({ opacity: 0.45}, 10);
}

function hide_container(color)
{
	$("#" + color + "_container").fadeOut();
}

function validate_contact_form()
{
	var cntName	  = $('#cntName').val();
	var cntPosition  = $('#cntPosition').val();
	var cntCompany   = $('#cntCompany').val();
	var cntTelephone = $('#cntTelephone').val();
	var cntEmail     = $('#cntEmail').val();
	var cntQuery   = $('#cntQuery').val();
	
	// Verify Name
		if (cntName == '' || cntName.length < 2 || cntName == "name") { inlineMsg('cntName','Please specify your Name!',3); return false; }
	
	// Verify Company
		if (cntCompany == '' || cntCompany.length < 2 || cntCompany == "company" ) { inlineMsg('cntCompany','Please specify your Company!',3); return false; }

	// Verify Email
		if (cntEmail == '' || cntEmail.length < 2 || cntEmail == "email" ) { inlineMsg('cntEmail','Please specify your Email!',3); return false; }
		if (validateEmail(cntEmail)) { inlineMsg('cntEmail','Please specify a<b> valid</b> Email!',3); return false; }
	
	// Verify Position
		if (cntPosition == '' || cntPosition.length < 2 || cntPosition == "position" ) { inlineMsg('cntPosition','Please specify your Position!',3); return false; }
	
	// Verify Telephone
		if (cntTelephone == '' || cntTelephone.length < 2 || cntTelephone == "telephone" ) { inlineMsg('cntTelephone','Please specify your Telephone!',3); return false; }
		
	// Verify Query
		if (cntQuery == '' || cntQuery.length < 2 || cntQuery == "query" ) { inlineMsg('cntQuery','Please specify your Enquiry!',3); return false; } 
		
	//daca am ajuns aici inseaman ca pot trimite mailul si actunci afisez un loading si ascund butoanele
	$("#submit-buttons").hide();
	$("#submit-loading").show();
	
	return true;
}

function validate_subscribe_form()
{
	var nwEmail     = $('#nwEmail').val();
	
	// Verify Email
		if (nwEmail == '' || nwEmail.length < 2 || nwEmail == "email" ) { inlineMsg('nwEmail','Please specify your Email!',3); return false; }
		if (validateEmail(nwEmail)) { inlineMsg('nwEmail','Please specify a<b> valid</b> Email!',3); return false; }
	
	//daca am ajuns aici inseaman ca pot trimite mailul si actunci afisez un loading si ascund butoanele
	$("#submit-buttons").hide();
	$("#submit-loading").show();
	
	return true;
}


function validateEmail(emailad) {
		
	var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,4}$/;

	if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1)){
		return true;
	}
	else {
		return false;
	}
}

