// preloads
nF=new Image();
nF.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/menu_why-smokefree.gif";
nFon=new Image();
nFon.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/menu_why-smokefree_on.gif";
nG=new Image();
nG.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/menu_what-do-i-do.gif";
nGon=new Image();
nGon.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/menu_what-do-i-do_on.gif";
nH=new Image();
nH.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/menu_the-facts.gif";
nHon=new Image();
nHon.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/menu_the-facts_on.gif";
nI=new Image();
nI.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/menu_smokefree-world.gif";
nIon=new Image();
nIon.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/menu_smokefree-world_on.gif";
nJ=new Image();
nJ.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/menu_supporters.gif";
nJon=new Image();
nJon.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/menu_supporters_on.gif";
nA=new Image();
nA.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/nav_home.gif";
nAon=new Image();
nAon.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/nav_home_on.gif";
nB=new Image();
nB.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/nav_faq.gif";
nBon=new Image();
nBon.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/nav_faq_on.gif";
nC=new Image();
nC.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/nav_contact.gif";
nCon=new Image();
nCon.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/nav_contact_on.gif";
nD=new Image();
nD.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/nav_resources.gif";
nDon=new Image();
nDon.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/nav_resources_on.gif";
nE=new Image();
nE.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/nav_sitemap.gif";
nEon=new Image();
nEon.src="http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/images/nav_sitemap_on.gif";

function Swap(imageID,imageName) {
	if(MM_findObj(imageID)){
	 MM_findObj(imageID).src = eval(imageName + ".src");
	}	
}

function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
	obj.addEventListener(evType, fn, false); 
	return true; 
	}
	else if (obj.attachEvent){ 
	var r = obj.attachEvent("on"+evType, fn); 
	return r; 
	} else { 
	return false; 
	} 
}

function CheckContentForm(daForm) {
return;
	var MissingFields=0;
	var ManFieldValue=daForm.mandatory.value;
	var ManFields=ManFieldValue.split(",");
	for(x=0;x<ManFields.length;x++) {
	FieldName=ManFields[x];
		// go through validation options	
		if(FieldName.indexOf("{email}")>1) {
			FieldName=FieldName.replace("{email}","");
			if(!TestEmail($F(FieldName))) {
			var MissingFields=MissingFields+1;
			}
		}
		else if(FieldName.indexOf("{number}")>1) {
			FieldName=FieldName.replace("{number}","");			
			if(isNaN($F(FieldName)) || $F(FieldName)=="") {
			var MissingFields=MissingFields+1;
			}
		}
		else if(FieldName.indexOf("{amount}")>1) {
			FieldName=FieldName.replace("{amount}","");			
			FieldValue=$F(FieldName).replace("$","");
			if(isNaN(FieldValue) || $F(FieldName)=="") {
			var MissingFields=MissingFields+1;
			}
		}
		else if(FieldName.indexOf("[]")>1) {
			FieldName=FieldName.replace("[]","");
			var MissingFields=MissingFields+1;
			for(y=0;y<MM_findObj(FieldName).length;y++) {
				//if(MM_findObj(FieldName)[y].checked==true) {
				var MissingFields=MissingFields-1;
				//}
			}
		}
		else if(FieldName.indexOf("{=")>1) { // needs to equal another field
			FirstFieldName=FieldName.replace(/\{=([a-zA-Z0-9_\-]*)\}/g,"");
			FieldNameToMatch=FieldName.replace(FirstFieldName+"{=","");
			FieldNameToMatch=FieldNameToMatch.replace("}","");
			if($F(FirstFieldName) != $F(FieldNameToMatch)) {
			var MissingFields=MissingFields+1;
			}
		}
		else {
			if(MM_findObj(FieldName).length>1) {
				if(MM_findObj(FieldName)[0].type=="radio" || MM_findObj(FieldName)[0].type=="checkbox") {
					var MissingFields=MissingFields+1;
					for(y=0;y<MM_findObj(FieldName).length;y++) {
						if(MM_findObj(FieldName)[y].checked==true) {
						var MissingFields=MissingFields-1;
						}
					}
				}
			}
			else {
				if(MM_findObj(FieldName).value=="") {
				var MissingFields=MissingFields+1;
				}
			}
		}
	}
		
	if(ManFields.length > 0) {
		if(MissingFields>0) {
		alert("Please fill out all fields marked with an asterisk.");
		return false;
		}
		else {
		return true;
		}
	}
	else {
	return true;
	}
}

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 TestEmail(e) {
	if(e) {
	p = e.indexOf('@');
	s = e.indexOf(';');
	d = e.lastIndexOf('.');
		if (p<1 || p==(e.length-1) || d<p || d==(e.length-1) || s>-1) {
		return false;
		}
	return true;
	}
return false;
}

function RemoveJunk(El,DataType) {
var V = El.value;
	if(DataType=="int") {
		if (/[^0-9\.]/g.test(V)) {
		El.value = V.replace(/[^0-9\.]/g, '');
		}
	}
	else if(DataType=="string") {
		if (/[^a-zA-Z\.]/g.test(V)) {
		El.value = V.replace(/[^a-zA-Z\.]/g, '');
		}
	}
	else if(DataType=="stringint") {
		if (/[^a-zA-Z0-9]/g.test(V)) {
		El.value = V.replace(/[^a-zA-Z0-9]/g, '');
		}
	}
	else if(DataType=="password") {
		if (/[^a-zA-Z0-9_!\$\.]/g.test(V)) {
		El.value = V.replace(/[^a-zA-Z0-9_!\$\.]/g, '');
		}
	}
	else if(DataType=="amount") {
		if (/[^0-9\.\$]/g.test(V)) {
		El.value = V.replace(/[^0-9\.\$]/g, '');
		}
	}
	else if(DataType=="nofloat") {
		if (/[^0-9\$]/g.test(V)) {
		alert('Sorry, only whole dollar amounts are permitted.');
		El.value = V.replace(/[^0-9\$]/g, '');
		}
	}
}

