<!--

// ----------------------------------------------
// rt.js
// 
// Global Rotten Tomatoes javascript functions
//
// 02.23.06 : Created : wanshun tam
// ----------------------------------------------

function swapImg(imgName, imgSrc) {
  document.images[imgName].src = imgSrc;
}

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 ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
  var today = new Date();
  today.setTime( today.getTime() );
  if ( expires ) {
    expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );
  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";
}

function refreshPage(location, param) {
	var baseURL  = location + param;
	top.location.href = baseURL;
	
	return true;
}


/**
* Shows or hides the specified div
* @param div A string name of the div to be toggled
* @return true if it's NOW visisble, false if now invisible
*/
function toggle_display(div_name) {
    div_field = document.getElementById(div_name);
    if (div_field.style.display == "none") {
        //Show it
        div_field.style.display = "";
        return 1;
    } else {
        div_field.style.display = "none";
        return 0;
    }
}

function changeClass(id_name, class_name) {
    if (document.getElementById(id_name)) {
        div_field = document.getElementById(id_name);

        div_field.className = class_name;
        return true;
    } else {
        return false;
    }
}

function hideDiv(id_name) {
    div_field = document.getElementById(id_name);

    if (div_field) {
        if (div_field.style.display != "none") {
            div_field.style.display = "none";
            return 1;
        } else {
            return 0;
        }
    }
}

function showDiv(id_name) {
    div_field = document.getElementById(id_name);

    if (div_field) {
        if (div_field.style.display != "") {
            div_field.style.display = "";
            return 1;
        } else {
            return 0;
        }
    }
}

function changeTabs(tab_name, tab_id, max_tabs) {
	if (tab_id == 1) {
		changeClass(tab_name+'1_left', 'link_tab_left_on');
		changeClass(tab_name+'1_center','link_tab_center_on');
		changeClass(tab_name+'1_right', 'link_tab_right_on_overlap');
		
		changeClass(tab_name+'2_center','link_tab_center_off');
		changeClass(tab_name+'2_right', 'link_tab_right_off');
		
		return 1;
	} else if (tab_id == 2) {
		changeClass(tab_name+'1_left', 'link_tab_left_off');
		changeClass(tab_name+'1_center','link_tab_center_off');
		changeClass(tab_name+'1_right', 'link_tab_right_off_overlap');
		
		changeClass(tab_name+'2_center','link_tab_center_on');
		changeClass(tab_name+'2_right', 'link_tab_right_on');
		
		return 1;
	}
	
	return 0;
}

function update_statusbar(w,id_name) {
  window.status = w;
  return true; 
}

function clear_statusbar() {
  window.status = "";
}

function urlencode(string) {
    return escape(string).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F');
}

//-->
