var DefaultTextEmailColor     = "";
var DefaultTextEmailfontStyle = "";
var DefaultTextEmailValue     = "";

function load(){
	DefaultTextEmailColor     = document.getElementById('email').style.color;
	DefaultTextEmailfontStyle = document.getElementById('email').style.fontStyle;
	DefaultTextEmailValue     = document.getElementById('email').value;	
}

function onclick_email(){
	obj_input = document.getElementById('email');
	input_content = obj_input.value;
	
	if(input_content==DefaultTextEmailValue) obj_input.value = "";
	
	document.getElementById('ok_button').disabled = "";
	obj_input.style.color     = "#000000";
	obj_input.style.fontStyle = "normal";
}

function onclick_searchbox(obj){
	document.getElementById('btnG').disabled = "";
	input_content = obj.value;
	if(input_content=="") obj.style.background = '#A4E4F5';
	obj.style.color     = "#000000";
	obj.style.fontStyle = "normal";
}

function onblur_searchbox(obj){
	if(obj.value=="") obj.style.background = "#A4E4F5 url(common/images/google_logo.png) 5px 0 no-repeat";
	obj.style.color = "#1188A6";
	obj.style.fontStyle = "italic";
	obj.blur();
	
}

function reset_searchbox(){
	document.getElementById("q").value="";
	document.getElementById("q").style.background = "#A4E4F5 url(common/images/google_logo.png) 5px 0 no-repeat";
	document.getElementById('btnG').disabled = "disabled";
	document.getElementById("q").blur();
}

function onblur_email(){
	obj_input = document.getElementById('email');
	input_content = obj_input.value;
	
	if(input_content=="" || input_content==DefaultTextEmailValue){
		obj_input.value = DefaultTextEmailValue;
		document.getElementById('ok_button').disabled = "disabled";
	}
	
	obj_input.style.color     = DefaultTextEmailColor;
	obj_input.style.fontStyle = DefaultTextEmailfontStyle;
}

function validateEmail(email_str){
	
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	if (reg.test(email_str) == false) return false; else return true;
}

function onsubmit_email(){
	
	input_content = document.getElementById('email').value;
	
	if (validateEmail(input_content) == false)
	{
		alert('Este nevoie de o adresa de mail valida.\nAceasta adresa "'+input_content+'" este invalida.');
		return false;
	} 
	return true; 
}

function onsubmit_contact(){
	img_src_default   = "common/images/star.png";
	img_title_default = "Camp obligatoriu a fi completat!";
	
	img_src_invalid   = "common/images/error.png";
	img_title_invalid = "Campul este invalid!";
	
	name_input = document.getElementById('contact_name');
	name_value = name_input.value;
	name_img   = document.getElementById('img_contact_name');
	
	email_input = document.getElementById('contact_email');
	email_value = email_input.value;
	email_img   = document.getElementById('img_contact_email');

	comment_input = document.getElementById('contact_comment');
	comment_value = comment_input.value;
	comment_img   = document.getElementById('img_contact_comment');
	
	var error_mess = "";
	
	if(name_value.length>2 && email_value.length>2 && comment_value.length>2 && validateEmail(email_value)==true){
		return true;
	} else {
		
		if(name_value.length<3){
			
			name_input.style.backgroundColor = "#FFB3B3";
			name_img.src                     = img_src_invalid;
			name_img.title                   = img_title_invalid;
			
		} else {
			
			name_input.style.backgroundColor = "#A4E4F5";
			name_img.src                     = img_src_default;
			name_img.title                   = img_title_default;			
		}
		
		if(validateEmail(email_value)==false){
			
			email_input.style.backgroundColor = "#FFB3B3";
			email_img.src                     = img_src_invalid;
			email_img.title                   = img_title_invalid;
			
		} else {
			
			email_input.style.backgroundColor = "#A4E4F5";
			email_img.src                     = img_src_default;
			email_img.title                   = img_title_default;
			
		}
		if(comment_value.length<3){
			
			comment_input.style.backgroundColor = "#FFB3B3";
			comment_img.src                     = img_src_invalid;
			comment_img.title                   = img_title_invalid;
			
		} else {
			
			comment_input.style.backgroundColor = "#A4E4F5";
			comment_img.src                     = img_src_default;
			comment_img.title                   = img_title_default;
			
		}
		
		return false;
	}
	
}
