/* -- BEGIN ventuno JS -- */      
var ventuno_SITE_ID = "";
	ventuno_SITE_ID = "time_swampland";
var relatedKeys="";
var windowURL="";
var rvContent="";
var userHashCode="";
var showType="";
var plyCntIndex=0;

var rvDescription="<center><b>ADVERTISEMENT </b><br> Click on the thumbnail to watch the video</center>";

function replaceAll(txt, replace, with_this) {
  return txt.replace(new RegExp(replace, 'g'),with_this);
}

ventuno = {}
ventuno.Browser = new function() {
	var ua, s, i;

	this.isIE    = false;
	this.isNS    = false;
	this.version = null;

	ua = navigator.userAgent;

	s = "MSIE";
	if ((i = ua.indexOf(s)) >= 0) {
	  this.isIE = true;
	  this.version = parseFloat(ua.substr(i + s.length));
	  return;
	}

	s = "Netscape6/";
	if ((i = ua.indexOf(s)) >= 0) {
	  this.isNS = true;
	  this.version = parseFloat(ua.substr(i + s.length));
	  return;
	}

	// Treat any other "Gecko" browser as NS 6.1.

	s = "Gecko";
	if ((i = ua.indexOf(s)) >= 0) {
	  this.isNS = true;
	  this.version = 6.1;
	  return;
	}	
}
ventuno.Tracker = new function() {
    this.track = function ( ele, site, area ) {
    	    if( !ele.href ) return;    	    
    }
}



ventuno.Inline = new function() {

    var content;

    this.processContent = function (content) {
        if( !content || !content.content || content.content=="") return;
        // append content and omniture frame
        // ********************************
        document.getElementById(content.location).innerHTML = content.content;
        
           }

    this.search = function(posStr, local, auxVars) {
             
        
    }
    
    function zoomToFull() {
        //alert("zoomToFull");
        Animator.add( {
            process: function() {
                if( sideBar.clientHeight >= sideBar.scrollHeight-20) {
                    sideBar.style.height = sideBar.scrollHeight+'px';
                    return false;
                }
                sideBar.style.height = (sideBar.clientHeight + 15) +'px';
                return true;
            }
        });
    }
}


