function ontr (tr) {
	for (var j=0;j<tr.cells.length;j++) {
		tr.cells[j].style.background="rgb(164,209,255)";
	}
}



function offtr (tr){
	for (var j=0;j<tr.cells.length;j++) {
	  	tr.cells[j].style.background="rgb(255,255,255)";
	}
}




var timeout;
function montre(id) {
  	if (timeout) clearTimeout(timeout);
  
	var d = document.getElementById(id);
	for (var j = 1; j<=10; j++) {
		if (document.getElementById('smenu'+j)) {document.getElementById('smenu'+j).style.display='none';}
	}
	if (d) {d.style.display='block';}
	
	timeout=setTimeout("montre()",2000)
}






var poptimeout, html;
var poped=false;

function popup (top,html,title) {
	var p=document.getElementById('popup');
	var w=document.getElementById('wrapper');
	var min=25;
  	var max=100;
  	var op;
  	
	if (poped) {
		op=max; poped=false;
		p.style.visibility='hidden';
		p.style.display='none';
		document.body.style.background='rgb(255,255,255)';
	}
  	else {
		op=min; poped=true;
		p.style.visibility='visible';
		p.style.display='table';
		p.style.top=top+'px';
		document.body.style.background='rgb(170,170,170)';
	}
	
	w.style.filter='alpha(opacity='+op+')';
	w.style.opacity=op/100;
	
	p.style.left='-90%';
	p.rows[1].cells[0].innerHTML=html;
	p.rows[0].cells[0].innerHTML=title;
	poptimeout=setInterval('slide(15)',10)	
}


function slide (fl) {
	var p=document.getElementById('popup');
	var l=parseInt(p.style.left);
	if (l>=fl) clearInterval(poptimeout);
	else p.style.left=(l+15)+'%';
}
	
	

function vidpop (vmx, height, id, name, thumb, upstate, state, xmlurl) {
  	if (upstate>=1) var uptext='Edit Upload Settings';
  	else var uptext='Upload Video';
  
	var html='<table cellspacing="0" style="border:0">';
	html+='<tr>';
	html+='<td style="padding: 0 10px 6px 0;border:0">';
	html+='<table cellspacing="0" cellspacing="0" class="datathumb">';
	html+='<tr>';
	html+='<td class="corner"><img src="/i/thumb_top_left.gif" /></td>';
	html+='<td class="horizontal"><img src="/i/thumb_top.gif" /></td>';
	html+='<td class="corner"><img src="/i/thumb_top_right.gif" /></td>';
	html+='</tr>';
	html+='<tr>';
	html+='<td class="vertical"><img src="/i/thumb_left.gif" /></td>';
	html+='<td class="nail"><img src="'+thumb+'" /></td>';
	html+='<td class="vertical"><img src="/i/thumb_right.gif" /></td>';
	html+='</tr>';
	html+='<tr>';
	html+='<td class="corner"><img src="/i/thumb_bottom_left.gif" /></td>';
	html+='<td class="horizontal"><img src="/i/thumb_bottom.gif" /></td>';
	html+='<td class="corner"><img src="/i/thumb_bottom_right.gif" /></td>';
	html+='</tr>';
	html+='</table>';
	html+='</td>';
	html+='<td style="border:0;padding:0"><b>'+name+'</b></td>';
	html+='</tr>';
	html+='</table>';
	html+='<table cellspacing="0" style="width:100%;border-right:0" class="data">';
	
	html+='<tr onmouseover="ontr(this)" onmouseout="offtr(this)" style="cursor:pointer" onclick="document.location.href=\'/?videdit='+id+'\'">';
	html+='<td style="border-left:0;"><img src="/i/diskette_24.gif" class="i24"/></td>';
	html+='<td style="border-left:0;">Edit Tracking URLs</td>';
	html+='</tr>';
	
	html+='<tr onmouseover="ontr(this)" onmouseout="offtr(this)" style="cursor:pointer" onclick="document.location.href=\'/?widget='+id+'\'">';
	html+='<td style="border-left:0;width:30px"><img src="/i/window_24.gif" class="i24"/></td>';
	html+='<td style="border-left:0;">Get Stats Widget</td>';
	html+='</tr>';
	
	html+='<tr onmouseover="ontr(this)" onmouseout="offtr(this)" style="cursor:pointer" onclick="document.location.href=\'/?vidover='+id+'\'">';
	html+='<td style="border-left:0;width:30px"><img src="/i/statistic_24.gif" class="i24"/></td>';
	html+='<td style="border-left:0;">View Video Stats</td>';
	html+='</tr>';
	
	html+='<tr onmouseover="ontr(this)" onmouseout="offtr(this)" style="cursor:pointer" onclick="c=confirm(\'Are you sure you want to delete this video?\'); if(c) document.location.href=\'/?viddel='+id+'\'; else void(0);">';
	html+='<td style="border-left:0;width:30px"><img src="/i/close_a_24.gif" class="i24"/></td>';
	html+='<td style="border-left:0;">Delete This Video</td>';
	html+='</tr>';

	html+='</table>';


	popup(height, html, 'Video Options');
}


	
	
	
	
function i (obj) { 
	if (document.getElementById(obj)) return document.getElementById(obj);
	else return false;
}


function go (url) {
	document.location.href = url;
}





function uploadval () {	
	if ((i('title').value.length<4) || (i('title').value.length>200)) {
		alert('You must enter a title and it must be 4-200 characters long.');
		i('title').focus();
		return false;
	}
	else if ((i('tags').value.length<4) || (i('tags').value.length>200)) {
	  	alert('You must enter at least one tag and it must be at least 4 characters long.');
		i('tags').focus();
		return false;
	}
	else if ((i('description').value.length<4) || (i('description').value.length>500)) {
		alert('You must enter a description and it must be at least 4-500 characters long.');
		i('description').focus();
		return false;
	}
	else if (i('tags').value.lastIndexOf(',')>-1) {
		alert('You must separate tags by SPACES - not commas');
		i('tags').focus();
		return false;
	}
	else if ((i('file')) && (i('file').value.length>1) && (i('tos').checked==false)) {
		alert('You must agree to the legal terms.');
		i('tos').focus();
		return false;
	}
	else {
		i('pwd').value=i('pwd2').value + i('pwd1').value;
	  	
	  	if ((i('file')) && (i('file').value.length>1)) {
	  	  	i('submit').style.display='none';
	  	  	i('submit').style.visibility='hidden';
	  		i('loading').style.display='block';
	  		i('loading').style.visibility='visible';
	  		uploadtimer();
		}
		else {
			i('submit').value='Submitting...';
	  		i('submit').disabled=true;
		}
		
		return true;
	}
}



function uploadtimer() {
	var arr=i('timer').innerHTML.split(':');
	arr[1]++;
	
	if (arr[1]==60) {
		arr[1]=0;
		arr[0]++;
	}
	
	var s = arr[1].toString();
	if (s.length<2) s='0' + arr[1].toString();
	
	
	var m = arr[0].toString();
	if (m.length<2) m='0' + arr[0].toString();
	
	
	i('timer').innerHTML=m + ':' + s;
	setTimeout("uploadtimer()", 1000);
}





function siteinfo (site, usr, pwd) {
	eval('i("'+site+'_msg").innerHTML='+site+'_enter;');
	offtr(i(site+'_tr'));
	i(site+'_usr').value=usr;
	i(site+'_pwd').value=pwd;
	i(site+'_new').value='1';
}



function sb () { 
  i('submitlogin').innerHTML='<h5>Loading your account....</h5><br/><img src="/i/loading.gif" alt="Loading" />'; 
}

