function gid(id)
{
	if(typeof document.getElementById(id) != 'undefined')
	{
		return document.getElementById(id);
	}
	else
	{
		return false;
	}
}
var xmlhttp;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	 xmlhttp=false
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false;
	 }
	}
	function myXMLHttpRequest() {
	  var xmlhttplocal;
	  try {
	    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	    xmlhttplocal=false;
	  }
	 }

	if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
	 try {
	  var xmlhttplocal = new XMLHttpRequest();
	 } catch (e) {
	  var xmlhttplocal=false;
	  alert('couldn\'t create xmlhttp object');
	 }
	}
	return(xmlhttplocal);
}



function trim(value){
	value = value.replace(/^\s+/,'');
	value = value.replace(/\s+$/,'');
	return value;
}

function handleResponse() {
  if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
            changeText(update[0], update[1]);
        }
		}
    }
}

function changeText( div2show, text ) {
    // Detect Browser
    var IE = (document.all) ? 1 : 0;
    var DOM = 0; 
    if (parseInt(navigator.appVersion) >=5) {DOM=1};

    // Grab the content from the requested "div" and show it in the "container"
    if (DOM) {
        var viewer = document.getElementById(div2show);
        viewer.innerHTML = text;
    }  else if(IE) {
        document.all[div2show].innerHTML = text;
    }
}

function strip(val)
{
	val = new String(val).replace(/\'/g, '`');
	return val.replace(/[^0-9A-Za-z\.,`\-\!\?\@_ ]/g, '');
}


function changeTDHeight()
{
	var mit = gid('movieInfoTable');
	var actionTD1 = gid('actionTD1');
	var actionTD2 = gid('actionTD2');
	if(mit){
		var tableHeight = (mit.offsetHeight)-20;
		if(actionTD1) actionTD1.style.height=tableHeight+'px';
		if(actionTD2) actionTD2.style.height=tableHeight+'px';
	}
}
function swapSrcnSize(o,img,c)
{
	gid("showDescScrRes").innerHTML=c;
	if(img > '') o.src='http://www.bustnow.com/images/swfscrnsize/'+img;
}
function setAdBorder(typ)
{
	var o=gid("sponsor_player_ad");
	if(typ==1)
	{
		o.style.borderBottom="0px #3f5a80 solid";
	}
	else
	{
		o.style.borderBottom="3px #3f5a80 solid";
	}
}
/*
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::    Bustnow.com Favorites JS - Copyright 2008 - Copy prohibited.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*/
function favorite2(section,id)
{
	var url = new String(location.href);
		url = url.replace(location.hostname,"");
		url = url.replace("http://","");
		url = escape(url);
	var param = 'save=1&section='+section+'&id='+id+'&url='+url;
		xmlhttp.open('post', 'http://my.bustnow.com/account/favorites.php');
		xmlhttp.onreadystatechange = handleResponseFavo;
		xmlhttp.send(null);
	//var test = new Ajax.Request('http://my.bustnow.com/account/favorites.php', {method:'post',parameters:'save=1&section='+section+'&id='+id+'&url='+url, onSuccess:function(request){successFav(request)}, onFailure:errorFav});
}

function addFavorite(section,id)
{
	var url = new String(location.href);
		url = url.replace(location.hostname,"");
		url = url.replace("http://","");
		url = escape(url);
	var param = 'save=1&section='+section+'&id='+id+'&url='+url;
		xmlhttp.open('post', 'http://my.bustnow.com/account/favorites.php');
		xmlhttp.onreadystatechange = handleResponseFavo;
		xmlhttp.send(null);
	//var test = new Ajax.Request('http://my.bustnow.com/account/favorites.php', {method:'post',parameters:'save=1&section='+section+'&id='+id+'&url='+url, onSuccess:function(request){successFav(request)}, onFailure:errorFav});
}
function createFavoDiv(section,id)
{
	if(!document.getElementById("addFavo"))
	{
		var newdiv = document.createElement('div');
		var divIdName = 'addFavo';
		newdiv.setAttribute('id',divIdName);
		newdiv.innerHTML = '<span class="headerAddFavo">My.Bustnow</span><span class="closeAddFavo">> <a href="javascript:removeFavoDiv()">Close</a> <</span>'+
							'<iframe name="iframe" src="http://my.bustnow.com/bn.favo.php?section='+section+'&id='+id+'" width="506" height="382" scrolling="auto" frameborder="0" allowtransparency="yes">';
		document.body.appendChild(newdiv);
	}
}
function removeFavoDiv()
{
	var olddiv = document.getElementById('addFavo');
	document.body.removeChild(olddiv);
}
function favorite(section,id)
{
	createFavoDiv(section,id)
	//alert("Comming soon! My.Bustnow Favorites Section.");
}

function handleResponseFavo()
{
	if(xmlhttp.readyState == 4){
		if(xmlhttp.status == 200){
			var response = xmlhttp.responseText;
			alert(response);
		}
    }else{
		errorFav();
	}
}
