var newwindow;

function MM_preloadImages() { //v3.0
  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];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function decision(message, url){
	if(confirm(message)) 
		location.href = url;
}

function doSubmit(checkbx){
	document.myshows.submit();
}

function redirect(link)
{
	window.location.replace(link);
}


function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName);
  if (obj) {
    if (obj.value == ''){
    	obj.value = firstname.value + " " + lastname.value;
    }
  }
}

function setListingName() { //v3.0
  var obj = MM_findObj('listingname');
  if (obj) {
    if (obj.value == ''){
    	obj.value = firstname.value + " " + lastname.value;
    }
  }
}

function setEmailAddress() { //v3.0
  var obj = MM_findObj('listingemail');
  if (obj) {
    if (obj.value == ''){
    	obj.value = email.value;
    }
  }
}

function addAddress()
{
	var emailAddresses = document.getElementById('emailAddresses');
	var emailAddress = document.createElement('input');
	emailAddress.name = 'newAddEmail[]';
	emailAddress.maxlength = '64';
	emailAddress.size = '28';
	emailAddresses.appendChild(emailAddress);
	emailAddresses.appendChild(document.createElement('br'));
}

function removeAddress(n)
{
	var email = document.getElementById(n);
	email.value = '';
	email.style.display = 'none';
	
	var remlink = document.getElementById('link[' + n + ']');
	remlink.style.display = 'none';
}

function popUP(mypage, myname, w, h, scroll, titlebar) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

function ChangePic () 
{
	document.images.img_logo.src=
	document.create_player.sel_logo.options[document.create_player.sel_logo.selectedIndex].value
}

function doThumb() { //v3.0
	var i,j=0,x,a=doThumb.arguments;
	//if ( navigator.appName == "Microsoft Internet Explorer" ) {
	//alert(navigator.platform.indexOf("Win"));
	//alert(form1.length);
	
	var theForm = document.getElementById('theForm');
	alertmsg = 0;
	
	for(i=0;i<theForm.length;i++)
	{
		if (theForm[i].name == 'file[]')
		{
			if (a[4] != (i - 1))
			{
				//alert(theForm[i].value+' | '+a[2]+' | '+a[4]+' | '+i);
				if (theForm[i].value == a[2])
				{
					alertmsg = 'It appears that you have a duplicate photo selected.';
				}
			}
			//do the preview
			if(a[4] == (i - 1))
			{
				if(navigator.userAgent.indexOf("Firefox") != -1)
				{
					//currently no way to do previews in Firefox	
				}
				else
				{
					image = document['thumb' + (i - 2)];
					image.src = 'file://' + a[2];
					image.width = 80;
					image.height = 60;
				}
			}
		}
	}
	
	if (alertmsg){
		alert(alertmsg);
	}
	
}

function doPlayerThumb() { //v3.0
	var i,j=0,x,a=doPlayerThumb.arguments;
	
	var theForm = document.getElementById('create_player');
	alertmsg = 0;
	
	for(i=0;i<theForm.length;i++)
	{
		if (theForm[i].name == 'file_player_photo')
		{
			//do the preview
			if(a[4] == i)
			{
				if(navigator.userAgent.indexOf("Firefox") != -1)
				{
					//currently no way to do previews in Firefox	
				}
				else
				{
					image = document['img_create_photo'];
					image.src = 'file://' + a[2];
					image.width = 99;
					image.height = 125;
				}
			}
		}
	}
	
}

function doThumb2() { //v3.0
	var i=0,j=0,x,a=doThumb2.arguments;
	//args: 0: id, 1: '', 2: this.value, 3: 1, 4:number
	
	theForm = document.form1;
	alertmsg = 0;
	
	while (document.getElementById('file' + i++))
	{
		j = i - 1;
		//alert('file' + j);
		if (a[4] != j)
		{
			if (document.getElementById('file' + j).value == a[2]){
				alertmsg = 'It appears that you have a duplicate photo selected.';
			}
		}
	}
	
	if (alertmsg){
		alert(alertmsg);
	}
	
	if (navigator.platform.indexOf("Win") >= 0) {
         //a[2] = 'file:///' + a[2].substring(3,a[2].length);
	} else {
		a[2] = 'file://' + a[2];
	}
	
	document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function BW_centerLayers() { //v4.1.1
	if (document.layers || document.all || document.getElementById){
		var winWidth, winHeight, i, horz, vert, width, height, offsetX, offsetY, negX, negY, group, x, y, args;
		args = BW_centerLayers.arguments;
		
		onresize = BW_reload;

				
		winWidth = (document.all)?document.body.clientWidth:window.innerWidth;
		winHeight = (document.all)?document.body.clientHeight:window.innerHeight;
				
		for (i=0; i<(args.length-9); i+=10) {
			horz    = args[i+1];
			vert    = args[i+2];
			width   = parseInt(args[i+3]);
			height  = parseInt(args[i+4]);
			offsetX = parseInt(args[i+5]);
			offsetY = parseInt(args[i+6]);
			negX    = args[i+7];
			negY    = args[i+8];
		
			x = ((winWidth - width)/2) + offsetX;
			y = ((winHeight - height)/2) + offsetY;
						
			x = (negX=='false' && (x < 0))?0:x;
			y = (negY=='false' && (y < 0))?0:y;
				
			layerObj = (document.getElementById)?document.getElementById(args[i]):MM_findObj(args[i]);
			
			if (layerObj!=null) {
				layerObj = (layerObj.style)?layerObj.style:layerObj;
				layerObj.left = (horz=="true")?x:layerObj.left;
				layerObj.top = (vert=="true")?y:layerObj.top;
			}
		}
	}
}

function BW_reload() {location.reload();}
