// JavaScript Document
//here you place the ids of every element you want.
var ids=new Array('desc_more','desc_less','register','login');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function get_embed(source_url) {
	en=encodeURIComponent;
	d=document;
	n = "" + (window.getSelection ? window.getSelection() : 
		d.getSelection ? d.getSelection() : 
		d.selection.createRange().text);
	b=d.body.innerHTML;
	e=b.match('&'+'lt;embed.*?&'+'gt;');
	if(!e){e=b.match(/\<embed.*?\>/i)};
	if(!e){e=b.match('&'+'lt;object.*?.object&'+'gt;')};
	if(!e){e=b.match(/\<object.*?.object\>/i)};
	if(!e){e=['']};
	x='http://www.myvidster.com/user/quickadd.php?l='+en(window.location)+'&e='+escape(e[e.length-1])+'&t='+en(d.title)+'&n='+escape(n);
	a=function(){if(!window.open(x,'','toolbar=0,status=0,resizable=1,width=910,height=560')){location.href=x+'&p=1'}};
	if(!(/Firef/.test(navigator.userAgent))){a()}else{setTimeout(a,0)};
	void(0);
}

//start js video control test

	// some variables to save
	var currentPosition;
	var currentVolume;
	var currentItem;

	// these functions are caught by the JavascriptView object of the player.
	function sendEvent(typ,prm) { thisMovie("vplayer").sendEvent(typ,prm); };
	function getUpdate(typ,pr1,pr2,pid) {
		if(typ == "time") { currentPosition = pr1; }
		else if(typ == "volume") { currentVolume = pr1; }
		else if(typ == "item") { currentItem = pr1; setTimeout("getItemData(currentItem)",100); }
		var id = document.getElementById(typ);
		id.innerHTML = typ+ ": "+Math.round(pr1);
		pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
		if(pid != "null") {
			document.getElementById("pid").innerHTML = "(received from the player with id <i>"+pid+"</i>)";
		}
	};

	// These functions are caught by the feeder object of the player.
	function loadFile(obj) { thisMovie("vplayer").loadFile(obj); };
	function addItem(obj,idx) { thisMovie("vplayer").addItem(obj,idx); }
	function removeItem(idx) { thisMovie("vplayer").removeItem(idx); }
	function getItemData(idx) {
		var obj = thisMovie("vplayer").itemData(idx);
		var nodes = "";
		for(var i in obj) { 
			nodes += "<li>"+i+": "+obj[i]+"</li>"; 
		}
		document.getElementById("data").innerHTML = nodes;
	};

	// This is a javascript handler for the player and is always needed.
	function thisMovie(movieName) {
	    if(navigator.appName.indexOf("Microsoft") != -1) {
			return window[movieName];
		} else {
			return document[movieName];
		}
	};
	
	//end js video control test


	function WindowOpenFull(url,name) {
	url += "&amp;scrheight=" + screen.availHeight;
	h = screen.availHeight;
	w = screen.availWidth;
	window.open(url,name,'resizable=0,height='+h+',width='+w+',left=0,top=0');
}

function WindowOpen(url,name,w,h) {
	t = (screen.availHeight / 2)-(h - 200);
	l = (screen.availWidth / 2)-(w - 200);
	window.open(url,name,'resizable=1,height='+h+',width='+w+',left='+l+',top='+t+'');
}

function disableButton (button) {
		if (document.all || document.getElementById)
			button.disabled = true;
		else if (button) {
			button.oldOnClick = button.onclick;
			button.onclick = null;
			button.oldValue = button.value;
			button.value = 'DISABLED';
  }
}

function video_nav(channel_id,pos,video_id,video_count) {
	x = {action:"video_nav", channel_id:""+channel_id+"", pos:""+pos+"", video_id:""+video_id+"", video_count:""+video_count+""};
	l='/processor.php';
	$("div#video_nav").load(l,x);
  }

  function video_nav_all(gallery_id,pos,video_id,video_count) {
	x = {action:"video_nav_all", gallery_id:""+gallery_id+"", pos:""+pos+"", video_id:""+video_id+"", video_count:""+video_count+""};
	l='/processor.php';
	$("div#video_nav").load(l,x);
  }
  
function rate(id,value) {
	  x = {action:"rate", id:""+id+"", value:""+value+""};
	  l='/processor.php';
	   $("div#rate").load(l,x);
  }

  function reload_video(id,type,thumbnail,size,base_link,name_attrib,flashvars) {
	  x = {action:"reload_video", id:""+id+"", type:""+type+"", size:""+size+"", thumbnail: ""+thumbnail+"", base_link: ""+base_link+"", name_attrib: ""+name_attrib+"", flashvars: ""+flashvars+""};
	  l='/processor.php';
	   $("div#video_space").load(l,x);
  }


   function display_channel(channel_id,page,thumb_num) {
	  x = {action:"display_channel", channel_id:""+channel_id+"", page:""+page+"", thumb_num:""+thumb_num+""};
	  l='/processor.php';
	   $("div#thumb_space").load(l,x);
  }

    function display_gallery(gallery_id,page,thumb_num,from) {
	  x = {action:"display_gallery", gallery_id:""+gallery_id+"", page:""+page+"", thumb_num:""+thumb_num+"", from:""+from+""};
	  l='/processor.php';
	   $("div#thumb_space").load(l,x);
  }

    function diplay_all_tags(type,id) {
	  x = {action:"diplay_all_tags", type:""+type+"", id:""+id+""};
	  z  = {action:"loading"};
	  l='/processor.php';

	  $("div#tag_space").load(l,z);
	  $("div#tag_space").load(l,x);
  }
  
  function OnChange(dropdown)
{
    var myindex  = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value
	var baseURL  = 'http://www.myvidster.com/video/'+SelValue;
    top.location.href = baseURL;
    
    return true;
}