var dom = (document.getElementById) ? true : false;  
var smooth_timeout = null;	// the timer fot the resize
var ifr = null;				// the iframe object
var timer_hide;

// clear the timer and show the div
function showSortBy(id) {
	if (timer_hide)
		clearTimeout(timer_hide);
	show(id);
	//resizeIFrameSmooth('cplv_center',226,427);
	resizeIFrame('cplv_center',226,447);
}

// set a timer to delay the hide of the div
function hideSortBy(id, delay) {
	// call the real hide function in 'delay' ms
	timer_hide = setTimeout("hideSortBySub('"+id+"')", delay);
}

// resize the iframe to a new value
function resizeIFrame(id, w, h) {
	if (dom) {
		ifr = document.getElementById(id);
		ifr.width = w;
		ifr.height = h;
	}
}

// resize the iframe to a new value
function resizeIFrameSmooth(id, w, h) {
	var old_w, old_h, tmp_w, tmp_h, step_w, step_h;
	if (dom) {
		ifr = document.getElementById(id);
		tmp_w = old_w = parseInt(ifr.width);
		tmp_h = old_h = parseInt(ifr.height);
		if ((tmp_w != w) || (tmp_h != h)) {
			// nb of pixel at a time
			step_w = 100;
			step_h = 100;
			// call a function that will do the resize and timeout
			resizeIFrameSmoothSub(old_w, old_h, w, h, step_w, step_h);
		}
	}
}

// recursive function used to resize the iframe
function resizeIFrameSmoothSub(from_w, from_h, to_w, to_h, step_w, step_h) {
	var new_w, new_h;
	if (ifr != null){
		if (from_w < to_w) {
			new_w = from_w + step_w;
		} else if (from_w > to_w) {
			new_w = from_w - step_w;
		} else {
			new_w = from_w;
		}
		if (from_h < to_h) {
			new_h = from_h + step_h;
		} else if (from_h > to_h) {
			new_h = from_h - step_h;
		} else {
			new_h = from_h;
		}
		ifr.width = new_w;
		ifr.height = new_h;
		if ((from_w != to_w) || (from_h != to_h)) {
			// if the from was > and now is < (or inverse) we gone too far...
			// divide by 2 the step
			if ( ((from_w < to_w) && (new_w > to_w)) || ((from_w > to_w) && (new_w < to_w)) ) {
				step_w = Math.floor(step_w/2);
			}
			if ( ((from_h < to_h) && (new_h > to_h)) || ((from_h > to_h) && (new_h < to_h)) ) {
				step_h = Math.floor(step_h/2);
			}
			smooth_timeout = setTimeout("resizeIFrameSmoothSub("+new_w+","+new_h+","+to_w+","+to_h+","+step_w+","+step_h+");",10);
		}
	}
}

function goFeature() {
	parent.mcb_l.location = "left.asp"
	//parent.mcb_r.location = "features.asp"
	show('dailypix');
	hide('contact_title');
	show('feature');
	hide('link_cat');
	show('bg');
	hide('bg_link');
	hide('sow_title');
	resizeIFrameSmooth('mcb_l',330,250);
	setTimeout("show('contentarea');",1500)
	//document.getElementById('content_left').contentDocument.location = "left.asp";
}

function goDaily() {
	parent.mcb_l.location = "left.asp"
	//parent.mcb_r.location = "features.asp"
	show('dailypix');
	show('feature');
	hide('close2')
	resizeIFrameSmooth('mcb_l',330,250);
	setTimeout("show('contentarea');",1500)
	//document.getElementById('content_left').contentDocument.location = "left.asp";
}

function goShare() {
	parent.mcb_l.location = "timeshare.asp"
	//parent.mcb_r.location = "features.asp"
	hide('dailypix');
	hide('feature');
	show('close2')
	resizeIFrameSmooth('mcb_l',330,358);
	setTimeout("show('contentarea');",1500)
	//document.getElementById('content_left').contentDocument.location = "left.asp";
}

function goShare_EN() {
	parent.mcb_l.location = "timeshare_en.asp"
	//parent.mcb_r.location = "features.asp"
	hide('dailypix');
	hide('feature');
	show('close2')
	resizeIFrameSmooth('mcb_l',330,358);
	setTimeout("show('contentarea');",1500)
	//document.getElementById('content_left').contentDocument.location = "left.asp";
}



function goInfo() {
	parent.mcb_l.location = "left.asp"
	show('dailypix');
	hide('contact_title');
	show('feature');
	hide('link_cat');
	show('bg');
	hide('bg_link');
	hide('sow_title');
	resizeIFrameSmooth('mcb_l',330,250);
	setTimeout("show('contentarea');",1500)
	//document.getElementById('content_left').contentDocument.location = "left.asp";
}

function goContact() {
	parent.mcb_r.location = "news.asp"
	hide('dailypix');
	hide('feature');
	hide('link_cat');
	show('contact_title');
	show('bg');
	hide('bg_link');
	hide('sow_title');
	resizeIFrameSmooth('mcb_l',330,360);
	setTimeout("show('contentarea');",1500)
	//document.getElementById('content_left').contentDocument.location = "left.asp";
}

function goLink() {
	parent.mcb_l.location.href = "links.asp"
	hide('dailypix');
	hide('contact_title');
	hide('feature');
	hide('bg');
	show('bg_link');
	show('link_cat');
	show('sow_title');
	hide('contentarea');
	hide('close2');
	resizeIFrameSmooth('mcb_l',844,395);
	//resizeIFrame('mcb_r',647,390);
	
}

function moveDiv()
{
  var the_style = getStyleObject("contentarea");
  var the_left = parseInt(the_style.left) - 155;
  var the_top = parseInt(the_style.top) + 0;
  if (document.layers)
  {
    the_style.left = the_left;
    the_style.top = the_top;
  }
  else 
  {
    the_style.left = the_left + "px";
    the_style.top = the_top + "px";  
  }
}

function moveDiv2()
{
  var the_style = getStyleObject("contentarea");
  var the_left = parseInt(the_style.left) + 335;
  var the_top = parseInt(the_style.top) - 18;
  if (document.layers)
  {
    the_style.left = the_left;
    the_style.top = the_top;
  }
  else 
  {
    the_style.left = the_left - "px";
    the_style.top = the_top + "px";  
  }
}

function getStyleObject(objectId) {

if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
	} else if (document.all && document.all(objectId)) {
	return document.all(objectId).style;
	} else if (document.layers && document.layers[objectId]) {	
	return document.layers[objectId];
	} else {
	return false;
	}
}


