function popupSimple(url,w,h)
{
	var hori= w;
	var verti= h;
	var l = (screen.availWidth-hori)/2;
	var t = (screen.availHeight-verti)/2;
	
	if (window.screen)
	{
		window.open(url,'popup'+w+'x'+h, 'width='+hori+', height='+verti+', resize=no, toolbar=no, status=no, menubar=no, scrollbars=yes, left='+(l)+', top='+(t));
		
		//location.href=strPage;
	}
}

function newWindow(strPage,h,w)
{
	if (window.screen)
	{
		window.open(strPage,'newWin', 'resize=yes, toolbar=no, status=no, menubar=yes, scrollbars=no, height='+(h)+', width='+(w));
		
		//location.href=strPage;
	}
}

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_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_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 popup(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
		document.getElementById('selectedrelease').location.href=theURL+'?rel_id='+rel_id;
}

function switch_d(div_id) {
		if (document.getElementById(div_id).style.display=="block")
		{
			document.getElementById(div_id).style.display="none";
		}
		else 
		{
			document.getElementById(div_id).style.display="block";
		}
}

function flip(div_id) {
	if (document.getElementById(div_id)) 
	{
		if (document.getElementById(div_id).style.display=="inline")
		{
				document.getElementById(div_id).style.display="none";
		}
		else 
		{
			document.getElementById(div_id).style.display="inline";
		}
	}
}

function switchContent() {
	if (document.getElementById('content').style.visibility=="hidden")
		{
			document.getElementById('content').style.visibility="visible";
		}
		else 
		{
			document.getElementById('content').style.visibility="hidden";
		}
}

function set_remote(div_id,text) {
	if (text!="") {
		document.getElementById(div_id).innerHTML=text;
	}
	document.getElementById(div_id).style.visibility="visible";
}

function clr_remote(div_id) {
	document.getElementById(div_id).style.visibility="hidden";
}

function close_d(div_id) {
document.getElementById(div_id).style.display="block";
}

function previewPopup(template,pg_id)
{
	window.open('../'+template+'?pg_id='+pg_id,'page_preview');
}

function page_w() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}

function page_h() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}

function getHeight(id)
{
	h = Number.NaN;
	if (document.getElementById) {
		var ele = document.getElementById(id);
		if (ele && typeof ele.offsetHeight != 'undefined') {
			h = ele.offsetHeight;
		}
	}
	return h;
}

function getWidth(id)
{
	w = Number.NaN;
	if (document.getElementById) {
		var ele = document.getElementById(id);
		if (ele && typeof ele.offsetWidth != 'undefined') {
			w = ele.offsetWidth;
		}
	}
	return w;
}

