function changeLayerStatus(id) {
	var capa = document.getElementById(id);
	capa.style.visibility = (capa.style.visibility == "visible") ? "hidden" : "visible"; 
}

function getElementById(id) {
	return document.getElementById(id);
}

function confirmAndLaunch(url) {
	if (confirm('Estās segur?')) {
		window.location.href = url;	
	}
}

function confirmAndLaunch2(url, text) {
	if (confirm(text)) {
		window.location.href = url;	
	}
}

function setFocus(field) {
  field.focus();
}

//Images
function checkIsImageFile(value) {
	var regExp = /.[png|jpeg|jpg|gif]$/;
	return (regExp.test(value) ? true : false);
}

function getAcceptedImageExtensions() {
	return "png|jpeg|jpg|gif";
}

//Documents

function checkIsPdfFile(value) {
	var regExp = /.pdf$/;
	return (regExp.test(value) ? true : false);
}

function checkIsDocumentFile(value) {
	var regExp = /.[doc|xls|ppt|sxw|sxc|pdf|odt|ods]$/;
	return (regExp.test(value) ? true : false);
}

function getAcceptedDocumentExtensions() {
	return "doc|xls|ppt|sxw|sxc|pdf|odt|ods";
}

function checkIsNumeric(value) {
	var regExp = /^\d+$/;
	return (regExp.test(value) ? true : false);
}

function checkIsValidUrl(value) {
	var regExp = /^(http|https|ftp):\/\/(www\.)?([a-z0-9])+\.[a-zA-Z]+(\.[a-zA-Z]+)?/;
	return (regExp.test(value) ? true : false);
}
/*
function checkIsValidDateAmerican(value) {
	var regExp = /(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])/;
	return (regExp.test(value) ? true : false);
}

function checkIsValidDateSpanish(value) {
	var regExp = /(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d/;
	return (regExp.test(value) ? true : false);
}
*/
function checkIsValidEmail(value) {
	var regExp = /^(([^\-][\w\-]*?\.?){1,})[^-](\@{1})([^\-][\w+\.\-])[^\2]{1,}[^\-]$/;
	return (regExp.test(value) ? true : false);
}

function filterNumericField(obj)
{
	var numbers='1234567890'
	var value = obj.value;
	var c;
	
	var val= '';
	for (i = 0; i < value.length; i++) { 
		c = value.charAt(i); 
		if (numbers.indexOf(c) != -1) {
			val = val + c;
		}
	}
	obj.value = val;
}

function openPopUp(url, id, w1, h1)
{
  var x = (screen.width/2)*1 - w1/2;
  var y = (screen.height/2)*1 - h1/2;
  var vWinCal = window.open(url, id, 
    "width="+w1+",height="+h1+",status=no,resizable=no,scrollbars=auto,top="+y+",left="+x);
}

function openPopUp2(url, w, h) 
{
  window.open(url, 'soci', 'toolbar=0,status=0,menubar=0,scrollbars=0,resizable=0,location=0,directories=0,width='+w+',height='+h);
}
