/*****************************SWF.JS************************************************/

if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
	deconcept.SWFObject = function(swf, id, w, h, ver, c){
	if (!document.createElement || !document.getElementById) { return; }
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	if(c) { this.addParam('bgcolor', c); }
}
deconcept.SWFObject.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs.push(key +"="+ variables[key]);
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { 
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '/>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX");
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		

			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(reqVer, xiInstall){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else{
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			for (var i=3; axo!=null; i++) {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				PlayerVersion = new deconcept.PlayerVersion([i,0,0]);
			}
		}catch(e){}
		if (reqVer && PlayerVersion.major > reqVer.major) return PlayerVersion; // version is ok, skip minor detection
		
		if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major >= 8 || xiInstall) {
			try{
				PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
			}catch(e){}
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = parseInt(arrVersion[0]) != null ? parseInt(arrVersion[0]) : 0;
	this.minor = parseInt(arrVersion[1]) || 0;
	this.rev = parseInt(arrVersion[2]) || 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param){
		var q = document.location.search || document.location.hash;
		if(q){
			var startIndex = q.indexOf(param +"=");
			var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
			if (q.length > 1 && startIndex > -1) {
				return q.substring(q.indexOf("=", startIndex)+1, endIndex);
			}
		}
		return "";
	}
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
	var objects = document.getElementsByTagName("OBJECT");
	for (var i=0; i < objects.length; i++) {
		for (var x in objects[i]) {
			
			if (typeof objects[i][x] == 'function') {
				
				objects[i][x] = null;
			}
		}
	}
	
}

if (typeof window.onunload == 'function') {
	var oldunload = window.onunload;
		window.onunload = function() {
		deconcept.SWFObjectUtil.cleanupSWFs();
		oldunload();
	}
} else {
	window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
}
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;
/*****************************END SWF.JS************************************************/
/*************************LOGIN.JS****************************/
function funcOpenLoginBox ( div_name, action )
{
	if ( action == 'close')
		window.parent.document.getElementById(div_name).style.display = "none";
	else if ( action == 'show')
		window.parent.document.getElementById(div_name).style.display = "block";

}
 function replace_plus(text)
	{
        return text.replace('+',' ');
	}	 
function get_cookie(Name) 
	{
		
		var search = Name+"="	
		var returnvalue = "";
		if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search)
			if (offset != -1) {
				offset += search.length
				end = document.cookie.indexOf(";", offset);
				if (end == -1) end = document.cookie.length;
				returnvalue=unescape(document.cookie.substring(offset, end));
				
					var a 	=returnvalue.length;
					for(i=0;i<a;i++)
					{
						returnvalue=replace_plus(returnvalue);
					}
			}
		}
		
		return returnvalue;
	}
function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

	function delCookie(name) {
	setcookie(name, "", time() - 3600 , "/", "ibnlive.com");
} 					


function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}