function page_max() {
	top.window.moveTo(0,0);
	if (document.all) {
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
	//alert('w:'+page_w()); alert('h:'+page_h());
}

var colours=new Array ('ff0099','0099ff','ff6600','ffff00');

function random_colour() {
	return (colours[Math.ceil(Math.random()*colours.length)-1]);
}

function cell_focus(cell_i,highlight) {
	cell_blurb_id='cell_blurb'+cell_i;
	cell_header_id='cell_header'+cell_i;
	cell_bg_id='cell_bg'+cell_i;
	cell_container_id='cell_container'+cell_i;
	//if (highlight>0)
	if (1) {
		if (document.getElementById(cell_container_id)) {
			document.getElementById(cell_container_id).className='cell_container_over';
			document.getElementById(cell_container_id).style.borderColor=random_colour();
		}
	}
	if (document.getElementById(cell_blurb_id)) {
		move_to=getHeight(cell_container_id)-getHeight(cell_blurb_id);
		queue = Effect.Queues.get('cell_blurb'+cell_i);
		queue.each(function(effect) { effect.cancel(); });
		new Effect.Move(cell_blurb_id, { x:5, y: move_to, mode: 'absolute', duration: 0.2, queue: { position: 'end', scope: 'cell_blurb'+cell_i }  });
	}
	if (document.getElementById(cell_header_id)) {
		document.getElementById(cell_header_id).style.display='block';
		move_to=0;
		queue = Effect.Queues.get('cell_header'+cell_i);
		queue.each(function(effect) { effect.cancel(); });
		new Effect.Move(cell_header_id, { x:5, y: move_to, mode: 'absolute', duration: 0.2, queue: { position: 'end', scope: 'cell_header'+cell_i }  });
	}
	if (document.getElementById(cell_bg_id)) {
		queue = Effect.Queues.get('cell'+cell_i);
		queue.each(function(effect) { effect.cancel(); });
		new Effect.Opacity(cell_bg_id, { to: 0.99, duration: 0.3, queue: { position: 'end', scope: 'cell'+cell_i }  });
	}
}

function cell_blur(cell_i) {
	cell_blurb_id='cell_blurb'+cell_i;
	cell_header_id='cell_header'+cell_i;
	cell_bg_id='cell_bg'+cell_i;
	cell_container_id='cell_container'+cell_i;
	if (document.getElementById(cell_container_id)) {
		document.getElementById(cell_container_id).className='cell_container';
		document.getElementById(cell_container_id).style.borderColor='222222';
	}
	if (document.getElementById(cell_blurb_id)) {
		move_to=getHeight(cell_container_id);
		queue = Effect.Queues.get('cell_blurb'+cell_i);
		queue.each(function(effect) { effect.cancel(); });
		new Effect.Move(cell_blurb_id, { x:5, y: move_to, mode: 'absolute', duration: 0.1, queue: { position: 'end', scope: 'cell_blurb'+cell_i }  });
	}
	if (document.getElementById(cell_header_id)) {
		move_to=-getHeight(cell_header_id);
		queue = Effect.Queues.get('cell_header'+cell_i);
		queue.each(function(effect) { effect.cancel(); });
		new Effect.Move(cell_header_id, { x:5, y: move_to, mode: 'absolute', duration: 0.1, queue: { position: 'end', scope: 'cell_header'+cell_i }  });
	}
	if (document.getElementById(cell_bg_id)) {
		queue = Effect.Queues.get('cell'+cell_i);
		queue.each(function(effect) { effect.cancel(); });
		new Effect.Opacity(cell_bg_id, { to: 0.3, duration: 0.6, queue: { position: 'end', scope: 'cell'+cell_i } });
	}
}

function blurb_focus(cell_i) {
	document.getElementById('cell_blurb'+cell_i).className='cell_blurb_over';
}

function blurb_blur(cell_i) {
	if (document.getElementById('cell_blurb'+cell_i)) {
		document.getElementById('cell_blurb'+cell_i).className='cell_blurb';
	}
}

function header_focus(cell_i) {
	document.getElementById('cell_header'+cell_i).className='cell_header_over';
}

function header_blur(cell_i) {
	if (document.getElementById('cell_header'+cell_i)) {
		document.getElementById('cell_header'+cell_i).className='cell_header';
	}
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function set_img(src,h,w,caption,ext,download_txt,download_url,img_i,img_n) {
	document.getElementById('detail_image').style.backgroundImage='url('+src+')';
	i=0;
	while (i<img_n) { i++;
		document.getElementById('image_link'+i).className='image';
	}
	document.getElementById('image_link'+img_i).className='image_current';
	if (caption!="") {
		document.getElementById('detail_caption').style.display='block';
		document.getElementById('caption_text').innerHTML=caption;
	} else {
		document.getElementById('detail_caption').style.display='none';
	}
	if (ext=='.pdf') {
		document.getElementById('detail_pdf_link').innerHTML='<a onFocus="this.blur();" class="down" href="'+download_url+'">'+download_txt+'</a>'; 
		document.getElementById('detail_pdf_link_container').style.display='block';
	} else {
		document.getElementById('detail_pdf_link_container').style.display='none';
	}
	if (ext=='.flv') {
		document.getElementById('detail_video').style.display='block';
		flv='<table cellspacing="0" cellpadding="0" border="0" width="100%" height="100%"><tr valign="middle"><td align="center">';
		flv=flv+'<div id="flvplayer"><a onFocus="this.blur();" href="http://www.adobe.com/go/getflashplayer"><img_src="../img/get_flash_player.gif" width="88" height="31" alt="Download Flash Player"></a></div>';
		flv=flv+'</td></tr></table>';
		document.getElementById('detail_video').innerHTML=flv;
		var so = new SWFObject("inc/flvplayer.swf","mpl",w,h,"7");
		so.addParam("allowfullscreen","true");
		so.addParam("allowscriptaccess","true");
		so.addVariable("displayheight",h);
		so.addVariable("file","../"+download_url);
		so.addVariable("height",h);
		so.addVariable("width",w);
		so.addVariable("showdigits","false");
		so.addVariable("autostart","true");
		so.addVariable("repeat","true");
		so.addVariable("showvolume","true");
		so.addVariable("bufferlength","3");
		so.addVariable("type","flv");
		so.write("flvplayer");
	} else {
		if (document.getElementById('detail_video')) {
			document.getElementById('detail_video').style.display='none';
		}
	}
}
	
function detail_menu_focus() {
	if (document.getElementById('detail_menu')) {
		document.getElementById('detail_menu').style.borderColor=random_colour();
	}
	//document.getElementById('detail_controls').style.display='none';
	if (typeof( window[ 'detail_menu_timeout' ] ) != "undefined" ) {
		clearTimeout(detail_menu_timeout);
	}
}

function detail_menu_blur() {
	if (document.getElementById('detail_menu')) {
		document.getElementById('detail_menu').style.borderColor='222222';
	}
	close_detail_menu(400);
}

function show_detail_menu() {
	document.getElementById('detail_controls').style.display='none';
	document.getElementById('detail_menu').style.display='block';
	close_detail_menu(3000);
	//new Effect.Opacity('detail_menu', { to: 0.99, duration: 0.2 });
}

function close_detail_menu(delay) {
	//document.getElementById('detail_menu').style.display='none';
	//document.getElementById('detail_controls').style.display='block';
	//detail_menu_timeout=setTimeout("document.getElementById('detail_controls').style.display='block';",delay);
	detail_menu_timeout=setTimeout("document.getElementById('detail_menu').style.display='none';document.getElementById('detail_controls').style.display='block';",delay);
	//new Effect.Opacity('detail_menu', { to: 0, duration: 1 });
}

function consider_swatch(pantone,hex) {
	if (pantone!='') {
		document.getElementById('swatch_label').innerHTML=pantone;
		document.getElementById('swatch').style.backgroundColor=hex;
		document.getElementById('considering').style.visibility='visible';
	} else {
		document.getElementById('considering').style.visibility='hidden';
	}
}
