var changing_thumbs = new Array();
function changeThumb(index, i, num_thumbs, path)
{
	if (changing_thumbs[index])
	{
		hidden_image_id = (i + 1) % num_thumbs;
		if(i == 0)
			i++;	
		if (hidden_image_id == 0)
			hidden_image_id++;
		$(index).src = path + "_" + i + ".jpg";
		$("hidden_image").src = path + "_" + hidden_image_id + ".jpg";
		
		i = i % num_thumbs;
		i++;
		setTimeout("changeThumb('" + index + "'," + i + ", " + num_thumbs + ", '" + path + "')", 600);
	}
}

function startThumbChange(index, num_thumbs, path)
{	
	changing_thumbs[index] = true;
	
	changeThumb(index, 1, num_thumbs, path);
}

function endThumbChange(index, path)
{
	changing_thumbs[index] = false;
	document.getElementById(index).src = path;
}

function addBookmark(url, title)
{
  if (!url) url = location.href;
  if (!title) title = document.title;
 
  //Gecko
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
  //IE4+
  else if (typeof window.external == "object") window.external.AddFavorite(url, title);
  //Opera7+
  else if (window.opera && document.createElement)
  {
    var a = document.createElement('A');
    if (!a) return false; //IF Opera 6
    a.setAttribute('rel','sidebar');
    a.setAttribute('href',url);
    a.setAttribute('title',title);
    a.click();
  }
  else return false;
 
  return true;
}

function selColor(sel,selIndex,tArea){
	tArea.style.color=sel.options[selIndex].value;
}

function sendRequest() {

		new Ajax.Request("../../email_form_process.php", {
			   method: 'post',
			   postBody: "name="+$F("name")+"&email="+$F("email")+"&message="+$F("message")+"&url="+$F("url"),
			   onComplete: showResponse

		});
	}

function showResponse(req)
	{
	   $('errors').style.borderStyle= "solid";
	   
	   var res=/message was received/;
	  
	   if(req.responseText.match(res))
	   {
		$('errors').style.borderColor= "green";
		$('errors').style.color="green";
		$('errors').style.backgroundColor="#181818";
	   }else{
		$('errors').style.borderColor= "red";
		$('errors').style.color="red";
		$('errors').style.backgroundColor="#181818";
	   }
	   
	   $('errors').style.borderSize= "2px";
	   $('errors').innerHTML=  req.responseText;
	}

var ratp=new Array(0,0,0,0,0);
var rattext=new Array("Boo","Decent","Alright","Sexy","Hot!");
var ratact=1;

function ratingo(i)
{if (ratact)
 {for(j=1;j<=5;j++)
	{ if (j<=i)
		{ document.getElementById("stb"+j).src=document.getElementById("sb2o").src; }
		else
		{ document.getElementById("stb"+j).src=document.getElementById("sb0o").src; }
	}
	
	document.getElementById("ratetext").innerHTML="<span style='color:#FFFFFF'>"+rattext[i-1]+"</span>";
 }
}


function ratinga(i)
{if (ratact)
 {for(j=1;j<=5;j++)
	{ document.getElementById("stb"+j).src=document.getElementById("sb"+ratp[j-1]).src;
	}
	
	document.getElementById("ratetext").innerHTML="Rate this Video";
 }
}

var raction=new Image();

function dorating(id,i)
{if (ratact)
 {raction.src="../../rate.php?id="+id+"&rate="+i;
	
	document.getElementById("ratetext").innerHTML="Thank you!";
	ratact=0;
	document.getElementById("anzrattd").innerHTML=ratings+" ratings";
 }
}

function setSize(hig){
	document.getElementById("flvplayer").style.height=hig;
	//alert(hig);
}

function moreVideos()
{
	top.location = document.getElementById('referencedLink').value;	
}

var count = "200";
function limiter(){
	var tex = document.loginform.video_desc.value;
	var len = tex.length;
	if(len > count){
		tex = tex.substring(0,count);
		document.loginform.video_desc.value =tex;
		return false;
	}
	document.loginform.limit.value = count-len;
}