<!--

function init() {
	ie = (document.all)? true:false
	ns = (ie)? false:true
}

function bgChange(celda,img)
{
	celda.style.background="url(" + img + ")";
}

function gotoUrl(url) {
	if (url != '#' && url.length > 0) {
		//self.location.replace(url)
		window.open(url, '_self');
	}	
}

function CheckSecCode()
{
	var myConn 		= new XHConn();	
	var secCode	= document.getElementById('code').value;
	var Obj	= document.getElementById('codeOK'); // El id del div donde se cargaran las cosas
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	var fnWhenDone = function (oXML) {
		if (oXML.responseText == "0") {
			alert (document.getElementById("wrong_sec_code").value);
			document.getElementById('siimage').src = '/modules/abstracts/securimage_show.php?sid=' + Math.random();
			document.getElementById("code").value = "";
			document.getElementById("code").focus();
		}
		else
			document.getElementById("form_send_abstract").submit();
	};
	myConn.connect("/modules/abstracts/check-sec-code.php", "POST", "code=" + secCode, fnWhenDone);	
}

function valida_send_abstract(){
	if	(isEmpty("job_title")) {
		alert (document.getElementById("empty_job_title").value);
		return false;
	};
	if	(isEmpty("nomb1") || isEmpty("apellidos1")) {
		alert (document.getElementById("empty_nomb1").value);
		return false;
	};
	if	(isEmpty("organization_name")) {
		alert (document.getElementById("empty_organization_name").value);
		return false;
	};
	if	(isEmpty("email")) {
		alert (document.getElementById("empty_email").value);
		return false;
	};
	if	(!isMail_address(document.getElementById("email").value)) {
		alert (document.getElementById("bad_email").value);
		return false;
	};
	if	(isEmpty("uploadedfile1")) {
		alert (document.getElementById("empty_uploadedfile").value);
		return false;
	};
	CheckSecCode();
}

function isMail_address (str){
	return  ((str.indexOf('@') != -1) && (str.indexOf('@') != 0) && (str.indexOf('@') != str.length -1) && (str.indexOf('.') != -1) && (str.indexOf('.') != 0) && (str.indexOf('.') != str.length -1))  

}

function datos_resumen(){
	if (form1.select_modalidad.value == "1")
		participant.style.display = 'block'
	else
		participant.style.display = 'none'
}
function show_div(show){
	if (show == true)
		div.style.display = 'block'
	else
		div.style.display = 'none'
}

function isEmpty(id) {
	if ((document.getElementById(id).value == null) || (document.getElementById(id).value == "")) {
		document.getElementById(id).focus();  
		return true;
	} else
		return false;
}

function show(id) {
	document.getElementById(id).style.display = "block";
}

function hide(id) {
	document.getElementById(id).style.display = "none";
}

function authors (num){
	switch(num) {
		case "1":
			show("author1");
			hide("author2"); hide("author3"); hide("author4"); hide("author5"); hide("author6"); 
		break;
		case "2":
			show("author1"); show("author2");
			hide("author3"); hide("author4"); hide("author5"); hide("author6"); 
		break;
		case "3":
			show("author1"); show("author2"); show("author3");
			hide("author4"); hide("author5"); hide("author6"); 
		break;
		case "4":
			show("author1"); show("author2"); show("author3"); show("author4");
			hide("author5"); hide("author6"); 
		break;
		case "5":
			show("author1"); show("author2"); show("author3"); show("author4"); show("author5");
			hide("author6"); 
		break;
		case "6":
			show("author1"); show("author2"); show("author3"); show("author4"); show("author5"); show("author6");
		break;
	}
}

