// Hide the page
//document.getElementById("siteWrap").style.height = "1px";

// Hide the page
function hidePage(){
	document.getElementById("siteWrap").style.height = "1px";
}
	
var urlHash = window.location.hash.substring(1).toLowerCase();
if(urlHash){
	//alert("Page will display item: " + urlHash);
}else{
	urlHash = missingNode;
}

function emailFieldFocus(ef,isFocus){ // Checks if focus is given or removed to the email field in the mailing list
	if(isFocus && ef.value == 'Enter your email then join the mailing list(s) below.'){
		ef.value=''; 
	}else if(ef.value == ''){			
		ef.value='Enter your email then join the mailing list(s) below.'; 
	}
}
			
function checkEmailForm(){
	var emailEntryValue = emailField.value;	
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var checkResult;
	if(filter.test(emailEntryValue)){
		checkResult = true;
	}else{
		alert("SORRY! Your email address is invalid.");
		checkResult = false;
	}
	return (checkResult)
}
function checkEmailConfirm() {
	var urlQS = window.location.search.substring(1).toLowerCase();
	var parmsQS = urlQS.split('&');
	
	for (var i=0; i<parmsQS.length; i++) {

		if(parmsQS[i] == "leblast=join"){
			alert("OK! You've been added to the Le Blast Mailing List.");
		}else if(parmsQS[i] == "leshow=join"){
			alert("OK! You've been added to the Le Show Mailing List.");
		}
															// Grab email and pass it back to the form
		var emailValCheck = parmsQS[i].split('email=');
		if (emailValCheck[1]){
			emailField.value = unescape(emailValCheck[1]);
		}
	}
}
checkEmailConfirm();

// Detect the IE Broswer
var detect = navigator.userAgent.toLowerCase();
var IEbrowser = detect.indexOf("msie") + 1;

// these are default responses to be returned for ID searches that fail
var missingNode = "";
var missingAttribute = "";

// Function to replace Error Creating html
function html_fixes(s_data) {

	s_data = s_data.replace(/<\/?.*?[\s>]/g, function(tag) { // lowercase tag names
		return tag.toLowerCase()
	});
	
	s_data = s_data.replace(/<(img|br|hr)([^>]*)>/gi, '<$1$2 />'); // add closing slash to img/br/hr
	s_data = s_data.replace(/=(?!")([^"]*?)([\s>])/g, '="$1"$2'); // quote unquoted attributes
	

	// Replace Spacing
	s_data = remove_spaces(s_data);
	
	// Encode HTML
	s_data = s_data.replace(/%/g, '%25'); // encode %
	s_data = s_data.replace(/&/g, '%26'); // encode &
	s_data = s_data.replace(/</g, '%3C'); // encode <
	s_data = s_data.replace(/>/g, '%3E'); // encode >
	s_data = s_data.replace(/\"/g, '%22'); // encode "
	s_data = s_data.replace(/^\s*/g, ''); // remove whitespace from the beginning
	s_data = s_data.replace(/\s*$/g, ''); // remove whitespace from the end
	s_data = s_data.replace(/\+/g, '%2B'); // encode +
	s_data = s_data.replace(/\=/g, '%3D'); // endode =
	return s_data;
}

function remove_spaces(s_data) {
		s_data = s_data.replace(/<\?.*\/>/g, ''); // remove xml declaration
		s_data = s_data.replace(/[\t]/g, ''); // remove tabs
		s_data = s_data.replace(/[\r\n]*?(\S)/g, '$1'); // remove newlines followed by stuff
		s_data = s_data.replace(/(\S)[\r\n]+?(\S)/g, '$1 $2'); // remove newlines (normal ones AND the ones Firefox 1.0 puts in longer bits of text for no particular reason...)
		s_data = s_data.replace(/>\s*</g, '><'); // remove space between tags
		return s_data;

}

// Function to get the Text content of a tag from the ID (e)
	function getID_Text(e){ 
		if(document.getElementById(e)){
			return html_fixes(document.getElementById(e).innerHTML);
		}else{
			return missingNode;
		}
	}
	
// Function to get the specified attribute (p) of a tag from the ID (e)
	function getID_Attr(e, p){
		if(document.getElementById(e) && document.getElementById(e).getAttribute(p)){
			return document.getElementById(e).getAttribute(p);	
		}else{
			return missingAttribute;
		}
	}
	
// Function to register an Onclick Event
// addOnclick(Element, function)
	function addOnclick(e, func) {
		if(e == "ls01"){
			alert("yeah");
		}	
		if(document.getElementById(e)){
			
			document.getElementById(e).onclick = eval(func);
		}
	}

// Le Show Popup
	function leshow_popup() {
		var winleft = (screen.width - 650) / 2;
		var winUp = (screen.height - 700) / 2;
		window.open(this.getAttribute("href"),'leshow','width=650,height=600,left=' + winleft + ',top=' + winUp + ',toolbar=No,location=No,scrollbars=Yes,status=no,resizable=No,fullscreen=No');
		return false;
	}

	function leshow_popup_flash(s_href) {
		var winleft = (screen.width - 650) / 2;
		var winUp = (screen.height - 700) / 2;
		window.open(s_href,'leshow','width=650,height=600,left=' + winleft + ',top=' + winUp + ',toolbar=No,location=No,scrollbars=Yes,status=no,resizable=No,fullscreen=No');
	}
	


// HASH Change Script
///////////////////////////////////////////

function changeUrlHash(addHash){    // just call from actionscript getUrl("javascript:changeUrlHash('#your_hash_link_here');");
	var pgTitle = document.title;
	window.location = addHash;
	document.title = pgTitle;
}

