<!--

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.0
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 && document.getElementById) x=document.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];}
}

if (document.images) 
{
   img1 = new Image();
   img2 = new Image();
   img3 = new Image();
   img4 = new Image();
   img5 = new Image();
   img1.src = "/images/buttons/go_down.gif";
   img2.src = "/images/buttons/go_over.gif";
   img3.src = "/images/header_ontonight_hover.jpg";
   img4.src = "/images/header_cwnews_hover.jpg";
   img5.src = "/images/header_topshots_hover.jpg";
}

// Function to 'activate' images.
function imgOn(imgName) {
        if (document.images) {
            document[imgName].src = eval("nav_" + imgName + "_on.src");
		}
}
// Function to 'deactivate' images.
function imgOff(imgName) {
        if (document.images) {
            document[imgName].src = eval("nav_" + imgName + "_off.src");
        }
}

function preload() { //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=preload.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 restore() { //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.0
	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 && document.getElementById) x=document.getElementById(n); return x;
}

function swap() { //v3.0
	var i,j=0,x,a=swap.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 launch(url,winName,w,h) { //v2.0
	var clip = lleft=(screen.availWidth/2)-(760/2);
	ttop=(screen.availHeight/2)-(600/2);
	newwindow=window.open(url, winName, 'left='+lleft+',top='+ttop+',width='+w+',height='+h+',toolbar=0,status=0,location=0,scrollbars=auto,resizable=no'); 
	if (window.focus) {newwindow.focus()}
	return false;
}

function launch_pr(url,winName,thumbimg) { //v2.0
	var w = 700;
	var h = 600;
	var portrait = 0;
	if ( thumbimg != null )
	{
		var img = new Image();
		img.src = thumbimg;
		if ( img.height > img.width )
		{
			w = 600;
			h = 740;
		}
	}
	
	var clip = lleft=(screen.availWidth/2)-(760/2);
	ttop=(screen.availHeight/2)-(600/2);
	newwindow=window.open(url, winName, 'left='+lleft+',top='+ttop+',width='+w+',height='+h+',toolbar=0,status=0,location=0,scrollbars=auto,resizable=no'); 
	if ( !newwindow.opener ) {newwindow.opener=self;}
	if (window.focus) {newwindow.focus();}
	return false;
}


function launch_dl(url,winName) { //v2.0
	var clip = lleft=(screen.availWidth/2)-(760/2);
	var w = 640;
	var h = 600;
	ttop=(screen.availHeight/2)-(600/2);
	newwindow=window.open(url, winName, 'left='+lleft+',top='+ttop+',width='+w+',height='+h+',toolbar=0,status=0,location=0,scrollbars=yes,resizable=yes'); 
	if (window.focus) {newwindow.focus()}
	return false;
}

function launch2(url,winName,w,h) { //v2.0
	var clip = lleft=(screen.availWidth/2)-(760/2);
	ttop=(screen.availHeight/2)-(600/2);
	newwindow=window.open(url, winName, 'left='+lleft+',top='+ttop+',width='+w+',height='+h+',toolbar=0,status=0,location=0,scrollbars=yes,resizable=no'); 
	if (window.focus) {newwindow.focus()}
	return false;
}


function replace(str1,str2,str3) {
	var i=0,j=0;
	while((i = str1.indexOf(str2,i)) != -1) {
		str1=str1.substring(0,i)+str3+str1.substring(i+=str2.length);
	}
	return str1;
}

//
// position calculations
//

function windowSize() {
    // return an object with the window's available width and height
    // With thanks to www.quirksmode.org
    var size = Object();
    if (self.innerWidth) {
        size.x = self.innerWidth;
        size.y = self.innerHeight;
    } else if (document.documentElement &&
                    document.documentElement.clientWidth) {
        size.x = document.documentElement.clientWidth;
        size.y = document.documentElement.clientHeight;
    } else if (document.body) {
        size.x = document.body.clientWidth;
        size.y = document.body.clientHeight;
    }
    return size;
}

function getElementPos(element) {
    // Return (x,y) for top-left of the given element, relative to document
    var res = Object();
    res.x = 0;
    res.y = 0;
    for (var obj = element; obj.offsetParent; obj = obj.offsetParent) {
        res.x += obj.offsetLeft;
        res.y += obj.offsetTop;
    }
    return res;
}

function moveToCenter(element, size) {
    // Move given element to center of given size
    element.style.left = "" + Math.floor((size.x-element.offsetWidth)/2) +
        "px";
    element.style.top = "" + Math.floor((size.y-element.offsetHeight)/2) +
        "px";
}

function SetScheduleDate( f )
{
	var sel = $("#scheduleweek")[0];
	if ( sel )
	{
		window.location = sel.options[sel.selectedIndex].value;
	}
	
	return false;
}

function DownLoadCWPRDocument( t, id, n )
{
	window.location = "/file/get/" + t + "/" + id + "/" + n;
	
	return false;
}


function OpenPopupWin1(url,title,w,h)
{
	var newwin = window.open( url,title,'width='+w+',height='+h+',status=yes,scrollbars=yes,resizable=no,location=no,toolbar=no');
	if (newwin) newwin.focus();
}

function ToggleBlocks( showid, hideid )
{
	$("#"+hideid).hide("fast");
	$("#"+showid).show("fast");
}

function ShowShowSummary( show )
{
	//alert( 'ShowShowSummary:'+show);
	if ( show )
	{
		$("#showsummaryblk").hide("fast");
		$("#showfullblk").show("fast");
	}
	else
	{
		$("#showfullblk").hide("fast");
		$("#showsummaryblk").show("fast");
	}
}


function el(id) {
  if (document.getElementById) {
    return document.getElementById(id);
  } else if (window[id]) {
    return window[id];
  }
  return null;
}


function hide_show_lb( mode )
{
	var lb = el('lbfooter');
	var lbpad = el('footerpad');
	
	if ( lb )
	{
		if ( mode == 'show' )
		{
			lb.style.height = '235px';
			
			if ( lbpad )
			{
				lbpad.style.height = '235px';
				lbpad.style.display = 'block';
			}
		}
		else if ( mode == 'min' )
		{
			lb.style.height = '35px';
			if ( lbpad )
			{
				lbpad.style.height = '35px';
				lb.style.display = 'block';
			}
		}
		else
		{
			lb.style.height = '0px';
			if ( lbpad )
			{
				//lbpad.style.height = '0px';
				lbpad.style.display = 'none';
			}
		}
	}
}

function minimizelightbox()
{
	lightbox_command(this,'min','');
}


function lightbox_command( control, cmd, image_key, closewin )
{
	xmlhttpclosewin = closewin;

	if ( cmd == 'add' || cmd == 'remove' || cmd == 'show' )
	{
		hide_show_lb('show');
	}
	else if ( cmd == 'min' || cmd == 'download_all' )
	{
		hide_show_lb('min');
	}
	else if ( cmd == 'hide'  )
	{
		hide_show_lb('hide');
	}	

	var timeval = new Date().getTime();
	var url = "/lightbox/" + cmd + "/" + image_key + "/?rand=" + timeval;  // prevents caching of URL request
	
	// load lightbox with updated html
	$.get( url,function(txt) {
		$("div#lbfooter").html(txt);
		
		// close popup, if any
		if ( xmlhttpclosewin && xmlhttpclosewin.document )
			xmlhttpclosewin.close(); 
		xmlhttpclosewin = null;
		//alert( "complete" );
	});

}

var promo_index = 0;
function rotate_promo(  )
{
	if ( promo_cnt > 0 )
	{
		promo_index = Math.floor(Math.random()*promo_cnt); 
		
		if ( promolinks[promo_index] != '' )
		{
			var promolink = el('promolink');
			var promoimg = el('promoimg');
			
			promolink.href = promolinks[promo_index];
			promoimg.src = promoimgs[promo_index];			
		}
	}
}

function rotate_promo2(  )
{
	if ( promo_cnt > 0 )
	{
		if ( promolinks[promo_index] == '' )
			promo_index = 0;
		
		if ( promolinks[promo_index] != '' )
		{
			var promolink = el('promolink');
			var promoimg = el('promoimg');
			
			promolink.href = promolinks[promo_index];
			promoimg.src = promoimgs[promo_index];
			promo_index++;
			
			setTimeout("rotate_promo()",2000);
		}
	}
}

function submitform( theform )
{
	if(theform.onsubmit())
	{
    		//this check triggers the validations
		theform.submit();
	}
}

//function submitform()
//{
//	if(document.myform.onsubmit())
//	{
		//this check triggers the validations
//		document.myform.submit();
//	}
//}

//-->