	function showBlock(block){
		f = document.getElementById(block);
		if (f.style.display =='none'){
			f.style.display = "block";
		}else{
			f.style.display = "none";
		}
		
	}
	function changeCategory($catId){
		f = document.forms["subCategoryForm"];
		f.changeCatId.value = $catId;
		f.submit();
	}

	function selectProduct($prodId, $action){
		f = document.forms["subProductForm"];
		f.productId.value = $prodId;
		f.productAction.value = $action;
		f.submit();
	}
	var popUpWin=0;
	function startVirtualTour(URLStr, left, top, width, height){
	URLStr='virtualtour.php';
	left='200';
	top='200';
	width='350';
	height='400';

  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
 // popUpWin = open('virtualtour.php','Cardinal Newman-Virtual Tour','height=400,width=350,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

	}

	function changeMenu($menuId){
		f = document.forms["sideMenuForm"];
		f.menuItem.value = $menuId;
		f.submit();
	}

	function MM_swapImgRestore() { //v3.0
		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	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_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
 	function MM_swapImgRestore() { //v3.0
		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	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_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

    function selectLang(code){

        lang = document.getElementById('lang');
        lang.value=code;
        f = document.getElementById('langSelectForm');
        f.submit();
    }
	    
function initScrollLayers() {
  var wndo1 = new dw_scrollObj('wn1', 'lyr1', null);

  wndo1.setUpScrollbar("dragBar1", "track1", "v", 0, 0);
  
  dw_showLayers("scrollbar1");

}
function dw_showLayers() {
  if ( document.getElementById ) {
    var lyr, i;
    for (i=0; arguments[i]; i++) {
      lyr = document.getElementById( arguments[i] );
      lyr.style.visibility = "visible";
    }
  }
}   

function checkEmailAddress(field) {
	// Note: The next expression must be all on one line...
	//       allow no spaces, linefeeds, or carriage returns!
	var goodEmail = field.match(/\b(^(\S+@).+(\..{2,3})$)\b/gi);	
	return (goodEmail);
	
}
function checkCandidateInterestForm() {
	var field = new Array;
	var form = document.getElementById("interestForm");
	var candidates_regname = document.getElementById("candidates_regname").value;
	var candidates_regemail = document.getElementById("candidates_regemail").value;	
	var candidates_regphone = document.getElementById("candidates_regphone").value;
	var candidates_daytocontact = document.getElementById("candidates_daytocontact").value;
	var candidates_timetocontact = document.getElementById("candidates_timetocontact").value;	
	if (candidates_regname=='') { field.push('name'); }
	if (candidates_regemail=='') { field.push('e-mail'); }
	if (candidates_regphone=='') { field.push('phone'); }
	if (candidates_daytocontact=='') { field.push('days to contact'); }
	if (candidates_timetocontact=='') { field.push('time to contact'); }
	if (field.length > 0) {
		var msg = "Missing field(s): ";
		for (x=0 ; x<field.length ; x++) {
			msg += field[x];
			if (x<field.length-1) {
					msg += ", ";
			}
		}
	}else if (!checkEmailAddress(candidates_regemail)) {
			msg= 'Wrong e-mail address!';
	}
	if (!msg) {
		form.submit();		
	}else{	
		alert (msg);
	}
}


function checkJobInterestForm() {
	var field = new Array;
	var form = document.getElementById("interestForm");
	var jobs_regname = document.getElementById("jobs_regname").value;
	var jobs_regemail = document.getElementById("jobs_regemail").value;
	var jobs_regphone = document.getElementById("jobs_regphone").value;
	var jobs_daytocontact = document.getElementById("jobs_daytocontact").value;
	var jobs_timetocontact = document.getElementById("jobs_timetocontact").value;	
	if (jobs_regname=='') { field.push('name'); }
	if (jobs_regemail=='') { field.push('e-mail'); }
	if (jobs_regphone=='') { field.push('phone'); }
	if (jobs_daytocontact=='') { field.push('days to contact'); }
	if (jobs_timetocontact=='') { field.push('time to contact'); }
	if (field.length > 0) {
		var msg = "Missing field(s): ";
		for (x=0 ; x<field.length ; x++) {
			msg += field[x];
			if (x<field.length-1) {
					msg += ", ";
			}
		}
	}else if (!checkEmailAddress(jobs_regemail)) {
			msg= 'Wrong e-mail address!';
	}
	if (!msg) {
		form.submit();		
	}else{	
		alert (msg);
	}
}



function checkJobCVForm() {
	var field = new Array;
	var form = document.getElementById("submitCVForm");
	var jobcv_firstname = document.getElementById("jobcv_firstname").value;
	var jobcv_lastname = document.getElementById("jobcv_lastname").value;
	var jobcv_regemail = document.getElementById("jobcv_regemail").value;
	var jobcv_regphone = document.getElementById("jobcv_regphone").value;
	var jobcv_file = document.getElementById("jobcv_file").value;
	if (jobcv_firstname=='') { field.push('firstname'); }
	if (jobcv_lastname=='') { field.push('lastname'); }
	if (jobcv_regemail=='') { field.push('e-mail'); }
	if (jobcv_regphone=='') { field.push('phone'); }
	if (jobcv_file=='') { field.push('CV'); }
	if (field.length > 0) {
		var msg = "Missing field(s): ";
		for (x=0 ; x<field.length ; x++) {
			msg += field[x];
			if (x<field.length-1) {
					msg += ", ";
			}
		}
	}else if (!checkEmailAddress(jobcv_regemail)) {
			msg= 'Wrong e-mail address!';
	}
	if (!msg) {
		form.submit();		
	}else{	
		alert (msg);
	}
}


function checkJobReferForm() {
	var field = new Array;
	var form = document.getElementById("referForm");	
	var jobs_regnamefrom = document.getElementById("jobs_regnamefrom").value;
	var jobs_regemailfrom = document.getElementById("jobs_regemailfrom").value;
	if (jobs_regnamefrom=='') { field.push('Name from'); }
	if (jobs_regemailfrom=='') { field.push('e-mail from'); }	
	var jobs_regnameto = document.getElementById("jobs_regnameto").value;
	var jobs_regemailto = document.getElementById("jobs_regemailto").value;
	if (jobs_regnameto=='') { field.push('Name to'); }
	if (jobs_regemailto=='') { field.push('e-mail to'); }	
	if (field.length > 0) {
		var msg = "Missing field(s): ";
		for (x=0 ; x<field.length ; x++) {
			msg += field[x];
			if (x<field.length-1) {
					msg += ", ";
			}
		}
	}else if (!checkEmailAddress(jobs_regemailto) || !checkEmailAddress(jobs_regemailfrom)) {
			msg= 'Wrong e-mail address!';
	}
	if (!msg) {
		form.submit();		
	}else{	
		alert (msg);
	}
}

function checkCandidateReferForm() {
	var field = new Array;
	var form = document.getElementById("referForm");	
	var candidates_regnamefrom = document.getElementById("candidates_regnamefrom").value;
	var candidates_regemailfrom = document.getElementById("candidates_regemailfrom").value;
	if (candidates_regnamefrom=='') { field.push('Name from'); }
	if (candidates_regemailfrom=='') { field.push('e-mail from'); }	
	var candidates_regnameto = document.getElementById("candidates_regnameto").value;
	var candidates_regemailto = document.getElementById("candidates_regemailto").value;
	if (candidates_regnameto=='') { field.push('Name to'); }
	if (candidates_regemailto=='') { field.push('e-mail to'); }	
	if (field.length > 0) {
		var msg = "Missing field(s): ";
		for (x=0 ; x<field.length ; x++) {
			msg += field[x];
			if (x<field.length-1) {
					msg += ", ";
			}
		}
	}else if (!checkEmailAddress(candidates_regemailto) || !checkEmailAddress(candidates_regemailfrom)) {
			msg= 'Wrong e-mail address!';
	}
	if (!msg) {
		form.submit();		
	}else{	
		alert (msg);
	}
}



function downloadFile (hash) {
	window.open ('../downloader.php?file='+hash);
}
	
function checkSubscribeForm() {
	var field = new Array;
	var form = document.getElementById("subscribeform");	
	var email1 = document.getElementById("email").value;
	var email2 = document.getElementById("email2").value;
	if (email1=='') { field.push('e-mail'); }
	if (email2=='') { field.push('condirm e-mail'); }
	
	
	if (field.length > 0) {
		var msg = "Missing field(s): ";
		for (x=0 ; x<field.length ; x++) {
			msg += field[x];
			if (x<field.length-1) {
					msg += ", ";
			}
		}
	}else if (email1 != email2) {
			msg= 'These e-mail addresses must be the same!';
	}else if (!checkEmailAddress(email1) || !checkEmailAddress(email2)) {
			msg= 'Wrong e-mail address!';
	}
	if (!msg) {
		form.submit();		
	}else{	
		alert (msg);
	}

}