function clearForm(formIdent) {
  var form, elements, i, elm; 
  form = document.getElementById 
    ? document.getElementById(formIdent) 
    : document.forms[formIdent]; 

	elements = form.elements;
		for( i=0, elm; elm=elements[i++]; )
		{
			if (elm.type == "text")
			{
				elm.value ='';
			}
			
			if (elm.type == "radio" || elm.type == "checkbox")
			{
				elm.checked = false;
			}
			
			if (elm.length > 1 && (elm.type != "radio" || elm.type != "checkbox"))
			{
			
				elm.selectedIndex = 0;
			}
		}
}

function CheckPoll(daForm) {
	var SafeToPost=false;
	for(i=0;i<daForm.elements.length;i++) {
		if(daForm.elements[i].type=="radio") {
			if(daForm.elements[i].checked==true) {
			var SafeToPost=true;
			}
		}
	}
	if(SafeToPost==true) {
		//if (GBrowserIsCompatible() && !is_ie5) { // ajax friendlys
		//	var AjaxPoll = new Ajax.Updater(
		//		{success: 'HomePagePoll'}, 
		//		"/_ajax.polls.inc.php", 
		//		{
		//		method: 'post', 
		//		parameters: Form.serialize(daForm), 
		//		onFailure: doResetPoll,
		//		evalScripts: true
		//	});
		//return false;
		//}
		//else { // traditional post
		
		//}
	}	
	else {
	alert("Please select an option to participate in the quiz");
	return false;
	}
}

function doResetPoll() {
	alert('There was a problem');
	return true;
}

function doCheckOptin(daForm) {
	if($F("op_fname")=="" || $F("op_lname") == "" || $F("op_email") == "") {
	alert("Please enter your details into the fields provided");
	return false;
	}
	if(!TestEmail($F("op_email"))) {
	alert("Please check that your email address has been entered in correctly");
	return false;
	}
	
	var AjaxOptin = new Ajax.Updater(
		{success: 'PodStayInformed'}, 
		"http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/_ajax.optin.inc.php", 
		{
		method: 'post', 
		parameters: Form.serialize(daForm), 
		onFailure: doManualOptin,
		evalScripts: false
		});
	return false;
}

function doManualOptin() {
	
}

function doSendFriendEmail(daForm) {
	if($F("sf_name")=="" || $F("sf_name_fr") == "" || $F("sf_email") == "" || $F("sf_email_fr") == "") {
	alert("Please enter your details into the fields provided");
	return false;
	}
	if(!TestEmail($F("sf_email"))) {
	alert("Please check that your email address has been entered in correctly");
	return false;
	}
	if(!TestEmail($F("sf_email_fr"))) {
	alert("Please check that your friends email address has been entered in correctly");
	return false;
	}
	
	var AjaxEmailPage = new Ajax.Updater(
		{success: 'PopContent'}, 
		"http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/_ajax.emailpage.inc.php", 
		{
		method: 'post', 
		parameters: Form.serialize(daForm), 
		onFailure: doManualOptin,
		evalScripts: false
		});
	return false;
}

function RotateVoxPops() {
setTimeout("GetVoxPopImage()",4000);
}

function GetVoxPopImage() {
var myVoxAjax = new Ajax.Updater('VoxBox', 'http://collections.europarchive.org/tna/20110202220654/http://www.smokefreeengland.co.uk/_ajax.vox.inc.php', {method: 'get'});
RotateVoxPops();
}

function OpenIboxWindow(dUrl) {
	if(dUrl) {
	var params = parseQuery('height=400');
	showBG();
	showIbox(dUrl,'',params);	// show ibox
	window.onscroll = maintPos;
	window.onresize = maintPos;
	}
}

function page_set(){	
	if(is_ie6) {
		var windowWidth = 0, windowHeight = 0, diff=0;
		if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
		diff=10;
		} 
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
		} 
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
		}
		if(MM_findObj("PageContainerOuter").style.height < windowHeight-45){
		MM_findObj("PageContainerOuter").style.height=(windowHeight-45).toString()+"px";
		MM_findObj("ContentContainer").style.height=((windowHeight-163)+diff).toString()+"px";
		}
	}
	
}

function init_sifr() {
	if(typeof sIFR == "function"){
	sIFR.replaceElement("h2", named({sFlashSrc: "http://collections.europarchive.org/tna/20110202220654/http://smokefree.profero.com.au/flash/paralucent.swf", sColor: "#003366", sWmode: "transparent"}));
	};
}

/* cookie stuff for flash detection */

var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
	var j = i + alen;    
	if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}
function SetCookie (name, value) {  
	var expires = (exp > 2) ? exp : null;  
	var path = null;  
	var domain = null;  
	var secure = false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	// This cookie is history  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

if(is_Flash) {
SetCookie('FlashPlayer',is_FlashVersion );
}

//addEvent(window, 'load', page_set);
addEvent(window, 'load', init_sifr);


