//		FORM VALIDATION

function trim(sString) {

	while (sString.substring(0,1) == ' ')
		{
		sString = sString.substring(1, sString.length);
		}
	while (sString.substring(sString.length-1, sString.length) == ' ')
		{
		sString = sString.substring(0,sString.length-1);
		}
	return sString;
}

function empty_field(val) {

    if(trim(val) == ""){return false;}
	return true;
    }

function check_email(value) {

	var x = value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else return false;
}

// atentie la ++++++++++++++++++
function check_date(value) {
	//	minimal date check
	var x = value;
	var filter  = /^([0-3]{1})+([0-9]{1})+(\/)+([0-1]{1})+([0-9]{1})+(\/)+([0-9]{4})+$/;
	//var filter  = /^([a-zA-Z0-9_\.\-])(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return true;
	else return false;
}

function check_contact_form(lang) {                                                // verificare date formular   xxxxxxxxxxxxx

	if(lang == 'en') {
		var alert_name = 'Please fill in your name!';
		var alert_msg = 'Please write your message!';
	}
	else {
		var alert_name = 'Va rugam sa va completati numele!';
		var alert_msg = 'Va rugam sa scrieti mesajul!';
	}

	if (empty_field(document.contact.nume.value) == false) {
     		alert(alert_name);
        	return;
    	}
     if (empty_field(document.contact.mesaj.value) == false) {
     		alert(alert_msg);
        	return;
    	}

	document.contact.submit();
}

//function open_popup(path, file_name) {
//
//    var width = 450;
//    var height = 480;
//
//	var winleft = (screen.width - width) / 2;
//	if (winleft < 0) winleft = 0;
//	var wintop = (screen.height - height) / 2 - 50;
//	if (wintop < 0) wintop = 0;
//    //alert(winleft);
//    var parameters = "width="+width+", height="+height+", left="+winleft+", top="+wintop+", toolbar=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes";
//	var file_to_open = '/include/open_popup.php?directory='+path+'&file_name='+file_name;
//	var new_window;
//
//	new_window = window.open(file_to_open, 'portofoliu', parameters);
//	new_window.focus();
//}

function open_image(file) {
	var path="/img/portofoliu/foto/"
    var width = 300;
    var height = 400;
	var winleft = 100;
	var wintop = 100;
    var parameters = "width="+width+", height="+height+", left="+winleft+", top="+wintop+", toolbar=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes";
	var file_to_open = '/portofoliu/foto/popup.php?path='+path+file;
	var new_window;
	new_window = window.open(file_to_open, 'foto', parameters);
	new_window.focus();
}


















function rowOverEffect(object) {
  if (object.className == 'dataTableRow1') object.className = 'dataTableRowOver1';
  if (object.className == 'dataTableRow2') object.className = 'dataTableRowOver2';
}

function rowOutEffect(object) {
  if (object.className == 'dataTableRowOver1') object.className = 'dataTableRow1';
  if (object.className == 'dataTableRowOver2') object.className = 'dataTableRow2';
}


function show_hide_div(div_id, action) {		//	v. 0.0

	var div_name = div_id;
//	var action = action;

	if (document.getElementById) {
		// this is the way the standards work

//		if(action.length > 0) {
		if(action != '') {

			document.getElementById(div_name).style.display = action;
		}
		else {

			if(document.getElementById(div_name).style.display == "block") {

				document.getElementById(div_name).style.display = "none";
			}
			else {

				document.getElementById(div_name).style.display = "block";
			}
		}
	}
	else if (document.all) {
		// this is the way old msie versions work

		if(action != '') {

			document.getElementById(div_name).style.display = action;
		}
		else {

			if(document.getElementById(div_name).style.display == "block") {

				document.all[div_name].style.display = "none";
			}
			else {
				document.all[div_name].style.display = "block";
			}
		}
	}
	else if (document.layers) {
		// this is the way nn4 works
		if(action != '') {

			document.getElementById(div_name).style.display = action;
		}
		else {
			if(document.getElementById(div_name).style.display == "block") {

				document.layers[div_name].style.display = "none";
			}
			else {
				document.layers[div_name].style.display = "block";
			}
		}
	}
}

