function showContent(tab)
{
  var content = 'featuredContent_' + tab;
  var nav_item = 'nav_' + tab;
  var elems = document.getElementsByTagName("*"); 
  for (var i=0;i<elems.length;i++) {
    if ( elems[i].id.substring(0,16) == 'featuredContent_' ) { 						// Hide all other content
    	elems[i].style.display = 'none';
    }
    //if ( elems[i].id.substring(0,4) == 'nav_' ) {									// Set all subnav to inactive
    //elems[i].src = 'images/featuredContent/' + elems[i].id + '-over.gif';
    //}
  }
  document.getElementById(content).style.display = 'block';							// Show selected tab
  //document.getElementById(nav_item).src = 'images/featuredContent/' + nav_item + '.gif';					// Set selected tab's nav to active
}

function showSubsection(tab)
{
  var content = 'mainTab_' + tab;
  var nav_item = 'mainNav_' + tab;
  var elems = document.getElementsByTagName("*"); 
  for (var i=0;i<elems.length;i++) {
    if ( elems[i].id.substring(0,8) == 'mainTab_' ) { 						// Hide all other content
    elems[i].style.display = 'none';
    }
    if ( elems[i].id.substring(0,8) == 'mainNav_' ) {									// Set all subnav to inactive
    elems[i].src = 'images/featuredContent/' + elems[i].id + '-over.gif';
    }
  }
  document.getElementById(content).style.display = 'block';							// Show selected tab
  document.getElementById(nav_item).src = 'images/featuredContent/' + nav_item + '.gif';					// Set selected tab's nav to active
}

function tabber(anchor)
{
	//alert(anchor.parentNode.parentNode.parentNode.innerHTML);
	alert(anchor.parentNode.parentNode.innerHTML);
	var elems = anchor.parentNode.parentNode.parentNode.getElementsByTagName("*");
	for( var i = 0; i < elems.length; i++ )
	{
		if ( elems[i].id.substring(0,16) == 'featuredContent_' )
		{
			elems[i].style.display = 'none';
		}
	}
	
}

function showHide(dropdown)
{
	
	if(document.getElementById(dropdown).style.visibility == 'hidden')
	{
		document.getElementById(dropdown).style.visibility = 'visible';
	}
	else if(document.getElementById(dropdown).style.visibility == 'visible')
	{
		document.getElementById(dropdown).style.visibility = 'hidden';
	}
}
function addSizedIMG(imageSrc,linkSrc,alt,tarW,tarH,tarDiv)					// Roderick Peace and Evan Lim 5-12-08
{
	x=new Image;
	x.src=imageSrc;
	x.tarDiv=tarDiv;
	
	x.onload = function()
	{
		iw=this.width;
		ih=this.height;
		
		imageRatio=ih/iw;
		tarRatio=tarH/tarW;
		
		strImageHTML = '' ;
		if(imageRatio<=tarRatio){
		
			//alert("iw:"+iw+" ih:"+ih+" Scale by width because its a wide image. ");	
			strImageHTML= '<img src="'+ imageSrc+'" width="'+tarW+'" alt="'+alt+'" >';
			if( linkSrc != '' )			// If image has a link, add it
			{
				strImageHTML = '<a href="'+linkSrc+'">' + strImageHTML + '</a>';
			}
			
		}else{
			spacer=(tarW-((tarH/ih)*iw))/2;
			//alert("iw:"+iw+" ih:"+ih+" Scale by height because its a tall image. Spacer:"+spacer);
			strImageHTML= '<img src="'+ imageSrc+'" height="'+tarH+'" alt="'+alt+'" style="margin-left: '+ spacer +'px;">';	
			if( linkSrc != '' )			// If image has a link, add it
			{
				strImageHTML = '<a href="'+linkSrc+'">' + strImageHTML + '</a>';
			}
		}
	
		xdiv=document.getElementById(tarDiv);
		xdiv.style.width = tarW+'px';	// Set width of containing div
		xdiv.style.height = tarH+'px';	// Set height of containing div
		xdiv.innerHTML=strImageHTML;
	}
}

function showHide2(dropdown)
{
	
	if(document.getElementById(dropdown).style.display == 'none')
	{
		document.getElementById(dropdown).style.display = 'block';
	}
	else if(document.getElementById(dropdown).style.display == 'block')
	{
		document.getElementById(dropdown).style.display = 'none';
	}
}

function resize(which, tarW, tarH) 
{
	//alert('function ran');
	var elem = document.getElementById(which);
	if (elem == undefined || elem == null) 
	{
		return false;
	}
	if (tarW == undefined || tarH == undefined)
	{
		tarW, tarH = 100;
	}
	
	if ( elem.width == 0 || elem.height == 0 )					// If image dimensions not available because image not available...
	{
		var xImage=new Image;									// Create new image in memory
		xImage.elem = elem;										// Create pointer to image to be resized
		xImage.tarW = tarW;										
		xImage.tarH = tarH;
		
		xImage.onload = function()								// Create callback function, runs when image in memory loads
		{
			//alert('onload callback');
			doResize( elem, this.width, this.height, tarW, tarH );				// Resize element based on in memory image dimensions
	
		}
		xImage.src=elem.src;          							// Load data from invisible image into in memory image
	}
	else
	{
		var iw = elem.width;
		var ih = elem.height;
		doResize( elem, iw, ih, tarW, tarH );
	}
}

