var clsColorForBorder="#CC0000";
var clsColorForMain  ="#CC0000";
function preloadImages(){
	if(document.images){
		if(!document.imageArray) document.imageArray = new Array();
			var i,j = document.imageArray.length, args = preloadImages.arguments;
			for(i=0; i<args.length; i++){
			if (args[i].indexOf("#")!=0){
				document.imageArray[j] = new Image;
				document.imageArray[j++].src = args[i];
			}
		}
	}
}
function switchImage(imgName, imgSrc){
	if (document.images){ 
		if (imgSrc != "none"){
			document.images[imgName].src = imgSrc;
		}
	}
}
function submitTo(url,formname){//for buttons submitting to different sites.
	document.forms[formname].action=url;
	document.forms[formname].submit();
}
//For count downs start
function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}
function Contar(entrada,salida,texto,caracteres) {
  var entradaObj=getObject(entrada);
  var salidaObj=getObject(salida);
  var longitud=caracteres - entradaObj.value.length;
  if(longitud <= 0) {
    longitud=0;
    texto='<span class="disable"> '+texto+' </span>';
    entradaObj.value=entradaObj.value.substr(0,caracteres);
  }
  salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
}
//For count downs end

function Navigator(url){
	if (url==null)
	{
		url=window.location.href;
	}
	if (document.all){
		window.navigate(url);
	}
	else
	{
		window.location.href=url;
	}
}
function gather(obj_name){
	if (document.all)//*ie
		return document.all[obj_name];
	else
		return document.getElementById(obj_name);
}
function switch_to_less(){
	gather("description_pane_show_less").style.display="none";
	gather("description_pane_show_more").style.display="inline";
	gather("description_pane_less").style.display="inline";
	gather("description_pane_more").style.display="none";
}
function switch_to_more(){
	gather("description_pane_show_less").style.display="inline";
	gather("description_pane_show_more").style.display="none";
	gather("description_pane_less").style.display="none";
	gather("description_pane_more").style.display="inline";
}
function SWF_just_rated_user(rating,overal_rating,total_rates){
	SWF_just_rated(rating,overal_rating,total_rates,"user");
}
function SWF_just_rated_editor(rating,overal_rating,total_rates){
	SWF_just_rated(rating,overal_rating,total_rates,"editor");
}
function SWF_just_rated(rating,overal_rating,total_rates,id_fix){
	//gather("can_rate_"+id_fix+"_span").innerHTML="your rating is "+rating;
	gather("total_rates_"+id_fix+"_span").innerHTML=total_rates+" rates";
	gather("overal_rating_"+id_fix+"_span").innerHTML="rating: "+overal_rating;
	
}
function setFocus(_window){
	if (_window == null){
		_window=window;
	}
	_window.focus();
}
var NS = (navigator.appName=="Netscape")?true:false;
function initialize(w,h) {
	iWidth = (NS)?window.innerWidth:document.body.clientWidth;
	iHeight = (NS)?window.innerHeight:document.body.clientHeight;
	iWidth = w - iWidth;
	iHeight = h - iHeight;
	window.resizeBy(iWidth, iHeight);
	self.focus();
}
function writeCookie(name, value, hours) {
    if(hours==null || hours=="")hours=24;
	var d=new Date(); 
    d.setTime(d.getTime()+(hours*60*60*1000));  
    var expires="; expires="+d.toGMTString();
    document.cookie = name+"="+value+expires+"; path=/"; 
}
function readCookie(name){
    var c=document.cookie ; 
    if (c.indexOf(name)!=-1) { 
        pos1=c.indexOf("=", c.indexOf(name))+1; 
        pos2=c.indexOf(";",pos1);  
		// If last cookie
		if(pos2==-1)    pos2=c.length;;
		data=c.substring(pos1,pos2); 
        return data;
     }
}
function mail_changes_in_friend_teller(){
	gather("your_mail").innerHTML=gather("receiver_mail").value;
}
function name_changes_in_friend_teller(){
	gather("friend_name").innerHTML=gather("sender_name").value;
}
function comment_changes_in_friend_teller(){
	gather("your_comment").innerHTML=gather("senders_comment").value;
}
function validate_tell_a_friend(){
	if(gather("sender_name").value==""){
		alert("Sender name must not be empty");
		return false;
	}
/*	if(gather("sender_mail").value==""){
		alert("Sender mail must not be empty");
		return false;
	}
	if(gather("sender_mail").value.indexOf("@")==-1){
		alert("Sender mail must include @");
		return false;
	}
	if(gather("sender_mail").value.indexOf(".")==-1){
		alert("Sender mail must include .");
		return false;
	}
	if(gather("sender_mail").value.indexOf(" ")!=-1){
		alert("Sender mail must not include spaces in it");
		return false;
	}*/
		if(gather("receiver_mail").value==""){
		alert("Receiver mail must not be empty");
		return false;
	}
	if(gather("receiver_mail").value.indexOf("@")==-1){
		alert("Receiver mail must include @");
		return false;
	}
	if(gather("receiver_mail").value.indexOf(".")==-1){
		alert("Receiver mail must include .");
		return false;
	}
	if(gather("receiver_mail").value.indexOf(" ")!=-1){
		alert("Receiver mail must not include spaces in it");
		return false;
	}
	return true;
}
function switch_to_change(){
	gather("password_not_changer").style.display="none";
	gather("password_changer").style.display="inline";
	gather("password_being_changed").value="yes";
}
function switch_to_no_change(){
	gather("password_not_changer").style.display="inline";
	gather("password_changer").style.display="none";
	gather("password_being_changed").value="no";
}
function validate_editprofile(){
		if(gather("saved_email").value==""){
		alert("Your mail must not be empty");
		return false;
	}
	if(gather("saved_email").value.indexOf("@")==-1){
		alert("Your mail must include @");
		return false;
	}
	if(gather("saved_email").value.indexOf(".")==-1){
		alert("Your mail must include .");
		return false;
	}
	if(gather("saved_email").value.indexOf(" ")!=-1){
		alert("Your mail must not include spaces in it");
		return false;
	}
	if(gather("password_being_changed").value=="yes"){
		if(gather("saved_password").value==""){
			alert("You must provide your old password to change your password.\n If you do not wish to change your password, please close this box by clicking 'cancel changing password' link.");
			return false;
		}
		if(gather("new_password").value==""){
			alert("You must pick a new password.\n If you do not wish to change your password, please close this box by clicking 'cancel changing password' link.");
			return false;
		}
		if(gather("new_password_again").value==""){
			alert("You must repeat the password you picked as your new password.\n If you do not wish to change your password, please close this box by clicking 'cancel changing password' link.");
			return false;
		}
		if(gather("new_password").value!=gather("new_password_again").value){
			alert("Passwords you picked do not match!");
			return false;
		}
		if(gather("new_password").value==gather("saved_password").value){
			alert("Password you picked is the same with your currently password. Please check your given passwords.\n If you do not wish to change your password, please close this box by clicking 'cancel changing password' link.");
			return false;
		}
	}
	return true;
}
function open_narrow_informer(){
	gather("can_narrow_big").style.display = "inline";
}
function close_narrow_informer(){
	gather("can_narrow_big").style.display = "none";
}
function mark_keyword_as_here(i){
	mark_keyword_as_buffered(i);
	obj=gather("VideoPlayerKeywordLink"+i+"");
	obj.other=gather("VideoPlayerKeywordSquaredLink"+i+"");
	obj.showing=0;
	obj.intervalId = setInterval(
		function (){
			obj.showing++;
			obj.style.display=(obj.showing % 2 == 0 )?"none":"inline";
			obj.other.style.display=(obj.showing % 2 == 0 )?"inline":"none";
			if (obj.showing==15){
				clearInterval(obj.intervalId);
			}	 
		},100);
}
function mark_keyword_as_buffered(i){
	gather("VideoPlayerKeywordText"+i+"").style.display="none"; 
	gather("VideoPlayerKeywordLink"+i+"").style.display="inline";
}
function navigate_to_keyword(i){
	var obj=(thisMovie("player"));
	obj.SetVariable("JS_TELLS","NavigateToKeyword:"+i);
}
function thisMovie(movieName) {
	if (navigator.appName.indexOf ("Microsoft") !=-1) {
		return window[movieName];
	} else {		 
		return window.document[movieName][1];
	}
}
function switchTab(tab){
	gather("tab_chat_div").style.display="none";
	gather("tab_chat_tab_act").style.display="none";
	gather("tab_chat_tab_pas").style.display="inline";
	gather("tab_chat_td").style.background=" transparent url('images/inactive_tab.gif')";
	gather("tab_comm_div").style.display="none";
	gather("tab_comm_tab_act").style.display="none";
	gather("tab_comm_tab_pas").style.display="inline";
	gather("tab_comm_td").style.background=" transparent url('images/inactive_tab.gif')";	
	gather("tab_writ_div").style.display="none";
	gather("tab_writ_tab_act").style.display="none";
	gather("tab_writ_tab_pas").style.display="inline";
	gather("tab_writ_td").style.background=" transparent url('images/inactive_tab.gif')";	
	
	gather("tab_"+tab+"_div").style.display="inline";
	gather("tab_"+tab+"_tab_act").style.display="inline";
	gather("tab_"+tab+"_tab_pas").style.display="none";
	gather("tab_"+tab+"_td").style.background=" transparent url('images/active_tab.gif')";
} 
function deleteCommentSuccessfull(id){
(gather("written_comments_"+id)).style.display="none";
	totalCommentForVideo--;
	if (totalCommentForVideo==0){
		(gather("no_comment")).style.display="inline";
	}
}
function writeCommentSuccessfull(){
	url =window.location.href;
	url =url.split("#")[0];
	writeCookie("session.cache_limiter", "nocache", 15/3600);
	gather("hidden_form_for_writing_comment").submit();
	//Navigator(url);
}
var window_props="width=530,height=529,status=yes,menubar=no,copyhistory=no,directories=no,location=no,toolbar=no,scrollbars=no,resizable=no";
function popup(url,name,wp){
	if (wp==null) wp=window_props;
	window.open(url,name,wp).focus();
}
function openerNavigator(url){
	if (url==null)
	{
		url=window.opener.location.href;
		url =url.split("#")[0];
	}
	if (document.all){
		window.opener.navigate(url);
	}
	else
	{
		window.opener.location.href=url;
	}
}
function prepare_preview(type,file,frame){
	var url = "thumbnailer.php?file="+file;
	url+="&frame="+frame;
	url+="&type="+type;
	gather("preview_img").src=url;
}
function insert_thumbnail(type,file,frame,videoid){
	var url = "thumbnailer.php?file="+file;
	url+="&frame="+frame;
	url+="&type="+type;
	url+="&videoid="+videoid;
	popup(url,'thumb_inserted',"width=250,height=200,status=yes,menubar=no,copyhistory=no,directories=no,location=no,toolbar=no,scrollbars=no,resizable=no");
}
function movieuploaded(){
window.opener.gather("update_from_thumb_generator").value="yes";
window.opener.gather("a").submit();
}
function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_nbGroup(event, grpName) { 
var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_preloadImages() { 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
