var secs
var timerID = null
var timerRunning = false
var delay = 1000
var balance=0;
var discount=0;
var paid = 0;
var total=0;

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function verify(){
	var frm = document.forms["signup"];
	var continue_on = true;
	//var required_fields = Array("login", "first_name", "last_name", "pwd");
	for(i=0;i<frm.length;i++){
		var field_name = frm.elements[i].name;
		var field_value = frm.elements[i].value;
		if(field_value == ''){
			if(field_name == "uid"){ alert_field = "Login";}
			else if(field_name == "pwd"){ alert_field = "Password";}
			else if(field_name == "pwd2") { alert_field = "the repeated password";}
			else{ alert_field = field_name;}
			alert("All fields are required. Please fill in "+alert_field);
			frm.elements[field_name].focus();
			continue_on = false;
			return false;	
		}	
	}
	uid = frm.elements['uid'].value;
	document.frames[0].location="../includes/checkid.php?id="+uid;
	if(continue_on){
		//frm.submit();	
	}	
}

function checkVar(thevar){
	if(thevar=="available"){
		document.forms["signup"].submit();
	}
	else{
		alert("That username is already taken. Please try another");
		document.forms["signup"].elements['uid'].focus();	
	}	
}

var i = 0;
var banners_array = new Array();
banners_array[0] = "LordexFinal.swf";
banners_array[1] = "Millers.swf";

function bannerRotation(){
	var time= new Date();
	hours= time.getHours();
	mins= time.getMinutes();
	secs= time.getSeconds();
	closeTime=hours*3600+mins*60+secs;
	closeTime+=5;	// How many seconds until the next banner rotation
	Timer();
}
function Timer(){
	td_id =  document.getElementById('b_td');
	var time= new Date();
	hours= time.getHours();
	mins= time.getMinutes();
	secs= time.getSeconds();
	curTime=hours*3600+mins*60+secs
	if (curTime>=closeTime){
	if (i < banners_array.length){	// The number 2 is the amount of banners that you have above - adjust accordingly
	flash_file = banners_array[i];
		td_id.innerHTML = "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "+
										"codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" "+ 
										"width=\"469\" height=\"61\">"+ 
										"<PARAM name=\"movie\" value=\"../banners/"+flash_file+"\"> "+
										"<PARAM name=\"quality\" value=\"high\"> "+ 
										"<PARAM name=\"menu\" value=\"true\"> "+
										"<EMBED SRC=\"../banners/"+flash_file+"\" quality=\"high\" menu=\"true\" "+
										"pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"469\" height=\"61\"> "+
										"</EMBED> "+
										"</OBJECT>";								
		i++;	
	}
	else{	i = 0; }
	bannerRotation();
	}
	else{
	window.setTimeout("Timer()",1000)}
}

function updateInvoice(theName){
		theId = document.getElementById(theName);
		val = theId.value;
		if(theId.checked==true){			
			this.total+=parseFloat(val);
		}
		else{
			this.total=total-parseFloat(val);
			if(parseFloat(this.total)<0){
				this.total=0.00;	
			}
		}
		document.forms['myForm'].amount_due.value=total;
		getBalance();
}

function getBalance(){
	this.paid = document.forms['myForm'].paid.value;
	this.balance = parseFloat(document.forms['myForm'].amount_due.value)-parseFloat(this.paid);
	this.balance = this.balance - parseFloat(document.forms['myForm'].discount.value);
	document.forms['myForm'].balance.value=this.balance;
}

function revealDiv(divID){
	theDiv = document.getElementById(divID);
	if(theDiv.style.display=="block"){
		theDiv.style.display="none";
	}
	else{
		theDiv.style.display="block";	
	}
}


function login(){
	var go = confirm("You must be logged in to create an ad. Would you like to login (or register) now?");
	if(go){
		window.location.href="login.php";	
	}
	else return false;	
}

function upgrade(){
	var divID = document.getElementById('message_box');
	divID.innerHTML="<Font color=blue>Submitting Request...</FONT>";
	document.forms['payment'].submit();	
}

