// JavaScript Document

function placeInMiddle(layer){
	
var winW = 630, winH = 460;

var mainLayer = document.getElementById(layer);
var difference;

if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth; 
 }
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.body.offsetWidth; 
 }
}

if (winW > 800){
	difference = winW - 800	
}

if (navigator.appName.indexOf("Microsoft") == -1){
	mainLayer.style.left = (difference / 2) + 'px';
} else {
	mainLayer.style.marginLeft  = (difference / 2) + 'px';
}

mainLayer.style.display = 'block';
return true;

}

function DelayHideMenu(layer){
	
	
	switch (layer){
	
	case 1:	
		if ($('menu_drop_down_traseu').style.display == 'block') 
			$('menu_drop_down_traseu').style.display = 'none';
	break;
	
	case 2:
	
		if ($('menu_drop_down_editii').style.display == 'block') 
			$('menu_drop_down_editii').style.display = 'none';
	break;
	
	case 3:
	
	if ($('menu_drop_down_traseu').style.display == 'block') 
			$('menu_drop_down_traseu').style.display = 'none';
			
	if ($('menu_drop_down_editii').style.display == 'block') 
			$('menu_drop_down_editii').style.display = 'none';
	
	break;
	}
	
	return true;
	
}



function checkInscription(){
		
	if (isEmpty('reg_name', 'Numele este obligatoriu!')){
		if (isEmpty('reg_surname', 'Prenumele este obligatoriu!')){
			if (isEmpty('reg_idnumber', 'Seria si Numarul de C.I. este obligatoriu!')){
				if (isEmpty('reg_persnumber', 'Codul Numeric Personal este obligatoriu!')){
					if (isNumeric('reg_persnumber', 'Codul Numeric personal este invalid')){
						if (isLenght('reg_persnumber', 13, 'Codul Numeric personal este invalid')){
							if (isEmpty('reg_city', 'Orasul este obligatoiu!')){
						if (isEmpty('reg_address', 'Adresa este obligatorie!')){
							if (isEmpty('reg_telephone', 'Numarul de telefon este obligatoriu!')){
								if (isEmpty('reg_email', 'Adresa de Email este oblogatorie!')){
									if (isEmail('reg_email', 'Adresa de Email este oblogatorie!')){
									if (isEmpty('reg_contact', 'Numele persoanei de contact este obligatoriu!')){
										if (isEmpty('reg_contacttel', 'Numarul de telefon al persoanei de contact este obligatoriu!')){											
										return true;
										}
									}
										}
									}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	
						
	return false;
	
}


function checkInscriptionADM(){

	
	if (isEmpty('reg_name', 'Numele este obligatoriu!')){
		if (isEmpty('reg_surname', 'Prenumele este obligatoriu!')){
			if (isEmpty('reg_idnumber', 'Seria si Numarul de C.I. este obligatoriu!')){
				if (isEmpty('reg_persnumber', 'Codul Numeric Personal este obligatoriu!')){
					if (isNumeric('reg_persnumber', 'Codul Numeric personal este invalid')){
						if (isLenght('reg_persnumber', 13, 'Codul Numeric personal este invalid')){
							//if (isEmpty('reg_pne', 'Numarul de concurs este obligatoriu')){
							if (isEmpty('reg_city', 'Orasul este obligatoiu!')){
						if (isEmpty('reg_address', 'Adresa este obligatorie!')){
							if (isEmpty('reg_telephone', 'Numarul de telefon este obligatoriu!')){
								if (isEmpty('reg_email', 'Adresa de Email este oblogatorie!')){
									if (isEmail('reg_email', 'Adresa de Email este oblogatorie!')){
									if (isEmpty('reg_contact', 'Numele persoanei de contact este obligatoriu!')){										
										if (isEmpty('reg_contacttel', 'Numarul de telefon al persoanei de contact este obligatoriu!')){											
										return true;
										}
										}
									}
										}
									}
									}
								//}
							}
						}
					}
				}
			}
		}
	}
						
	return false;
	
}

function isEmpty(param, alert_msg){	
		if ($(param).value == ''){
			//alert(alert_msg);
			$(param+'ID').style.color = '#FFCC33';
			$(param).focus();
			$('ShowError').style.color = '#FFCC33';
			$('ShowError').innerHTML = alert_msg;
			return false;
		} else {
			$(param+'ID').style.color = '#FFFFFF';
		}
	return true;
}

function isNumeric(param, alert_msg){
	var ValidNumbers =/^[0-9]+$/;
	if ($(param).value.match(ValidNumbers)){
		return true;
	} else {
		$(param+'ID').style.color = '#FFCC33';
		$(param).focus();
		$('ShowError').innerHTML = alert_msg;
		param.focus();
		return false;
	}
}

function isLenght(param,  max_val, alert_msg){
	var p_val = $(param).value;
	
	if (p_val.length < max_val){
		$(param+'ID').style.color = '#FFCC33';
		$(param).focus();
		$('ShowError').innerHTML = alert_msg;
		$(param).focus();
		return false;
		
	} else {
		return true;
	}
}

function isSelected(param, alert_msg){
		if (elem.value == 'Select one'){
			alert(alert_msg);
			param.focus();
			return false;
		} else {
			return true;
		}
}

function isEmail(param, alert_msg){
	var emailVal = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if ($(param).value.match(emailVal)){
		return true;
	} else {
		alert(alert_msg);
		$(param).focus();
		return false;
	}
}

