// --------------------------------------------------
// code copyright Lightmaker 2009
// --------------------------------------------------
// common.js
// created: 31 July 2009
// lightmaker.com
// --------------------------------------------------


function showhide(o,st)
{
	if (typeof(o)=="string")
	{
		o=document.getElementById(o);
	}
	if (!o)
	{
		return;
	}
	if (typeof(st)!="boolean")
	{
		st=(o.style.display=="none");
	}
	o.style.display=(st) ? "" : "none";
	return st;
}

// Popup Window (Centred)
function popup(url,winname,w,h,feat) {
	if (!(isNaN(w) || isNaN(h))) {
		var x=parseInt((screen.width-w)/2);
		var y=parseInt((screen.height-h)/2);
		if (x<0)	x=0;
		if (y<0)	y=0;
		
		if (feat!=null && feat!="") {
			feat=","+feat;
		} else {
			feat="";
		}
		feat="left="+x+",top="+y+",width="+w+",height="+h+feat;
	}
	var w=window.open(url,winname,feat);
	if (w)
	{
		w.focus();
	}
}



function page_bookmark()
{
	if (window.sidebar) // Mozilla Firefox Bookmark
	{
		window.sidebar.addPanel(document.title, location.href,"");
	}
	else if (window.external) // IE Favorite
	{
		window.external.AddFavorite( location.href, document.title);
	}
}

function page_print()
{
	window.print();
}



function youtube_inject(id,ref)
{
	var o=document.getElementById(id);
	if (o)
	{
		var m='http://www.youtube.com/v/'+ref+'&hl=en&fs=1&rel=0&showinfo=0&iv_load_policy=3';
		o.innerHTML='<object width="460" height="315"><param name="movie" value="'+m+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+m+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="460" height="315"></embed></object>';
	}
}

var timer=new Object();
function showhidemenu(id,st,notimer)
{
	clearTimeout(timer[id]);
	var o=document.getElementById(id);
	if (!o)
	{
		return;
	}
	var cl=o.className;
	if (typeof(st)!="boolean")
	{
		st=(cl.indexOf("hide")==-1);
	}
	if (st)
	{
		cl=cl.replace("hide","");
	}
	else
	{
		cl+=" hide";
	}
	if (cl.indexOf("hide")!=-1 && notimer!=true)
	{
		timer[id]=setTimeout("showhidemenu('"+id+"',"+st+",true)",200)
		return st;
	}
	o.className=cl;
	return st;
}


function passqs(href,f,v)
{
	if (href.indexOf("?")==-1)
	{
		href+='?';
	}
	href+=f+'='+escape(v);
	location=href;
	return false;
}