function valida_personal_info(){
	init();
	for (var i=1; i<=document.getElementById("cant_persons").value; i++){
		if	(!name_ok("nombre"+i)) {
			alert (document.getElementById("msg_empty_name").value);
			return false;
		};
		if	(!name_ok("apellidos"+i)) {
			alert (document.getElementById("msg_empty_surname").value);
			return false;
		}
		if ((document.getElementById("extraDataPersonValue"+i) != null) && (document.getElementById("extraDataPersonValue"+i).value == "")) {
			alert (document.getElementById("msg_empty").value);
			document.getElementById("extraDataPersonValue"+i).focus();
			return false;
		}
	}
	if	(!string_ok("address")) {
		alert (document.getElementById("msg_empty_address").value);
		return false;
	};
	if	(!string_ok("province")) {
		alert (document.getElementById("msg_empty_province").value);
		return false;
	};
	if	(!string_ok("city")) {
		alert (document.getElementById("msg_empty_city").value);
		return false;
	};
	if	(!email_ok("email")) {
		alert (document.getElementById("msg_empty_email").value);
		return false;
	};
	if	((document.getElementById("aeroplan_in")) && (!string_ok("aeroplan_in"))) {
		alert (document.getElementById("msg_empty_aeroplan").value);
		return false;
	};
	if	((document.getElementById("aeroplan_out")) && (!string_ok("aeroplan_out"))) {
		alert (document.getElementById("msg_empty_aeroplan").value);
		return false;
	};
	if	(!string_ok("zip_code")) {
		alert (document.getElementById("msg_empty_zip_code").value);
		return false;
	};
	if	(!number_ok("phone1")) {
		alert (document.getElementById("msg_empty_telephone").value);
		return false;
	};
	if	(!number_ok("phone2")) {
		alert (document.getElementById("msg_empty_telephone").value);
		return false;
	};
	if	(!number_ok("phone3")) {
		alert (document.getElementById("msg_empty_telephone").value);
		return false;
	};
	if	(!isEmpty("fax1") && !number_ok("fax1")) {
		alert (document.getElementById("msg_empty_fax").value);
		return false;
	};
	if	(!isEmpty("fax1") && !number_ok("fax2")) {
		alert (document.getElementById("msg_empty_fax").value);
		return false;
	};
	if	(!isEmpty("fax1") && !number_ok("fax3")) {
		alert (document.getElementById("msg_empty_fax").value);
		return false;
	};
	
	return true;
}

function string_ok(id) {
	var re = /^[0-9a-zA-ZÁáÉéÍíÓóÚúÑñ\;\:\,\*\#\+\.\\\[\]\(\)\-\_\/\[\] ]+$/;
	if ((document.getElementById(id).value != null) && (re.test(document.getElementById(id).value))) {
		return true;
	}
	else {
		document.getElementById(id).focus();  
		return false;
	}
}

function email_ok(id) {
	var re = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	if ((document.getElementById(id).value != null) && (re.test(document.getElementById(id).value))) {
		return true;
	}
	else {
		document.getElementById(id).focus();  
		return false;
	}
}

function name_ok(id) {
	var re = /^[a-zA-ZÁáÉéÍíÓóÚúÑñ ]+$/;
	if ((document.getElementById(id).value != null) && (re.test(document.getElementById(id).value))) {
		return true;
	}
	else {
		document.getElementById(id).focus();  
		return false;
	}
}

function number_ok(id) { 
	var re = /^\d+$/;
	if ((document.getElementById(id).value != null) && (re.test(document.getElementById(id).value))){
		return true;
	}
	else{
		document.getElementById(id).focus();
		return false;
	}
}

function Change(palaceposition){
	var node = document.all.item("palace");
	if (node != null) {
		if (node.length > 0) {					
				for (j=0; j<node.length; j++) { 												
					if (j == palaceposition)  
						node(j).style.display = "";
					else 
						node(j).style.display = "none";	
				}
		} 
		else {
			if (node.style.display == "none") 
				node.style.display = "";
			else 
				node.style.display = "none";
		}
	}
}

function change_date (date1, date2, direction) {
	date1_arr = date1.split("-");
	date2_arr = date2.split("-");
	switch (direction) {
		case "+":
			if (date1_arr[2] >= date2_arr[2]){
				date2_arr[2] = parseInt(date1_arr[2]) + 1;
				if ((parseInt(date2_arr[2]) <= 9) && (parseInt(date2_arr[2]) >=1))
					date2_arr[2] = "0" + date2_arr[2];
			}
		break;
		case "-":
			if (date1_arr[2] <= date2_arr[2]) {
				date2_arr[2] = parseInt(date1_arr[2]) - 1;
				if ((parseInt(date2_arr[2]) <= 9) && (parseInt(date2_arr[2]) >=1))
					date2_arr[2] = "0" + date2_arr[2];
			}
		break;
	}
	return date2_arr[0] + "-" + date2_arr[1] +"-"+ date2_arr[2];
}

function index_of_select (select1, value) {
	index = -1;
	for (i=0; document.getElementById(select1).length-1; i++) {
		if (document.getElementById(select1).options[i].value == value) {
			index = i;
			break;
		}
	}
	return index;
}

function change_select (select1, select2, direction) {
	date2 = change_date(document.getElementById(select1).value, document.getElementById(select2).value, direction);
	if (index_of_select(select2, date2) != -1) {
		document.getElementById(select2).selectedIndex = index_of_select(select2, date2);
	}
}

function submitform (form, page) {
	document.getElementById(form).action = page;
	document.getElementById(form).submit();
}

function change_selection_index(id_change, id_changevalue)
{
	document.getElementById(id_change).selectedIndex = document.getElementById(id_changevalue).selectedIndex;
}
//-->
