function updateSpan(spanID,mediaID){
	if(mediaID == 0)
		document.getElementById(spanID).innerHTML = '';
	else
		document.getElementById(spanID).innerHTML = '<a href=index.cfm?fuseaction=main.ViewVideo&v='+mediaID+' target=_blank>View Media</a>';
}

function cPicker( windowURL, windowName, windowFeatures ) { 
	return window.open( windowURL, windowName, windowFeatures ) ; 
}

function showTR(trID){ 
  document.getElementById(trID).style.display = 'inline';
}
function hideTR(trID){ 
  document.getElementById(trID).style.display = 'none';
}

function saveList(A,B){
	B.value = "";
	for(i=0;i<=A.length-1;i++) {
		B.value = B.value + "," + A[i].value;
	}
}

function addToList(listA,listB){
	addOption_list(listA,listB);
}

function removeFromList(listA,listB){
	addOption_list(listA,listB);
}

function addOption_list(A,B)
{
	for(i=A.options.length-1;i>=0;i--) {
		if(A[i].selected){
			addOption(B, A[i].text, A[i].value);
			
			removeOption(A,i);
		}
	}
}


function addOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function removeOption(listbox,i)
{
	listbox.remove(i);
}

function showCityZip(n){ 
	var n = n.value;
	if(n != 221) {
		document.getElementById("gcity").style.display = 'inline'; 
    document.getElementById("gzip").style.display = 'none';
		document.createGroup.gzip.value = '00000';
		document.createGroup.gcity.value = '';
	} else {
		document.getElementById("gcity").style.display = 'none'; 
    document.getElementById("gzip").style.display = 'inline';
		document.createGroup.gzip.value = '';
		document.createGroup.gcity.value = '';
	} 
} 


function mark(num){
	var img;
	unmark(5);
	if(num){
		for( i = num; i > 0; i--){
			img = document.getElementById('r' + i);
			img.src = 'http://pluginroom.com/images/star_sm.gif';
		}
	}
}

function unmark(num){
	var img;
	
	if(num){
		for( i = num; i > 0; i--){
			img = document.getElementById('r' + i);
			img.src = 'http://pluginroom.com/images/star_sm_bg.gif';
		}
	}
}

function reLoadParent() {
	parent.location.reload();
}

function gotoPage(page) {
	window.location = "http://www.pluginroom.com/index.cfm?fuseaction=" + page;	
}

function cancelPage(page) {
	window.location = "http://www.pluginroom.com/index.cfm?" + page;	
}

function showPop(url,w,h)
//use: onclick="showPop('pop_titletips.asp',540,370)"
{
	var rnumber = Math.round(10000*Math.random())
	if(w < 100) w = 540;
	if(h < 100) h = 500;
	if(w == 0) w = 540;
	url = "http://www.pluginroom.com/" + url;
	newwindow=window.open(url,'popwin','width='+w+',height='+h+',left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}

function openMovie(murl)
//use: onclick="showPop('pop_titletips.asp',540,370)"
{
	//default values
	var w = 456;
	var h = 390;
	var rnumber = Math.round(10000*Math.random());
	
	url = "http://www.pluginroom.com/movie.cfm?murl=" + murl;
	newwindow=window.open(url,'video','width='+w+',height='+h+',left=0,top=0,resizable=no,scrollbars=no,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
	//return false;
}

//confirm deletion popup
function deletethis(msg,gotourl){
	var answer = confirm (msg);
	if (answer) {
		location.href = gotourl;
	} else
		return false;
		
	return;	
}

function checkUncheckAll(theElement) {
	var theForm = theElement.form, z = 0;
	for(z=0; z<theForm.length;z++){
  	if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  	theForm[z].checked = theElement.checked;
	  }
   }
}

//Form Manipulations
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength);

}

//textarea characters limiter
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}

function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename;
var rlimit;
rlimit = thelimit - theform.value.length;
var limit_text='Characters remaining: <b><span id="'+theform.toString()+'">'+rlimit+'</span></b>'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}
//end textarea limiter

//progress div
adTime=1000;  // seconds ad reminder is shown
chanceAd=1; // ad will be shown 1 in X times (put 1 for everytime)

var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var calunit=ns? "" : "px"
adCount=0;
function initAd(v){
	//check for empty file field
	if (v.value == "") { alert('File field is empty!'); return false;}

	if(!ns && !ie && !w3) return;
	if(ie)		adDiv=eval('document.all.progressDiv.style');
	else if(ns)	adDiv=eval('document.layers["progressDiv"]');
	else if(w3)	adDiv=eval('document.getElementById("progressDiv").style');
	randAd=Math.ceil(Math.random()*chanceAd);
        if (ie||w3)
        adDiv.visibility="visible";
        else
        adDiv.visibility ="show";
	if(randAd==1) showAd();

}
function showAd(){
if(adCount<adTime*10){adCount+=1;
	if (ie){documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
	documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;}	
	else if (ns){documentWidth=window.innerWidth/2+window.pageXOffset-20;
	documentHeight=window.innerHeight/2+window.pageYOffset-20;} 
	else if (w3){documentWidth=self.innerWidth/2+window.pageXOffset-20;
	documentHeight=self.innerHeight/2+window.pageYOffset-20;} 
	adDiv.left=documentWidth-200+calunit;adDiv.top =documentHeight-200+calunit;
	setTimeout("showAd()",100);}else closeAd();
}
function closeAd(){
if (ie||w3)
adDiv.display="none";
else
adDiv.visibility ="hide";
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
//end progress div