var firstLoad=false;
var direction=-1;
var timeOut=null;
function getFileFromURL(){
	var file="";
	var url=window.location+"";
	if(url.indexOf("?")>=0&&url.indexOf("=")<url.length-1)
		file=url.substr(url.lastIndexOf("=")+1,url.length-1);
	if(file&&file.indexOf(".flv")<0)	
		file+=".flv"; 
	return file;	
}
 function trim(str, chars) {
		chars = chars || "\\s";
		str= str.replace(new RegExp("^[" + chars + "]+", "g"), "");
		str= str.replace(new RegExp("[" + chars + "]+$", "g"), "");
		return str
	}
function removeTrailingSpaces(arg) {
	if(!arg)
		return "";
	while(''+arg.charAt(arg.length-1)==' ') { arg=arg.substring(0,arg.length-1); }
	return(arg);
}

function createplayer(go,url, showImg,imgSrc) {
 	document.getElementById("wrapper").style.top=69+"px"; 
  	if (!url) { theFile="image/product0.gif"; }
	else { theFile=url; } 
    var theWidth=267; 
	var theHeight=218; 
    var theDisplayheight=255;
 	
 	var s = new SWFObject("http://vietsoh.com/news/flash/player.swf", "playerID", theWidth, theHeight, "7");
	
	s.addParam("allowfullscreen", "true");
	s.addVariable("usefullscreen","true");
	s.addVariable("file", encodeURIComponent(theFile));
	s.addVariable("width", theWidth);
	s.addVariable("height", theHeight);
	s.addVariable("displayheight", theDisplayheight);
	s.addVariable("overstretch", "fit");
	s.addVariable("showicons", true);
	//s.addVariable("quality", "high"); 
	s.addParam('allowscriptaccess','always'); 
	s.addParam('stretching','fill');  
	s.addVariable("shuffle","false"); 
	s.addVariable("enablejs","true"); 
	s.addVariable("javascriptid","playerID");  
	if(imgSrc) s.addVariable("image",  imgSrc);
	if (go) { s.addVariable("autostart", "true"); }
	s.write("placeholder"); 
	//alert(document.getElementById("placeholder").innerHTML);
}
 
 
 function changesrc(img,val){
				if(val==0)
					img.src=img.src.replace(".gif","-1.gif" );
				else 	
					img.src=img.src.replace("-1.gif",".gif" );
			 }
	 function getYoutubePlayer( thumb , width, height ){

      return " <object width='"+width+"' height='"+height+"'><param name='movie' value='"+thumb+"'></param><param name='allowFullScreen' value='true'></param><param name='allowScriptAccess' value='always'></param><embed src='"+thumb+"' type='application/x-shockwave-flash' allowfullscreen='true'' allowScriptAccess='always' width='"+width+"' height='"+height+"'></embed></object>";
     }
		function play(auto,file,title,img){
				createplayer(auto,file,true,img);
				if(title)
					document.getElementById('divVideoLinkTitle').innerHTML=title;
		}
		function playYoutube( file,title ){ 
					document.getElementById('divVideoLinkTitle').innerHTML=title;
					document.getElementById('placeholder').innerHTML=getYoutubePlayer(file,269,220); 
		}
		 
	    function doLoad(file,img){ 
				play(false,file,false,img);
		} 
		function do_switch_tab(tabon) {
			var tab1 = document.getElementById("tab_headline_id");
			var tab2 = document.getElementById("tab_audio_id");
			var tab3 = document.getElementById("tab_video_id");
			
			var div1 = document.getElementById("div_headline_id");
			var div2 = document.getElementById("div_audio_id");
			var div3 = document.getElementById("div_video_id");
			if(tabon=="tab_headline_id")
			{
				tab1.className = 'title tabon';
				tab2.className = 'title taboff';
				tab3.className = 'title taboff';
				div1.className= 'div_on';
				div2.className= 'div_off';
				div3.className= 'div_off';
				
			}else if(tabon=="tab_audio_id")
			{
				tab2.className = 'title tabon';
				tab1.className = 'title taboff';
				tab3.className = 'title taboff';
				div2.className= 'div_on';
				div1.className= 'div_off';
				div3.className= 'div_off';
			}else if(tabon=="tab_video_id")
			{
				tab3.className = 'title tabon';
				tab1.className = 'title taboff';
				tab2.className = 'title taboff';
				div3.className= 'div_on';
				div2.className= 'div_off';
				div1.className= 'div_off';
			}
			
			 
		}
 
   function do_switch_tab_right(tabon) {
	    	var tab1 = document.getElementById("link_focus");
			var tab2 = document.getElementById("link_audio");
			var tab3 = document.getElementById("link_video");
			var tab4 = document.getElementById("link_tophits");
			
			var div1 = document.getElementById("box_focus");
			var div2 = document.getElementById("box_audio");
			var div3 = document.getElementById("box_video");
			var div4 = document.getElementById("box_tophits");
			 
			if(tabon=="link_focus")
			{  
				tab1.className = 'active';
				tab2.className = 'inactive';
				tab3.className = 'inactive';
				tab4.className = 'inactive';
				div1.className= 'div_on';
				div2.className= 'div_off';
				div3.className= 'div_off';
				div4.className= 'div_off'; 
				
			}else if(tabon=="link_audio")
			{  
				tab2.className = 'active';
				tab1.className = 'inactive';
				tab3.className = 'inactive';
				tab4.className = 'inactive';
				div2.className= 'div_on'; 
				div1.className= 'div_off';
				div3.className= 'div_off';
				div4.className= 'div_off';
				 
				
			}else if(tabon=="link_video")
			{
				tab3.className = 'active';
				tab2.className = 'inactive';
				tab1.className = 'inactive';
				tab4.className = 'inactive';  
				div3.className= 'div_on';
				div2.className= 'div_off';
				div1.className= 'div_off';
				div4.className= 'div_off';
				
			}else if(tabon=="link_tophits")
			{
				tab4.className = 'active';
				tab2.className = 'inactive';
				tab3.className = 'inactive';
				tab1.className = 'inactive';
				div4.className= 'div_on'; 
				div2.className= 'div_off';
				div3.className= 'div_off';
				div1.className= 'div_off';
				
			}
			
			 
		}
		
    
   
 /*
* VERTICAL NEWS TICKER 1.1.1 Tadas Juozapaitis ( kasp3rito@gmail.com )
*/
/*
* vertical news ticker
* Tadas Juozapaitis ( kasp3rito@gmail.com )
* http://plugins.jquery.com/project/vTicker
*/
(function(a){a.fn.vTicker=function(b){var c={speed:700,pause:4000,showItems:3,animation:"",mousePause:true,isPaused:false,direction:"up",height:0};var b=a.extend(c,b);moveUp=function(g,d,e){if(e.isPaused){return}var f=g.children("ul");var h=f.children("li:first").clone(true);if(e.height>0){d=f.children("li:first").height()}f.animate({top:"-="+d+"px"},e.speed,function(){a(this).children("li:first").remove();a(this).css("top","0px")});if(e.animation=="fade"){f.children("li:first").fadeOut(e.speed);if(e.height==0){f.children("li:eq("+e.showItems+")").hide().fadeIn(e.speed)}}h.appendTo(f)};moveDown=function(g,d,e){if(e.isPaused){return}var f=g.children("ul");var h=f.children("li:last").clone(true);if(e.height>0){d=f.children("li:first").height()}f.css("top","-"+d+"px").prepend(h);f.animate({top:0},e.speed,function(){a(this).children("li:last").remove()});if(e.animation=="fade"){if(e.height==0){f.children("li:eq("+e.showItems+")").fadeOut(e.speed)}f.children("li:first").hide().fadeIn(e.speed)}};return this.each(function(){var f=a(this);var e=0;f.css({overflow:"hidden",position:"relative"}).children("ul").css({position:"absolute",margin:0,padding:0}).children("li").css({margin:0,padding:0});if(b.height==0){f.children("ul").children("li").each(function(){if(a(this).height()>e){e=a(this).height()}});f.children("ul").children("li").each(function(){a(this).height(e)});f.height(e*b.showItems)}else{f.height(b.height)}var d=setInterval(function(){if(b.direction=="up"){moveUp(f,e,b)}else{moveDown(f,e,b)}},b.pause);if(b.mousePause){f.bind("mouseenter",function(){b.isPaused=true}).bind("mouseleave",function(){b.isPaused=false})}})}})(jQuery);
