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 MM_showHideLayers() { //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function genericwin(theurl,thename,thewidth,theheight,special,left,top,scrollToggle,resizeToggle) {
	if (special==1) { var left=(screen.width-thewidth)/2; var top=(screen.height-theheight)/2; }
window.open(theurl,thename,'left='+left+',top='+top+',width='+thewidth+',height='+theheight+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scrollToggle+',resizable='+resizeToggle+'');
}

function layerHeight(_id,_h) {
	document.getElementById(_id).style.height = _h+"px";
}

//navigation window function
function navigateTo(_url,_frame) {
	if(_frame=="_top") {
		top.location.href=_url;
	} else {
		window.open(_url);
	}
}

//layer show/hide and inner text set
function contentShow(_layer,_state,_txt,_lines) {
	(_lines==true) ? _txt=_txt.split("\n").join("<br/>") : null;
	document.getElementById(_layer).innerHTML=_txt;
	MM_showHideLayers(_layer,'', _state);
}


//#IMAGE VIEWER FUNCTIONS
imageIn=false;

//show the image
function imageShow(_topTitle,_srcList,_titleList,_num) {
	//resize the layer
	var size=dims();
	
	//target
	var swf=MM_findObj('imageView','');
	var container=MM_findObj('imgHolder','');
	
	//set the variables inside the swf and load it
	swf.loadImageset(_topTitle,_srcList,_titleList,_num);
	
	//set the sizing of the layer
	container.style.width=size[0]+"px";
	container.style.height=size[1]+"px";
	
	//image is in
	imageIn=true;
}

//close the image
function imageClose() {
	//shrink the holder and unload the movie
	document.getElementById("imgHolder").style.width="0px";
	document.getElementById("imgHolder").style.height="0px";
	document.getElementById("imageView").loadKill();
	
	//image out
	imageIn=false;
}

//#CONTENT RESIZE
function resizeContent() {
	if(imageIn) {
		//resize the image area
		var size=dims();
		document.getElementById("imgHolder").style.width=size[0]+"px";
		document.getElementById("imgHolder").style.height=size[1]+"px";
	}
}

//#WINDOW DIMENSION FUNCTIONS
function WindowHeight() {
	if (typeof(window.innerHeight) == "number") { // not ie - firefox - subtract the height of our scrollbar
		return window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {// ie6 standards compliant mode 
		return document.documentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {// ie4 compatible 
	}
}	

function WindowWidth() {
	if (typeof(window.innerWidth) == "number") {// not ie - firefox - subtract the width of our scrollbar
		return window.innerWidth-16;
	} else if (document.documentElement && document.documentElement.clientWidth) {// ie6 standards compliant mode 
		return document.documentElement.clientWidth;
	} else if (document.body && document.body.clientWidth) {// ie4 compatible 
		return document.body.clientWidth;
	}
}	

function dims() {
	var x,y;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2) // all but Explorer Mac
	{
		x = document.body.scrollWidth;
		y = document.body.scrollHeight;
	}
	else // Explorer Mac;
	     //would also work in Explorer 6 Strict, Mozilla and Safari
	{
		x = document.body.offsetWidth;
		y = document.body.offsetHeight;
	}
	return Array(x,y);
}

//#FEATURE reloader
function itemLoad(id) {
	if(id!=cid) {
		//reset the body copy
		contentShow('bodyContent','hide','');
		
		//reset the height
		document.getElementById("feature_block").style.height="76px";
	 
	 	//call a reload
		document.getElementById("feature_block").loadRefresh(id);
	 
	 //store the cid
		cid=id;
	}
}   

//THUMB filter
function thumbFilter(_str) {   
	
	//reset the body copy
	contentShow('bodyContent','hide','');
	
	//call a filter change         
	document.getElementById("feature_block").filterChange(_str);
}     

//PASS through an ID to the submenu
function submenuSendID(_id) {
	//call a filter change         
	document.getElementById("swf_submenu").idChange(_id);
}
