// 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;
}

// 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 - 500) / 2;
		var winUp = (screen.height - 700) / 2;
		window.open(this.getAttribute("href"),'leshow','width=500,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 - 500) / 2;
		var winUp = (screen.height - 700) / 2;
		window.open(s_href,'leshow','width=500,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;
}