function doResize( elem, iw, ih, tarW, tarH )
{

	//alert('doResize ran');
	var imageRatio = ih/iw;
	var tarRatio = tarH/tarW;

	if(imageRatio <= tarRatio){
		var vSpacer = (tarH-((tarW/iw)*ih));			// Determine difference between target height and resized height
		var offset = vSpacer + 'px';
		// Scale by width because it's a wide image
		elem.width = tarW;
		elem.style.visibility = 'visible';				// Image is hidden initially so we don't see the full size image. Set to visible after resizing
		elem.style.marginBottom = offset;				// Add padding to bottom to preserve original height
	}else{
		var hSpacer = (tarW-((tarH/ih)*iw))/2;			// Determine difference between target width and resized width
		var offset = hSpacer + 'px';
		// Scale by width because it's a wide image
		elem.height = tarH;
		elem.style.visibility = 'visible';				// Image is hidden initially so we don't see the full size image. Set to visible after resizing
		elem.style.marginLeft = offset;					// Center image to preserve original width
		elem.style.marginRight = offset;				// Center image to preserve original width
	}
}

function resizeCentered(which, tarW, tarH) 
{
	//alert('function ran');
	var elem = document.getElementById(which);
	if (elem == undefined || elem == null) 
	{
		return false;
	}
	if (tarW == undefined || tarH == undefined)
	{
		tarW, tarH = 100;
	}
	
	if ( elem.width == 0 || elem.height == 0 )					// If image dimensions not available because image not available...
	{
		var xImage=new Image;									// Create new image in memory
		xImage.elem = elem;										// Create pointer to image to be resized
		xImage.tarW = tarW;										
		xImage.tarH = tarH;
		
		xImage.onload = function()								// Create callback function, runs when image in memory loads
		{
			//alert('onload callback');
			doResizeCentered( elem, this.width, this.height, tarW, tarH );				// Resize element based on in memory image dimensions
	
		}
		xImage.src=elem.src;          							// Load data from invisible image into in memory image
	}
	else
	{
		var iw = elem.width;
		var ih = elem.height;
		doResizeCentered( elem, iw, ih, tarW, tarH );
	}
}

function doResizeCentered( elem, iw, ih, tarW, tarH )
{

	//alert('doResize ran');
	var imageRatio = ih/iw;
	var tarRatio = tarH/tarW;

	if(imageRatio <= tarRatio){
		var vSpacer = (tarH-((tarW/iw)*ih))/2;			// Determine difference between target height and resized height
		var offset = vSpacer + 'px';
		// Scale by width because it's a wide image
		elem.width = tarW;
		elem.style.visibility = 'visible';				// Image is hidden initially so we don't see the full size image. Set to visible after resizing
		elem.style.marginTop = offset;					// Add padding to top to preserve original height
		elem.style.marginBottom = offset;				// Add padding to bottom to preserve original height
	}else{
		var hSpacer = (tarW-((tarH/ih)*iw))/2;			// Determine difference between target width and resized width
		var offset = hSpacer + 'px';
		// Scale by width because it's a wide image
		elem.height = tarH;
		elem.style.visibility = 'visible';				// Image is hidden initially so we don't see the full size image. Set to visible after resizing
		elem.style.marginLeft = offset;					// Center image to preserve original width
		elem.style.marginRight = offset;				// Center image to preserve original width
	}
}


//resize hulu images
function resize240x180(which, tarW, tarH) 
{
	//alert('function ran');
	var elem = document.getElementById(which);
	if (elem == undefined || elem == null) 
	{
		return false;
	}
	if (tarW == undefined || tarH == undefined)
	{
		tarW, tarH = 100;
	}
	
	if ( elem.width == 0 || elem.height == 0 )					// If image dimensions not available because image not available...
	{
		var xImage=new Image;									// Create new image in memory
		xImage.elem = elem;										// Create pointer to image to be resized
		xImage.tarW = tarW;										
		xImage.tarH = tarH;
		
		xImage.onload = function()								// Create callback function, runs when image in memory loads
		{
			//alert('onload callback');
			doResize240x180( elem, this.width, this.height, tarW, tarH );				// Resize element based on in memory image dimensions
	
		}
		xImage.src=elem.src;          							// Load data from invisible image into in memory image
	}
	else
	{
		var iw = elem.width;
		var ih = elem.height;
		doResize240x180( elem, iw, ih, tarW, tarH );
	}
}

function doResize240x180( elem, iw, ih, tarW, tarH )
{
	iw = 240;
	ih = 180;
	//alert('doResize ran');
	var imageRatio = ih/iw;
	var tarRatio = tarH/tarW;

	if(imageRatio <= tarRatio){
		var vSpacer = (tarH-((tarW/iw)*ih));			// Determine difference between target height and resized height
		var offset = vSpacer + 'px';
		// Scale by width because it's a wide image
		elem.width = tarW;
		elem.style.visibility = 'visible';				// Image is hidden initially so we don't see the full size image. Set to visible after resizing
		elem.style.marginBottom = offset;				// Add padding to bottom to preserve original height
	}else{
		var hSpacer = (tarW-((tarH/ih)*iw))/2;			// Determine difference between target width and resized width
		var offset = hSpacer + 'px';
		// Scale by width because it's a wide image
		elem.height = tarH;
		elem.style.visibility = 'visible';				// Image is hidden initially so we don't see the full size image. Set to visible after resizing
		elem.style.marginLeft = offset;					// Center image to preserve original width
		elem.style.marginRight = offset;				// Center image to preserve original width
	}
}