function Get_Cookie1( 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 Delete_Cookie( name, path, domain ) {
if ( Get_Cookie1( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function validate_frm_login()
{
	
	if(document.frmregistration.login.value=='')
	{
		alert('Please enter username');
		return false;
	}
	if(document.frmregistration.password.value=='')
	{
		alert('Please enter password');
		return false;
	}
}

//0-logid,1-username,2-fname,3-lname,4-email,5-country,6-newsletter,7-postcomment
function get_cookie_variable(str,pos)
{
	var arr_cookie=str.split("**");
	var name=arr_cookie[pos];
	return name;
}
/**********************END **LOGIN.JS****************************/

/*****************************TAB.JS************************************************/

function createObject()
{
	if(window.XMLHttpRequest)
	{
		var obj=new XMLHttpRequest();
	}else
	{
		var obj=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	return obj;
}

var httpobj1=createObject();

var secnames=new Array();
		secnames[3]='nation';
		secnames[7]='business';
		secnames[5]='sports';
		secnames[17]='health';
		secnames[8]='showbiz';
		secnames[19]='lifestyle';
		secnames[2]='world';
		secnames[11]='scitech';
		secnames[20]='cj_tab';
		secnames[26]='travel';
		secnames[25]='auto';

function changeTopTab(val)
{

	if(document.getElementById('toptab_'+val).innerHTML=='')
	{
	
		url="/tabtop/"+val+"/";
		httpobj1.open("get",url);
		httpobj1.onreadystatechange=handleResponseTopTab;
		httpobj1.send(null);
	}
	else
	{
		show_selected_topdiv(val);
	}	
	
}
function handleResponseTopTab(){
	var text;
	var temp;
	if(httpobj1.readyState==4)
	{
		text=httpobj1.responseText;
		temp= text.split('*****');
		var id= temp[0];
		var value=temp[1];
		document.getElementById('toptab_'+id).innerHTML = value;
		show_selected_topdiv(id);
	}		
}

function show_selected_topdiv(val)
{
			for (var i=1;i<=3;i++)
			{
				if(i==val){
					document.getElementById('toptab_'+i).style.display="block";
					document.getElementById('TopClass'+i).className="active";
					document.getElementById('TopSelectedClass'+i).className="btxt11";
				}
				else{
					document.getElementById('toptab_'+i).style.display="none";
					document.getElementById('TopClass'+i).className="";
					document.getElementById('TopSelectedClass'+i).className="gtxt11";

				}
			}
}
function changeBottomTab (val)
{
	if(document.getElementById('Bottom'+val).innerHTML=='')
	{
	url="/tabbottom/"+val+"/";
	httpobj1.open("get",url);
	httpobj1.onreadystatechange=handleResponseBottomTab;
	httpobj1.send(null);
	}
	else
	{
		show_selected_botttomdiv(val);
	}
	
}
function show_selected_botttomdiv(val)
{
		
		for( i in secnames )	 
		{
			if ( i == val )
				{
					document.getElementById('Bottom'+i).style.display = 'inline';
					document.getElementById('BottomClass'+i).className = secnames[i]+'_active';
					document.getElementById('BottomSelectedClass'+i).className="btxt11";
					
				}
				else
				{
					document.getElementById('BottomClass'+i).className = secnames[i];	
					document.getElementById('Bottom'+i).style.display = 'none';
					document.getElementById('BottomSelectedClass'+i).className="gtxt11";
				}
		}
}
function handleResponseBottomTab()
{
	var text;
	var temp;
	if(httpobj1.readyState==4)
	{
		text=httpobj1.responseText;
		temp= text.split('*****');
		var id= temp[0];
		var value=temp[1];
		document.getElementById('Bottom'+id).innerHTML = value;
		show_selected_botttomdiv(id);
		
	}
}



var loadstatustext="<img src='/pix/common/loading.gif' /> Requesting content..."
   
//// For the Login Box 
if (self.screen) {     // for NN4 and IE4
        width = screen.width
        height = screen.height
// Testing this first prevents firing the slow Java of NN4
}
else if (self.java) {   // for NN3 with enabled Java
       var jkit = java.awt.Toolkit.getDefaultToolkit();
       var scrsize = jkit.getScreenSize();       
       width = scrsize.width; 
       height = scrsize.height; 
}
else{
 width = height = '?' // N2, E3, N3 w/Java off, probably Opera and WebTV

}

if ( width <= 1024  ) width = width - 280;
if ( (width > 1024) && (width <= 1280)  ) width = width - 400;
if ( width > 1280  ) width = width - 490;
width=width-175;
var loadstatustext="<img src='/pix/common/loading.gif' /> Requesting content..."
///// End of Manipulation of Login box
function changeMustWatch( name, arg, total_arg){
	for (var i=1;i <= total_arg;i++){
		if(i == arg ){
			document.getElementById( name+i+"_0").style.display="block";
			document.getElementById( name+i+"_1").style.display="none";
		}
		else{
			document.getElementById( name+i+"_0").style.display="none";
			document.getElementById( name+i+"_1").style.display="block";
		}
	}
}

function showbuzzReviewHttpResponse() {			
  if (httpobj1.readyState == 1)  {  	
  		document.getElementById('showbuzzReviewContainer').innerHTML = loadstatustext;
  }
  if (httpobj1.readyState == 4)  {  	
	  document.getElementById('showbuzzReviewContainer').innerHTML = httpobj1.responseText;
  }
}


function changeNavigation ( arg, total_arg, tab_name )
{	
  		
		if ( tab_name == 'showbuzzReview' )	var url = "/tab/showbuzz/";
			httpobj1.open("GET", url + arg +"/" +tab_name+".html", true);
		if ( tab_name == 'showbuzzReview' )  httpobj1.onreadystatechange = showbuzzReviewHttpResponse;	 	 
	if (  tab_name == 'showbuzzReview' ) 		
		{	 
		
			 for ( var i=1; i <= total_arg ; i++ )	 {
				if ( arg == i )
					document.getElementById( tab_name +i).style.display="block";
				else
					document.getElementById( tab_name +i).style.display="none";
			}
		}
		httpobj1.send(null);
  
}


/*****************************END TAB.JS************************************************/

var http_request =createObject();
function funcLoading(parameter, url) { 
  	
		var url 	   =  url;
		var parameters =  "parameter="+parameter;
	    if (http_request.overrideMimeType) {
    		  http_request.overrideMimeType('text/xml');
    	}
	    if (!http_request) {
    	     return false;
   		 }
		http_request.open('GET', url +"?"+ parameters, true);
		http_request.send(null);
}

/************************************TOOL TIPS************************************************/


function enableTooltips(id)
{

	var links,i,h;
	if(!document.getElementById || !document.getElementsByTagName) return;
	AddCss();
	h=document.createElement("span");
	h.id="btc";
	h.setAttribute("id","btc");
	h.style.position="absolute";
	document.getElementsByTagName("body")[0].appendChild(h);
	if(id==null) links=document.getElementsByTagName("a");
	else links=document.getElementById(id).getElementsByTagName("a");
	for(i=0;i<links.length;i++)
	{
		Prepare(links[i]);
	}
}

function Prepare(el)
{
	var tooltip,t,b,s,l, img;

	t=el.getAttribute("title");
	link=el.getAttribute("link");
	width = el.getAttribute("rel");
	height =el.getAttribute("rev");


	if(t==null || t.length==0) t="link:";

	el.removeAttribute("title");

	img=el.getAttribute("name");
	var newimg = document.createElement('img');
	newimg.src = img;
	newimg.alt = t;
	newimg.width = width;
	newimg.height = height;

	if(img==null || img.length==0)
	{
		img = "";
		el.removeAttribute("name");
	}
	else
	{
		tooltip=CreateEl("span","tooltip");

		imgdisplay=CreateEl("span", "top");
		imgdisplay.appendChild(newimg);
		tooltip.appendChild(imgdisplay);

		b=CreateEl("b","bottom");
		tooltip.appendChild(b);
		setOpacity(tooltip);
		el.tooltip=tooltip;
		el.onmouseover=showTooltip;
		el.onmouseout=hideTooltip;
		el.onmousemove=Locate;
	}
}

function showTooltip(e){
document.getElementById("btc").appendChild(this.tooltip);
Locate(e);
}

function hideTooltip(e){
var d=document.getElementById("btc");
if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

function setOpacity(el){
el.style.filter="alpha(opacity:95)";
el.style.KHTMLOpacity="0.95";
el.style.MozOpacity="0.95";
el.style.opacity="0.95";
}

function CreateEl(t,c){
var x=document.createElement(t);
x.className=c;
x.style.display="block";
return(x);
}

function AddCss(){
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","/css/web2/tooltips1.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

function Locate(e){
var posx=0,posy=0;
if(e==null) e=window.event;
if(e.pageX || e.pageY){
    posx=e.pageX; posy=e.pageY;
    }
else if(e.clientX || e.clientY){
    if(document.documentElement.scrollTop){
        posx=e.clientX+document.documentElement.scrollLeft;
        posy=e.clientY+document.documentElement.scrollTop;
        }
    else{
        posx=e.clientX+document.body.scrollLeft;
        posy=e.clientY+document.body.scrollTop;
        }
    }
document.getElementById("btc").style.top=(posy+5)+"px";
document.getElementById("btc").style.left=(posx-50)+"px";
}


/********************************END TOOL TIPS**************************************************************/
