
/**************************************/
/* Swap the active CSS */
function setActiveStyleSheet(title) {
	if (document.getElementsByTagName) {
		for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
			if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) a.disabled = true;
			if (a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

/**************************************/
/* Contact Validation */
function validateContact(oForm) {
	var bValid = true;

	if (validateEmail(oForm.email) == false) {
		alert('Please enter a valid email address for your feedback.');
		return false;
	}
	if (oForm.otherInfo.value == '') {
		alert('Please enter your message.');
		return false;
	}

return true;
}

/**************************************/
/* validate the email field */
function validateEmail(field) {
	with (field) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) { return false; }
		else { return true; }
	}
}


function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

//grayOut(true,{'opacity':'25'});
function grayOut(vis, options) {

var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';

    // Calculate the centre minus the dimnentions
	var popupWidth = 350;
	var popupHeight = 170;
	if (window.innerWidth) {
		screenWidth=window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		screenWidth=document.documentElement.clientWidth;
	} else if (document.body) {
		screenWidth=document.body.clientWidth;
	}
	if (window.innerHeight) {
		screenHeight=window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		screenHeight=document.documentElement.clientHeight;
	} else if (document.body) {
		screenHeight=document.body.clientHeight;
	}
	var x = (screenWidth / 2) - (popupWidth / 2);
	var y = (screenHeight / 2) - (popupHeight / 2);   

	// display the disclaimer
  var disc=document.getElementById('disclaimerScreenObject');
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top=y+'px';                           // In the top
        tnode.style.left=x+'px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='disclaimerScreenObject';                   // Name it so we can find it later
        tnode.setAttribute('class', 'disclaimer'); 
		tnode.innerHTML = '<form action="" method=""post"">';
		tnode.innerHTML += '<h3>WARNING</h3>';
		tnode.innerHTML += '<p>By accessing this website you confirm that you are of legal age in the jurisdiction in which you reside and are not offended by any adult material that it may contain.</p>';
		tnode.innerHTML += '<p>Continuing further means you accept this disclaimer.</p>';
//		tnode.innerHTML += '<input type="button" name="choice" value="I AGREE" onClick="location.replace(\'?disclaimer=agreed\');"/>';
		tnode.innerHTML += '<input type="button" name="choice" value="I AGREE" onclick="document.getElementById(\'disclaimerScreenObject\').style.display=\'none\'; document.getElementById(\'darkenScreenObject\').style.display=\'none\'; clearDisclaimer();"/>';
		tnode.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
		tnode.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;';
		tnode.innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
		tnode.innerHTML += '<input type="button" name="choice" value="NO THANKS" onClick="location.replace(\'http://www.google.co.uk\');"/>';
		tnode.innerHTML += '</form>';
    tbody.appendChild(tnode);                            // Add it to the web page
    disc=document.getElementById('disclaimerScreenObject');  // Get the object.
	disc.style.zIndex=zindex;        
//    disc.style.backgroundColor='red';  
    disc.style.width=popupWidth+'px';
    disc.style.height=popupHeight+'px';
    disc.style.display='block';	

  } else {
     dark.style.display='none';
  }
}

/*****************************************************************************************/
// Remove Disclaimer
function clearDisclaimer() {
	var xmlhttp;    

	if (window.XMLHttpRequest) {
		// Normal
		xmlhttp = new XMLHttpRequest();
	} else {
		// IE6
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlhttp.open("GET","_disclaimer.asp",true);
	xmlhttp.send();
}
