function pageLoaded(){
	document.loginForm.username.focus();
}

var num = 0;
var ZCnt = 0;
var AZone = new Array("EST","CNT","MNT","PAC")
var Zone = AZone[num];

function NumPlus(){
	if(num==-3){
	num=0;
	ZCnt=0;
	}
	else{
	num--;
	ZCnt++;
	}
	Zone = AZone[ZCnt];
}

function CheckNum(num){
	if(num<10)
	num = "0" + num;
	return num;
}

function CurTime(){
	MyDate = new Date()
	MyTime = CheckNum(((MyDate.getHours())+num)) + ":" + CheckNum(MyDate.getMinutes()) + ":" + CheckNum(MyDate.getSeconds());
	MyDay = (MyDate.getMonth() + 1) + "/" + MyDate.getDate() + "/" + MyDate.getFullYear(); 
	var str = '<font face="Verdana" size="1" color="#165193">' + MyDay + '   ' + MyTime + ' &nbsp; ' + ' </font>';
	time.innerText="";
	time.insertAdjacentHTML('AfterBegin',str);
	
	setTimeout("CurTime(num)",1000)
}
CurTime(num);

function cartSubmit(selectedtype,selecteditem)
{
  document.cart.dowhat.value = selectedtype;
  document.cart.whichitem.value = selecteditem;
  document.cart.submit() ;
}

function del_cat_confirm(id,name)
{
 var where_to= confirm("If this category still has subcategories and/or items in it and you delete it,\nall subcategories and items in it will also be deleted.\n\nAre you sure you wish to delete this category?\n\n- " + name);
 if (where_to== true)
 {
   window.location="/admin/category/del_category_db.asp?id=" + id + "&name=" + name;
 }
 else
 {
  window.location="/admin/category/del_category.asp?id=" + id;
  }
}

function del_subcat_confirm(id,name)
{
 var where_to= confirm("If this subcategory still has items in it and you delete it,\nall items in it will also be deleted.\n\nAre you sure you wish to delete this subcategory?\n\n- " + name);
 if (where_to== true)
 {
   window.location="/admin/subcategory/del_subcategory_db.asp?id=" + id + "&name=" + name;
 }
 else
 {
  window.location="/admin/subcategory/del_subcategory.asp?id=" + id;
  }
}

function del_item_confirm(id,name)
{
 var where_to= confirm("Are you sure you wish to delete this item?\n\n- " + name);
 if (where_to== true)
 {
   window.location="/admin/item/del_item_db.asp?id=" + id + "&name=" + name;
 }
 else
 {
  window.location="/admin/item/del_item.asp?id=" + id;
  }
}

function del_subitem_confirm(id)
{
 var where_to= confirm("Are you sure you wish to delete this item?");

 window.location="/admin/item/del_item_db.asp?id=" + id;
}

function del_coupon_confirm(id,name)
{
 var where_to= confirm("Are you sure you wish to delete this coupon?\n\n- " + name);
 if (where_to== true)
 {
   window.location="/admin/coupon/del_coupon_db.asp?id=" + id + "&name=" + name;
 }
 else
 {
  window.location="/admin/coupon/del_coupon.asp?id=" + id;
  }
}

function del_net30_confirm(id,name)
{
 var where_to= confirm("Are you sure you wish to delete this Net 30 code?\n\n- " + name);
 if (where_to== true)
 {
   window.location="/admin/net30/del_net30_db.asp?id=" + id + "&name=" + name;
 }
 else
 {
  window.location="/admin/net30/del_net30.asp?id=" + id;
  }
}

//Add Image Function
function add_image(lid,pid)
{
	var newName = 'add_image';
	var newUrl = '/admin/item/add_image.asp?';
	var lid = 'lid='+lid;
	var pid = '&pid='+pid;
	//var mls = '&mls=' + mls;
	//var idc = '&idc=' + idc;
	var fullUrl = newUrl + lid + pid;
	var features = 'left=150, top=150, width=400, height=200, resizable=no, menubar=no, directories=no, status=no, location=no, toolbar=no'
	window.open(fullUrl, newName, features );
}

//Update Image Function
function update_image(lid,pid){
	var newName = 'update_image';
	var newUrl = '/admin/item/update_image.asp?';
	var lid ='lid='+lid;
	var pid = '&pid='+pid;
	//var cur_image ='&curimage='+curimage;
	//var mlsstr ='&mls='+ mls; 
	//var idc = '&idc='+ idc;
	var fullUrl = newUrl + lid + pid;
	var features = 'left=150, top=150, width=400, height=200, resizable=no, menubar=no, directories=no, status=no, location=no, toolbar=no'
	window.open(fullUrl, newName, features );
}

//Delete Image Function
function delete_image(lid,pid){
	var conf = confirm("Are you sure do you want to delete this image?");
	if(conf)
	{
		var newName = 'delete_image';
		var newUrl = '/admin/item/delete_image.asp?';
		var listingid ='lid='+lid;
		var pid = '&pid='+pid;
		//var cur_image ='&curimage='+curimage;
		//var mlsstr ='&mls='+ mls; 
		//var idc = '&idc='+ idc;
		var fullUrl = newUrl + listingid + pid;
		var features = 'left=150, top=150, width=400, height=200, resizable=no, menubar=no, directories=no, status=no, location=no, toolbar=no'
		window.open(fullUrl, newName, features );
	}
}

function check() {

	var errmsg = '';
	
	if (document.getElementById('qty').value == '') {
		errmsg = errmsg + 'Please enter a quantity\n';
	}
		
	if (errmsg != '') {
		errmsg = 'There were some errors in this form:\n\n' + errmsg + '\nPlease correct these errors and\nresubmit.';
		alert(errmsg); 
	}
	
	if (errmsg == '') { 
		document.cart.submit()
	}

}