ventuno.Widget = new function() {


		var SKELETON_MARKUP = '<div class="widgetWrapper"> <div id="ventuno_widget_roundtop" class="roundTop"></div> <div id="widget"> <div id="ventuno_widget_header" class="headerBar"><h1>Related Videos</h1> <div onclick="ventuno.Widget.close()" class="closeBtn" title="Close"></div> </div> <div id="ventuno_widget_loading" class="loadingArea"> <div><img src="http://ventuno.in/mrss/widget/images/spinner.gif" alt="loading" />Getting related videos</div> </div> <div id="ventuno_widget_content" class="ventunoMainContentArea"></div> <div class="footerBar"><a target="_blank" href="http://www.ventuno.in" class="getThis">Get this Widget for Your Site &raquo;</a><font style="padding-left:270px">&nbsp;</font> <a class="footerBarventunoLogo" href="http://www.ventuno.in" target="new"><img id=\'ventunoAolLogo\' height=17px src=\'http://ventuno.in/mrss/widget/images/logo_ven.png\'></a> &nbsp;&nbsp;&nbsp;</div> </div> <div id="roundBot"></div> </div>';

        var widget; var widgetContent; var widgetLoading;
        var content;
		var dragObj = {};
               if(document.getElementsByTagName('base').length>0)  { 
                if (window.addEventListener){
                  window.addEventListener('load', appendStylesheet, false); 
                } else if (window.attachEvent){
                  window.attachEvent('onload', appendStylesheet);
                }  
               } else {
                appendStylesheet();
            }
                
            
        if (Math.random() <= 0.1) {
                     }
        
    	this.search = function(source,hash,type,pIndex) {
    	showType=type;	
		relatedkeys=source;
		plyCntIndex=pIndex;
		windowURL=window.location+"";
		//windowURL="http://expressbuzz.com/edition/story.aspx?Title=Jaipur+IOC+fire+pushes+migratory+birds+to+UP&artid=kAPQYuZVZkU=&SectionID=b7ziAYMenjw=&MainSectionID=b7ziAYMenjw=&SectionName=pWehHe7IsSU=&SEO=Jaipur,%20IOC%20fire%20,%20migratory%20birds,%20UP,%20Bharatpur";
		//alert(windowURL);		
		// windowURL="http://mathrubhumi.org/news.php?id=17685&cat=1&sub=15&subit=0";
		
		aPosition=windowURL.indexOf("&");
		if(aPosition!=-1) {
			windowURL = replaceAll(windowURL, "&", "%V");		
		}
		
		aPosition=windowURL.indexOf("+");
		while(aPosition!=-1) {
			windowURL = windowURL.replace("+", "%W");		
			aPosition=windowURL.indexOf("+");
		}		

		//alert(windowURL);		
		
		userHashCode=hash;
        if( !content || (source && content.source!=source ) ) {
            requestContent( source );
			dragObj.elNode = null;
            if( widget ){ widget.parentNode.removeChild(widget); content=null; widget=null; }
        }
        if( !widget ) draw();
        show();
    
    
        return false;
    }
    
    this.close = function() {
        if( widget ) widget.style.display ='none';
    }

    this.processContent = function (incomingContent) {
        content = incomingContent;
        for(i=0;i<1000;i++){ test='444'};
        if( !widgetContent ) return;
        widgetContent.innerHTML = content.content;
        widgetContent.style.height = widgetLoading.clientHeight +'px';
        widgetLoading.style.display = 'none';
        widgetContent.style.display = 'block';
                    zoomToFull();
                
              
    }

      function requestContent( local ) {
            ventuno.Widget.script = document.createElement('script');
			CONTENT_URL="http://ventuno.in/mrss/relatedVideo.php?key="+relatedkeys+"&location="+windowURL+"&hashcode="+userHashCode+"&type="+showType+"&pindex="+plyCntIndex;
			//alert(CONTENT_URL);
			ventuno.Widget.script.src = CONTENT_URL 
            setTimeout(function(){  document.body.appendChild(ventuno.Widget.script);}, 1);
        }
        
    function zoomToFull() {
        Animator.add( {
            process: function() {
                if( widgetContent.clientHeight >= widgetContent.scrollHeight-20) {
                    widgetContent.style.height = widgetContent.scrollHeight+'px';
                    if( iecheck() ) { 
                      ieahack(widget.getElementsByTagName("a"));
                      document.getElementById("ventunoiframeblock").style.height = (Number(widget.scrollHeight)-24)+'px';
                      document.getElementById("ventunoiframeblock").style.display = 'block';
                      alphaBackgrounds();   
                    } 
                    center();
                    return false;
                }
                widgetContent.style.height = (widgetContent.clientHeight + 20) +'px';
                center();
                return true;
            }
        });
    }
    
    function ieahack( col ) {
        for( var i=0; i<col.length; i++) {
            col[i].style.position = "relative";
        }
    }

    function center() {
        if( !widget || (iecheck((document.compatMode=='BackCompat')?true:false)) ) return;
		if( dragObj.elNode != undefined) return;
        windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
        windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;       
        widget.style.left = (windowWidth/2 - widget.scrollWidth/2) +'px';
        widget.style.top = (windowHeight/2 - widget.scrollHeight/2) +'px';
    }

    function show() {
        if( widget ) widget.style.display ='block';
        if( widget ) widget.style.visibility ='visible';
    }
        
    function draw() {
        
        if( SKELETON_MARKUP ) {
            widget = document.createElement( "div" );
            widget.id = "ventuno_widget";
                widget.style.position = (iecheck((document.compatMode=='BackCompat')?true:false))?'absolute':'fixed';     
            widget.innerHTML = SKELETON_MARKUP;
            document.body.appendChild( widget );
            alphaBackgrounds();
            center();
            window.onresize = center;
        }

        widgetContent = document.getElementById('ventuno_widget_content');
        widgetLoading = document.getElementById('ventuno_widget_loading');
		widgetHeader  = document.getElementById('ventuno_widget_header');
		
	    if (ventuno.Browser.isIE) {
			widgetHeader.attachEvent("onmousedown", dragStart);
		}
		if (ventuno.Browser.isNS) {
			widgetHeader.addEventListener("mousedown", dragStart, true);
		}

        if( content ) ventuno.Widget.processContent( content );
    }

	function dragStart(event, id) {
		dragObj = {};
		
	    dragObj.elNode = widget;

		if (ventuno.Browser.isIE) {
		  x = window.event.clientX + document.documentElement.scrollLeft
		    + document.body.scrollLeft;
		  y = window.event.clientY + document.documentElement.scrollTop
		    + document.body.scrollTop;
		}
	 	if (ventuno.Browser.isNS) {
		   x = event.clientX + window.scrollX;
		   y = event.clientY + window.scrollY;
		}


	    dragObj.cursorStartX = x;
	    dragObj.cursorStartY = y;
	    dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
	    dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

	    if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
	    if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;          

		if (ventuno.Browser.isIE) {
			document.attachEvent("onmousemove", dragGo);
			document.attachEvent("onmouseup",   dragStop);
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
		if (ventuno.Browser.isNS) {
			document.addEventListener("mousemove", dragGo,   true);
			document.addEventListener("mouseup",   dragStop, true);
			event.preventDefault();
		}

	}
	function dragGo(event) {
		var x, y;
		if (ventuno.Browser.isIE) {
		  x = window.event.clientX + document.documentElement.scrollLeft
		    + document.body.scrollLeft;
		  y = window.event.clientY + document.documentElement.scrollTop
		    + document.body.scrollTop;
		}
		if (ventuno.Browser.isNS) {
		  x = event.clientX + window.scrollX;
		  y = event.clientY + window.scrollY;
		}
	
	    dragObj.elNode.style.left =
	        (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
	    dragObj.elNode.style.top  =
	        (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

		if (ventuno.Browser.isIE) {
		  window.event.cancelBubble = true;
		  window.event.returnValue = false;
		}
		if (ventuno.Browser.isNS)
		  event.preventDefault();
	}
	function dragStop(event) {
		if (ventuno.Browser.isIE) {
		  document.detachEvent("onmousemove", dragGo);
		  document.detachEvent("onmouseup",   dragStop);
		}
		if (ventuno.Browser.isNS) {
		  document.removeEventListener("mousemove", dragGo,   true);
		  document.removeEventListener("mouseup",   dragStop, true);
		}
	}

        
    function appendStylesheet() {
        var stylesheet = document.createElement("link");
        stylesheet.rel = "stylesheet";
        stylesheet.type = "text/css";
        stylesheet.href = "http://ventuno.in/mrss/widget/images/style.css?v=0.03";        
 //       stylesheet.href = "http://localhost/widget/images/style.css";        

        stylesheet.media = "all";
        document.lastChild.firstChild.appendChild(stylesheet);
    }
        function appendGlamThemeStylesheet(){
    }
} 

Animator = new function() {
    var interval;
    var effects = [];
    
    this.add = function( effect ) {
        effects.push( effect );
        if( !interval ) start();
    }
    
    function remove() {
        effect = effects.pop();
        if( effect.after_process ) effect.after_process();
        if( effects.length==0 ) stop();
    }
            
    function start() {
        interval = setInterval(heartbeat, 1);
        //alert("Start Animator "+typeof(interval));
    }
    function stop() {
        //alert("stop animator");
        clearInterval( interval );
        interval = null;
    }
    
    function heartbeat() {
        if( effects.length==0 ) { stop(); return; }
        if( effects[0].process) {
            if( effects[0].process() ) effects[0].counter++;
            else remove();
        }
    }
}
function trace( val ) {
    var output = document.getElementById("output");
    if(output) output.innerHTML += (val + "<br/>");
}

function iecheck(inc_seven) {
    if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
        var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
        var iever = (inc_seven)?(rslt != null && Number(rslt[1]) >= 5.5):(rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7 );
    }
    return iever;
}
function wait(ms){ var now=new Date();var exitTime=now.getTime()+ms;while(true){now=new Date();if(now.getTime()>exitTime){return;}}}

function alphaBackgrounds() {
   //alert('alphaBackgrounds()');
   if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
        var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
        var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7 );
        for (i=0; i<document.all.length; i++){
            var bg = document.all[i].currentStyle.backgroundImage;
            if (itsAllGood && bg!='none'){
                if (bg.match(/(_Bot|_Mid|_Top|_Btn|_alpha_)\.png/i) != null){
                    var mypng = bg.substring(5,bg.length-2);
                    document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
                    document.all[i].style.backgroundImage = "none";
                }
            }
        }
    }   
}

