
//	File: 	my_etc.js
// 	Desc: 	Random js functions... 

// to Int -- strips all non numeric chars except '-' 


function tInt(string){
	return parseInt(string.replace("[^-0-9]",""));
}


function debug(msg){
	$('debug').style.display = "block";
	$("debug").innerHTML = "<pre><code>"+msg+"</code></pre>";
}



/* unfinished!!! regex is matching, not replacing */
function set_nav_indicators(){

	//determine name of current page
	if(location.pathname == "/"){
		var page1 = "home";
	} else {	
		var rx = /[a-z0-9_]+(?=\.php)/i;
		var pageArr = location.pathname.match(rx);
		var page1 = pageArr[0];
	}

	// if we're on a subpage (e.g. solutions_faq), strip off everything
	// after the "_" so we can still reflect location in the top-level
	// navigation (we use page1 | page2 in the regex below)
	
	if(page1.match("_") != null){
		var page2 = page1.slice(0,page1.search("_"));
	}
	
	// find appropriate nav elements and class them as "current"
	// main_nav
	
	rx = new RegExp("<li(?=><a href=.(" + page1 + "|" + page2 + ".))","i");
	//this is all screwy... 
	a = $("main_nav").innerHTML;
	if($('sub_nav')){$("sub_nav").innerHTML.replace(rx,"<li class='current'");}
	$("footer_nav").innerHTML.replace(rx,"<li class='current'");

	//abandoned regex to match pageName in /asdfasdf/asdfads/(pageName).(css|co.uk|ext.country.domain.abrv)
	//var rx = /[a-z0-9_]+(?:((\.[a-z0-9])*))/i;

}



Pane = {
	state	: 	0,		//defaults to up
	
	// containing element
	el_id	: 	"contact_pane",
	height	: 	"180px",
	// content
	con_id	: 	"contact_pane_content",
	toggle	: 	function(){
		if(this.state == 0){
			$(this.con_id).style.display="block";
			$(this.el_id).style.display='none';
			$(this.el_id).style.height=this.height;
			Effect.SlideDown(this.el_id, {scaleFrom: 11});
			this.state = 1;
		} else {
			Effect.SlideUp(this.el_id, { scaleTo: 11, restoreAfterFinish: false});
			this.state = 0;
		}
	}
};










