
	// Show the 'view' window (or close it)

	function viewshow(fid, uri, server) {
		if (server != null && server.substr(0,4) != "http")
		{
			server = "http://" + server;
		}

		if (document.getElementById("frameid"  + fid).style.display == "none")
		{
			// Show it.
			document.getElementById("frameid"  + fid).src = uri;

			document.getElementById("frameid"  + fid).style.display = "inline";
			document.getElementById("closeid"  + fid).style.display = "inline";
			document.getElementById("openid"   + fid).style.display = "none";

		} else {

			// Roll it back up.
			document.getElementById("frameid"  + fid).style.display = "none";
			document.getElementById("closeid"  + fid).style.display = "none";
			document.getElementById("openid"   + fid).style.display = "inline";
		}
	}
	
	//Hides Loading page and displays content of page when finish loading.
	function displayPage() {
		if (document.layers){ //NS4
			document.loadingPage.visibility = 'hidden';
		}
		else { //IE4
			document.all.loadingPage.style.visibility = 'hidden';
		}
	}
	
	//Switch images
	function switchImg(img_name,img_src) {
		document[img_name].src= btnColumn[img_src].src;
	}
	
//Preload images for left column results buttons.
	//Create an Array to store btnOff Images
	var btnColumn = new Array
	btnColumn[0] = new Image
	btnColumn[1] = new Image
	btnColumn[2] = new Image
	btnColumn[3] = new Image
	btnColumn[4] = new Image
	btnColumn[5] = new Image
	btnColumn[6] = new Image
	btnColumn[7] = new Image
	
	//Sets the image source into the btnColumns
	btnColumn[0].src = "images/results/btn_coupons_off.jpg"
	btnColumn[1].src = "images/results/btn_coupons_on.jpg"
	btnColumn[2].src = "images/results/btn_reviews_off.jpg"
	btnColumn[3].src = "images/results/btn_reviews_on.jpg"
	btnColumn[4].src = "images/results/btn_forums_off.jpg"
	btnColumn[5].src = "images/results/btn_forums_on.jpg"
	btnColumn[6].src = "images/results/btn_relatedSearch_off.jpg"
	btnColumn[7].src = "images/results/btn_relatedSearch_on.jpg"



//These function is to create a pop up box to display offers for result type 3 when hovering over "See Mor Merchants".
	var prevSelection = "";
	var prevID = "";
	
	function expand(curSelection, curID)
	{
		if (prevID != "") {
			if (prevID != curID) {
				prevSelection.getElementsByTagName("div").item(0).className = "menuNormal";	
			}
		}
	 	curSelection.getElementsByTagName("div").item(0).className = "menuHover";
		prevSelection = curSelection
		prevID = curSelection.id
	 
	}
	
	function collapse()
	{	
		//Will only perform if a prevSelection was made.
		if (prevSelection != "") {
			//Will only perform if the className is menuHover
			if (prevSelection.getElementsByTagName("div").item(0).className == "menuHover") {
				prevSelection.getElementsByTagName("div").item(0).className = "menuNormal";
			}
		}
		
		
	}
	
	function expandSub(s)
	{
		//alert("test");
	  var td = s;
	  var d = td.getElementsByTagName("div").item(0);
	
	  td.className = "menuSubHover";
	  d.className = "menuSubHover";
	}
	function collapseSub(s)
	{
	  var td = s;
	  var d = td.getElementsByTagName("div").item(0);
	
	  td.className = "menuSubNormal";
	  d.className = "menuSubNormal";
	}

	function mm_expand(selection)
	{
		document.getElementById(selection).className="menuHover";
	}
	
	function mm_collapse(selection)
	{
		document.getElementById(selection).className="menuNormal";
	}

//------------------------------------------------
//For Gift Center
function changedFor(sexRoot) {
	ageRoot = eval('document.gc_info.age');
	
	//Remove all options in Subcategory 1.
	while (ageRoot.length > 1) {
		ageRoot.remove(1);
	}
	
	//Write out all the options
	selectedFor = sexRoot.options[sexRoot.selectedIndex].value
	if (selectedFor == "couple") {	
		//Setup Age for couple
		isData = new Option("13-20 years old", "13_20");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("21-30 years old", "21_30");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("31-40 years old", "31_40");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("41-50 years old", "41_50");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("50+ years old", "50+");
		ageRoot.options.add(isData, ageRoot.options.length);

	} else if (selectedFor == "unisex_baby") {	
		//Setup Age for unisex
		isData = new Option("0-6 months old", "0_6");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("6-12 months old", "6_12");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("1-3 years old", "1_3");
		ageRoot.options.add(isData, ageRoot.options.length);

	} else {
		//Setup Age for him & her
		isData = new Option("0-6 months old", "0_6");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("6-12 months old", "6_12");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("1-3 years old", "1_3");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("4-8 years old", "4_8");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("8-12 years old", "8_12");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("13-20 years old", "13_20");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("21-30 years old", "21_30");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("31-40 years old", "31_40");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("41-50 years old", "41_50");
		ageRoot.options.add(isData, ageRoot.options.length);
		isData = new Option("50+ years old", "50+");
		ageRoot.options.add(isData, ageRoot.options.length);
	}
	

}