function ventunoOmniture(){

}

function _initventunoOm(){
 
}


function _initventunoOmPopup(){
}

function _clickventunoOm(lnk,quad,context){
}

function _trackventunoOm(quad,context){
}

function _trackAOLPopup(quad, context){
}

function  _trackAolOm(lnk,lnkType,lnkName,lnkPos){
}

function _initAolOm(){
}
ventunoOmniture.prototype.init          = _initventunoOm;
ventunoOmniture.prototype.popup         = _initventunoOmPopup;
ventunoOmniture.prototype.initaol       = _initAolOm;
ventunoOmniture.prototype.track         = _trackventunoOm;
ventunoOmniture.prototype.click         = _clickventunoOm;
ventunoOmniture.prototype.trackaol      = _trackAolOm;
ventunoOmniture.prototype.trackAOLPopup = _trackAOLPopup;

function getventunoRemoteFrame(){
}
function loadGadgetView(permlnk){
	if(ventuno.Inline){
		ventuno.Inline.search("ventunoInline", permlnk);
	} else {
	}
}

function changeSrc(url,id,cnt,pstatus) {
	if(document.getElementById('advtcnt')) {
		advtId=document.getElementById('advtcnt');
		if(advtId!=null) {			
			advtId.style.display="none";
		}
	}
	playerId=document.getElementById('ventunoplayer');
	playerId.style.display="block";

	// playerId.src=str;
	//zomJsFile="flashvars=\"embedCode=$embedSrc&embedType=noscriptObjectTagMRSS&width=325&height=300";	
	if(pstatus==0) { //Ventuno Player
		if(id!=138)
		playerId.innerHTML='<embed  src="'+url+'" allowfullscreen="true"  width="325" height="300" />';
		else {
		furl="http://www.ooyala.com/player.swf?version=2&embedCode="+url;
		playerId.innerHTML='<embed  src="'+furl+'" allowfullscreen="true" quality="high" bgcolor="#000000" width="325" height="300" name="ooyalaPlayer_bmhjds_kkhvho" align="middle" play="true" loop="false" quality="high" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash"   flashvars="embedCode='+url+'\&embedType=noscriptObjectTagMRSS\&width=325\&height=300" width="325" height="300" pluginspage="http://www.adobe.com/go/getflashplayer" />';
		//alert(playerId.innerHTML);
		}
	}else { // Other Players....
		plyCnt=document.getElementById('plytxtCnt'+cnt);
		plyCnt.style.display="block";
		playerId.innerHTML=plyCnt.value;
		//alert(plyCnt.value);
		//alert(playerId.innerHTML);
		plyCnt.style.display="none";
	}
	
	
	defaultDescription();
}
function changeTitle(title) {
videoId=document.getElementById('videoTitle');
videoId.innerHTML=title;
}

function defaultDesc() {
	videoId=document.getElementById('videoTitle');
	videoId.innerHTML=rvDescription;
}

function defaultDescription() {
	videoId=document.getElementById('videoTitle');	
	rvDescription=videoId.innerHTML;
}