var PostalCodeInit = new Array()
PostalCodeInit[0] = "01"
PostalCodeInit[1] = "02"
PostalCodeInit[2] = "03"
PostalCodeInit[3] = "04"
PostalCodeInit[4] = "33"
PostalCodeInit[5] = "05"
PostalCodeInit[6] = "06"
PostalCodeInit[7] = "08"
PostalCodeInit[8] = "09"
PostalCodeInit[9] = "10"
PostalCodeInit[10] = "11"
PostalCodeInit[11] = "39"
PostalCodeInit[12] = "12"
PostalCodeInit[13] = "51"
PostalCodeInit[14] = "13"
PostalCodeInit[15] = "14"
PostalCodeInit[16] = "15"
PostalCodeInit[17] = "16"
PostalCodeInit[18] = "17"
PostalCodeInit[19] = "18"
PostalCodeInit[20] = "19"
PostalCodeInit[21] = "20"
PostalCodeInit[22] = "21"
PostalCodeInit[23] = "22"
PostalCodeInit[24] = "07"
PostalCodeInit[25] = "23"
PostalCodeInit[26] = "24"
PostalCodeInit[27] = "25"
PostalCodeInit[28] = "27"
PostalCodeInit[29] = "28"
PostalCodeInit[30] = "29"
PostalCodeInit[31] = "52"
PostalCodeInit[32] = "30"
PostalCodeInit[33] = "31"
PostalCodeInit[34] = "32"
PostalCodeInit[35] = "34"
PostalCodeInit[36] = "35"
PostalCodeInit[37] = "36"
PostalCodeInit[38] = "26"
PostalCodeInit[39] = "37"
PostalCodeInit[40] = "38"
PostalCodeInit[41] = "40"
PostalCodeInit[42] = "41"
PostalCodeInit[43] = "42"
PostalCodeInit[44] = "43"
PostalCodeInit[45] = "44"
PostalCodeInit[46] = "45"
PostalCodeInit[47] = "46"
PostalCodeInit[48] = "47"
PostalCodeInit[49] = "48"
PostalCodeInit[50] = "49"
PostalCodeInit[51] = "50"

var Prefix = new Array()
Prefix[0] = "945"
Prefix[1] = "967"
Prefix[2] = "96"
Prefix[3] = "950"
Prefix[4] = "98"
Prefix[5] = "920"
Prefix[6] = "924"
Prefix[7] = "93"
Prefix[8] = "947"
Prefix[9] = "927"
Prefix[10] = "956"
Prefix[11] = "942"
Prefix[12] = "964"
Prefix[13] = "956"
Prefix[14] = "926"
Prefix[15] = "957"
Prefix[16] = "981"
Prefix[17] = "969"
Prefix[18] = "972"
Prefix[19] = "957"
Prefix[20] = "949"
Prefix[21] = "943"
Prefix[22] = "959"
Prefix[23] = "974"
Prefix[24] = "971"
Prefix[25] = "953"
Prefix[26] = "987"
Prefix[27] = "973"
Prefix[28] = "982"
Prefix[29] = "91"
Prefix[30] = "95"
Prefix[31] = "95"
Prefix[32] = "968"
Prefix[33] = "948"
Prefix[34] = "988"
Prefix[35] = "979"
Prefix[36] = "928"
Prefix[37] = "986"
Prefix[38] = "941"
Prefix[39] = "923"
Prefix[40] = "922"
Prefix[41] = "921"
Prefix[42] = "95"
Prefix[43] = "975"
Prefix[44] = "977"
Prefix[45] = "978"
Prefix[46] = "925"
Prefix[47] = "96"
Prefix[48] = "983"
Prefix[49] = "94"
Prefix[50] = "980"
Prefix[51] = "976"

var DaysInMonth = new Array()
DaysInMonth[0] = 31
DaysInMonth[1] = 29
DaysInMonth[2] = 31
DaysInMonth[3] = 30
DaysInMonth[4] = 31
DaysInMonth[5] = 30
DaysInMonth[6] = 31
DaysInMonth[7] = 31
DaysInMonth[8] = 30
DaysInMonth[9] = 31
DaysInMonth[10] = 30
DaysInMonth[11] = 31

var url="http://www.creurojaroses.org";
var title="Creu Roja a Roses";
var da = (document.all) ? 1 : 0;

MM_reloadPage(true);

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function popup(url, args) {
	newwindow=window.open(url, 'popup', args);
	if (window.focus) {newwindow.focus()}
	newwindow.opener.name = "opener";
}

function layerPrint(id) {  
  var ficha = document.getElementById(id);
  var ventimp = window.open(' ', 'popimpr');
  ventimp.document.write( ficha.innerHTML );
  ventimp.document.close();
  ventimp.print( );
  ventimp.close();
}

function isChecked(ctrl) {
    for(i=0;i<ctrl.length;i++)
        if(ctrl[i].checked) return true;
	return false;
}

function IsNIF(YourNIF) {
	if (YourNIF.length != 9) return 0
	else 
	{
		var NIFNumber = YourNIF.substring(0, 8)
		var NIFChar = YourNIF.substring(8, 9)	
		NIFChar = NIFChar.toUpperCase()
		cadena="TRWAGMYFPDXBNJZSQVHLCKET" 
		posicio = NIFNumber % 23 
		lletra = cadena.substring(posicio,posicio+1)
		return  (NIFChar == lletra) ? 1 : 0
	} 
}

function IsChar(YourChar) {
	var Template = /^[a-z- ]+$/i
	return (Template.test(YourChar)) ? 1 : 0
}

function IsNumeric(YourNum) {
	var Template = /^[0-9]+$/i
	return (Template.test(YourNum)) ? 1 : 0
}

function IsPostalCode(YourPostalCode, YourProvinceIndex) {
	if (YourPostalCode.length != 5) return 0
	else return (YourPostalCode.substring(0, 2) == PostalCodeInit[YourProvinceIndex]) ? 1 : 0
}
	
function IsPhoneNumber(YourPhoneNumber, YourProvinceIndex) {
	if (YourPhoneNumber.length != 9) return 0
	else if (IsNumeric(YourPhoneNumber) == 0) return 0
	else return (YourPhoneNumber.substring(0, Prefix[YourProvinceIndex].length) == Prefix[YourProvinceIndex]) ? 1 : 0
}

function IsMobile(YourPhoneNumber) {
	if (YourPhoneNumber.length != 9) return 0
	else if (IsNumeric(YourPhoneNumber) == 0) return 0
	else return (YourPhoneNumber.substring(0, 1) == "6") ? 1 : 0
}

function IsMail(YourMail) {
	var Template = /^[a-z-_0-9.]+@[a-z0-9.]+.[a-z]{2,3}$/i
	return (Template.test(YourMail)) ? 1 : 0
}

function IsDay(YourDay, YourMonth) {
	return (parseInt(YourDay) <= DaysInMonth[YourMonth - 1]) ? 1 : 0
}

function IsLeapYear(YourYear) {
	if ((YourYear % 4 == 0 && YourYear % 100 != 0) || (YourYear % 400 == 0)) {return 1}
	return 0
}

function IsDate(Day, Month, Year) {
	if (IsLeapYear(Year) == 0){DaysInMonth[1] = 28}
	else {DaysInMonth[1] = 29}
	return IsDay(Day, Month)
}