//--------------------------------------------------------------
// For open new window in Contact Us
function openContactUs(gLoc){	
	contactpage = gLoc + "/contactinfo/contactinformation.html";
	aWindow=window.open(contactpage,"Contact", "width=450, height=487");
	aWindow.focus();
}


//This function is to change the text color when user mouse over the row <td> of merchants.
	function tdLinkOn(curID) {
		merchantTxtStyle = eval(curID + ".style");
		merchantTxtStyle.color = "#990000" ;
	}
	function tdLinkOff(curID) {
		merchantTxtStyle = eval(curID + ".style");
		merchantTxtStyle.color = "" ;

	}



//For CSS Positioning of Homepage
function h_position(section) {
	var left_start;
	var winW;
	//var winH;
	
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  //winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  //winH = document.body.offsetHeight;
	 }
	}
	left_start = (winW-800)/2;
	//Will only reposition the <div> if the window size is larger than 800
	if (left_start > 10) {		
		moveto_left = left_start;
		moveto_right = left_start + 640;
		moveto_center = left_start + 160;
		switch (section) {
			case 1: document.getElementById("page_footer").style.left = moveto_left; break;
			case 2: document.getElementById("welcome").style.left = moveto_right; break;
			case 3: document.getElementById("directory").style.left = moveto_left; break;			
			case 4: document.getElementById("featured_products").style.left = moveto_center; break;
			case 5: document.getElementById("coupons").style.left = moveto_right; break;
			case 6: document.getElementById("page_header").style.left = moveto_left; break;
			case 7: document.getElementById("page_description").style.left = moveto_left; break;
			case 8: document.getElementById("featured_products_header").style.left = moveto_center; break;
		}
	}
}

function h_position_resize() {
	var left_start;
	var winW;
	//var winH;
	
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  //winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  //winH = document.body.offsetHeight;
	 }
	}
	left_start = (winW-800)/2;
	//Will only reposition the <div> if the window size is larger than 800
	if (left_start < 10) {	
		left_start = 10;
	}
	
	moveto_left = left_start;
	moveto_right = left_start + 640;
	moveto_center = left_start + 160;
	document.getElementById("page_footer").style.left = moveto_left;
	document.getElementById("welcome").style.left = moveto_right;
	document.getElementById("directory").style.left = moveto_left;	
	document.getElementById("featured_products").style.left = moveto_center;
	document.getElementById("coupons").style.left = moveto_right;
	document.getElementById("page_header").style.left = moveto_left;
	document.getElementById("page_description").style.left = moveto_left;
		
}

//Cookie Functions
//-----------------------------------------------------------------------
function getCookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}

//name = name of cookie
//value = value of cookie
//expires = number of minutes before it expires
function setCookie( name, value, expires, path, domain, secure ) {
  var today = new Date();
  today.setTime( today.getTime() );
  if ( expires ) {
    expires = expires * 1000 * 60 * 5;
  }
  var expires_date = new Date( today.getTime() + (expires) );
  alert(expries_date);
  document.cookie = name+"="+escape( value ) +
    ( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + //expires.toGMTString()
    ( ( path ) ? ";path=" + path : "" ) +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}

function deleteCookie( name, path, domain ) {
  if ( getCookie( name ) ) document.cookie = name + "=" +
    ( ( path ) ? ";path=" + path : "") +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
//---------------------------------------------------------------------

//Javascript Load Time Tracking
//Automatically starts when page loads.
	// create a new Date object then get the current time
	var start = new Date();
	var startsec = start.getTime();
	
	// COMMENTED OUT LOOP (LCHEONG 12/20/2006)
	// run a loop counting up to 250,000
	//var num = 0;
	//for( var i = 0; i < 250000; i++ )
	//{
	//  num++;
	//}
	
	function display_load_time() {
		var stop  = new Date();
		var stopsec = stop.getTime();
		
		var loadtime = ( stopsec - startsec ) / 1000;
		 alert("Page Loaded In: " +loadtime+ " seconds");
	}


//-----------------------------------------------------------
//Find the position of elelments on the page for css positioning.
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent) 	{
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curleft += obj.x;
	}
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}

/*Position Unique Content*/
function pos_unique_content() {
	content_end = findPosY(document.uc_loc);
	//alert(content_end);
	moveto = content_end + 50;
	document.getElementById('uc_div').style.top = moveto;
}
