 var ramswin

 function openwindow(url,winx,attrx) {

   if (!ramswin || ramswin.closed) {
       ramswin = open(url,winx,attrx)
   }
   else {
     ramswin.focus()
   }
 }
function wOpen(url,winx,attrx) {
	window.open(url,winx,attrx);
}

function wclose() {
	self.close();
}

function UpdateOpener() {
    opener.location.href = opener.location.href;
}

function toggleImage(oldimage,newimage,obj) {
       if (obj.images) {
        obj.images[oldimage].src = newimage;

       }
     }

function CopyInfo()
{
  var the_box = window.document.BillingForm.SameAsAdmin;
  if (the_box.checked == true) {
	 document.BillingForm.FirstName.value = "xxx";
	 document.BillingForm.LastName.value = "xcxxx";
	 document.BillingForm.Company.value = "";
	 document.BillingForm.Title.value = "";
	 document.BillingForm.Address1.value = "xxxxxx";
	 document.BillingForm.Address2.value = "";
	 document.BillingForm.City.value = "xxx";
	 document.BillingForm.State.value = "xxx";
	 document.BillingForm.Zip.value = "xxx";
	 document.BillingForm.Country.selectedIndex = "US";
	 document.BillingForm.Phone.value = "xxxxxxx";
	 document.BillingForm.Fax.value = "";
	 document.BillingForm.Email.value = "xxx@xxx.com";       
  } else {
 	 document.BillingForm.FirstName.value = "";
	 document.BillingForm.LastName.value = "";
	 document.BillingForm.Company.value = "";
	 document.BillingForm.Title.value = "";
	 document.BillingForm.Address1.value = "";
	 document.BillingForm.Address2.value = "";
	 document.BillingForm.City.value = "";
	 document.BillingForm.State.value = "";
	 document.BillingForm.Zip.value = "";
	 document.BillingForm.Country.selectedIndex = "";
	 document.BillingForm.Phone.value = "";
	 document.BillingForm.Fax.value = "";
	 document.BillingForm.Email.value = "";       
  }
}

function ReloadOpener(framename) {
	var obj1
	obj1 = eval("opener.parent." + framename +".location")
// onLoad="parent.frames.topframe.location.reload()
    obj1.reload()
}

function openWindow (source)
{
  window.open(source, "my_new_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=wid, height=hei")
}


function OpenDialog_Old(url,popup,popw,poph,t,opts) {
	var w = 480
	var h = 340
	var toppos = 0
	var leftpos = 0
	var winx = ''
	var numargs
	var winHandle

	if (opts == null) {
		winx = 'toolbar=no,location=no,history=no,resizable=no,status=no,scrollbars=no,menubar=no'
	}
	else {
		winx = opts
	}
	if (t == 1) {
		if (document.all || document.layers) {
			w = screen.availWidth
			h = screen.availHeight
		}
	}
	else {
		if (document.all) {
			w = document.body.clientWidth
			h = document.body.clientHeight
		}
		else if (document.layers) {
			w = window.innerWidth
			h = window.innerHeight
		}
	}
	
	toppos = (w - popw) / 2
	leftpos = (h - poph) / 2

	winx = winx + ',width=' + popw
	winx = winx + ',height=' + poph + ',top=' + toppos + ',left=' + leftpos
	
	winHandle = window.open(url,popup,winx);
	winHandle.focus()
}
function OpenDialog(url,popup,popw,poph,t,opts) {
	var w = 480
	var h = 340
	var toppos = 0
	var leftpos = 0
	var winx = ''
	var numargs
	//var winHandle

	if (opts == null) {
		winx = 'toolbar=no,location=no,history=no,resizable=no,status=no,scrollbars=no,menubar=no'
	}
	else {
		winx = opts
	}
	if (t == 1) {
		if (document.all || document.layers) {
			w = screen.availWidth
			h = screen.availHeight
			leftpos = ((w - popw) / 2)
			toppos = ((h - poph) / 2)
		}
	}
	else {
		if (document.all) {
			//w = document.body.clientWidth - 35
			//h = document.body.clientHeight - 35
			//w = Math.floor(screen.availWidth/3);
    		//h = Math.floor(screen.availHeight/3);
    		//leftpos = Math.floor((screen.availWidth-w)/2);
    		//toppos = Math.floor((screen.availHeight-h)/2);

			leftpos = window.screenTop+100;
			toppos = window.screenLeft+100;
	
		}
		else if (document.layers) {
			//w = window.innerWidth - 20
			//h = window.innerHeight -20
			leftpos = window.screenX + 100;
			toppos = window.screenY + 100;
	
		}
	}

	//leftpos = ((w - popw) / 2)
	//toppos = ((h - poph) / 2)

	winx = winx + ',width=' + popw
	winx = winx + ',height=' + poph + ',top=' + toppos + ',left=' + leftpos
	
	winHandle = window.open(url,popup,winx);
	if (winHandle.opener == null) winHandle.opener = self;

	winHandle.focus()
	
//	return winHandle;
}
function WhatToDo(url,popup,t,i) {

	popupctl = new Array(14)
	var wx = 400;
	var hx = 250;
	var t = 1;
	var opts;

	popupctl[0] = "Y";		// search
 	popupctl[1] = "Y";		// create folder
 	popupctl[2] = "Y";		// upload file
 	popupctl[3] = "N";		// download
 	popupctl[4] = "Y";		// revision
 	popupctl[5] = "Y";		// delete
 	popupctl[6] = "N";		// Move
	popupctl[7] = "N";		// copy
 	popupctl[8] = "N";		// lock
 	popupctl[9] = "N";		// unloock
 	popupctl[10] = "Y";		// permissions
 	popupctl[11] = "Y";		// view 
 	popupctl[12] = "Y";		// add/remove
 	popupctl[13] = "N"; 	// order prints
 
	if (popupctl[i] == "N") {
		SetFormAction(i)
	}
	else {
		switch(i) {
			case 0:
				wx = 400
				hx = 250
				break;
			case 1:
				wx = 400
				hx = 250
				break;
			case 2:
				wx = 450
				hx = 375
				opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"
				break;
			case 4:
				wx = 500
				hx = 400
				break;
			case 5:
				wx = 500
				hx = 400
				break;
			case 10:
				wx = 400
				hx = 250
				break;
			case 11:
				wx = 400
				hx = 250
				break;
			case 12:
				wx = 400
				hx = 250
				break;
			default:
				wx = 400
				hx = 250
			break;
		}
				 
		OpenDialog(url,popup,wx,hx,t,opts)
	}
	return true;
}

function SetClassFormAction(i,formname) {
	var obj1
	var opts
	var wx
	var hx
	var t

	t = 1
	wx = 450
	hx = 180
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=0"

	obj1 = eval("parent.leftframe." + formname)

	if (i == 2) {
		if (obj1.xcurid.value == 0) {
			alert("Please select a class to edit")
			return false;
		}
	}
	
	OpenDialog('','classwin',wx,hx,t,opts)

	obj1.action = "AClassProcess.asp?mode=" + i + "&src=0"
	obj1.method = "post"
	obj1.target = 'classwin'
 
	obj1.submit()


}
function SetItemFormAction(i,formname) {
	var obj1
	var opts
	var wx
	var hx
	var t

	t = 1
	wx = 550
	hx = 500
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"

	obj1 = eval("parent.mainframe." + formname)

	if (i == 2) {
		if (obj1.xcurid.value == 0) {
			alert("Please select an Item to edit")
			return false;
		}
	}
	
	OpenDialog('','classwin',wx,hx,t,opts)

	obj1.action = "AItemProcess.asp?mode=" + i
	obj1.method = "post"
	obj1.target = 'classwin'
 
	obj1.submit()


}
function SetFormAction(i,formname,framename,aspx) {
	var obj1
	var opts
	var wx
	var hx
	var t

	t = 1
	wx = 450
	hx = 180
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=0"

	obj1 = eval("parent." + framename + "." + formname)

	if (i == 2) {
		if (obj1.xcurid.value == 0) {
			alert("Please select a subcategory to edit")
			return false;
		}
	}

	//OpenDialog('','classwin',wx,hx,t,opts)

	obj1 = eval("parent." + framename + "." + formname)
	obj1.action = aspx + "?mode=" + i
	obj1.method = "post"
	obj1.target = 'mainframe'
 
	obj1.submit()
	return true;

}
function SetPlanFormAction(curval,formname,framename,aspx) {
	var obj1
	var opts
	var wx
	var hx
	var t

	t = 1
	wx = 450
	hx = 180
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=0"

	obj1 = eval("parent." + framename + "." + formname + '.' + curval)

	if (obj1.value == 0) {
		alert("Please select a plan from the list")
		return false;
	}

	//OpenDialog('','classwin',wx,hx,t,opts)

	obj1 = eval("parent." + framename + "." + formname)
	obj1.action = aspx + "?mode=" + curval
	obj1.method = "post"
	obj1.target = 'main'
 
	obj1.submit()
	return true;

}
function SetCatFormAction(i,formname) {
	var obj1
	var opts
	var wx
	var hx
	var t

	t = 1
	wx = 450
	hx = 250
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=0"
	obj1 = eval("parent.mainframe." + formname)
	obj1.action = "ACatProcess.asp?mode=" + i

	if (i == 4) {
		wx = 550
		hx = 500
		opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"
		obj1.action = "AItemProcess.asp?mode=" + i
	
	}

	OpenDialog('','classwin',wx,hx,t,opts)

	obj1.method = "post"
	obj1.target = 'classwin'
 
	obj1.submit()
	return true;

}
function ValidateClass(obj,i) {
	var obj1
	var opts
	var wx
	var hx
	var t


	if (i == 1) {
		if (obj.ClassName.value == "") {
			alert("Please enter the Class name")
			return false;
		}
	}


	t = 1
	wx = 450
	hx = 250
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"

	OpenDialog('','classxxx',wx,hx,t,opts)


	// action of 0 is class
	obj.action = "AClassUpdate.asp" + "?mode=" + i + "&action=0"
	obj.method = "post"
	obj.target = 'classxxx'

	obj.submit()

}
function ValidateCat(obj,i) {
	var obj1
	var opts
	var wx
	var hx
	var t


	if (i == 1) {
		if (obj.ClassName.value == "") {
			alert("Please enter the subcategory name")
			return false;
		}
	}


	t = 1
	wx = 450
	hx = 250
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"

	OpenDialog('','classxxx',wx,hx,t,opts)


	// action of 1 is subcategory
	obj.action = "AClassUpdate.asp" + "?mode=" + i + "&action=1"
	obj.method = "post"
	obj.target = 'classxxx'
	obj.submit()

}

function ValidateItem(obj,i) {
	var obj1
	var opts
	var wx
	var hx
	var t


	if (i == 1) {
		if (obj.ItemName.value == "") {
			alert("Please enter the Item name")
			return false;
		}
	}
	if (obj.ItemCode.value == "") {
			alert("Please enter the Item Code")
			return false;
	}

	t = 1
	wx = 450
	hx = 250
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"

	OpenDialog('','classxxx',wx,hx,t,opts)


	// action of 1 is subcategory
	obj.action = "AItemUpdate.asp" + "?mode=" + i + "&action=1"
	obj.method = "post"
	obj.target = "classxxx"
 
	obj.submit()
	return true;
}
function AddToQuote(obj) {

	var obj1
	var opts
	var wx
	var hx
	var t
	t = 1
	wx = 450
	hx = 250
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"

	//OpenDialog('','classxxx',wx,hx,t,opts)

	obj.action = "QuoteAddToBasket.asp"
	obj.method = "post"
	//obj.target = "classxxx"
	obj.submit()
}
function SearchDb(obj) {

	var obj1
	var opts
	var wx
	var hx
	var t
	t = 1
	wx = 450
	hx = 250
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"

return true

	//OpenDialog('','classxxx',wx,hx,t,opts)

	obj.action = "QuoteShowBasket.asp"
	obj.method = "post"
	obj.target = "content"

	obj.submit()


}
function SubmitDeleteQuote(obj,totitems,src) {
	
	var obj1
	var opts
	var wx
	var hx
	var t
	t = 1
	wx = 450
	hx = 250
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"

	//obj1 = eval("parent.content." + formname)
	obj.action = "QuoteDeleteFromBasket.asp?" + "totitems=" + totitems + "&src=" + src

	if (totitems == 0) {
		alert("There are no items in your Quote basket - Cannot delete")
		return false;
	}

	OpenDialog('','classxxx',wx,hx,t,opts)

	obj.method = "post"
	obj.target = "classxxx"
	obj.submit()


}
function SubmitDeleteQuote2(obj,totitems) {
	
	var obj1
	var opts
	var wx
	var hx
	var t
	t = 1
	wx = 450
	hx = 250
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"

	//obj1 = eval("parent.content." + formname)
	obj.action = "QuoteDeleteFromBasket.asp?" + "totitems=" + totitems

	if (totitems == 0) {
		alert("There are no items in your Quote basket - Cannot delete")
		return false;
	}

	//OpenDialog('','classxxx',wx,hx,t,opts)

	obj.method = "post"
	//obj.target = "classxxx"
	obj.submit()


}
function SubmitParentForm(formname,parentframe,targetframe,aspx,params) {
	var obj1
	var opts
	var wx
	var hx
	var t
	t = 1
	wx = 550
	hx = 350
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"

	OpenDialog('','classyyy',wx,hx,t,opts)

	obj1 = eval("parent." + parentframe + "." + formname)

	if (params == '') {
		obj1.action =  aspx 
	}
	else {
		obj1.action = aspx + "?" + params
	
	}

	obj1.method = "post"
	obj1.target = "classyyy"
	obj1.submit()

}
function SubmitThisForm(obj,aspx,params) {
	var opts
	var wx
	var hx
	var t
	t = 1
	wx = 550
	hx = 350
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"

	OpenDialog('','classyyy',wx,hx,t,opts)

	if (params == '') {
		obj.action =  aspx 
	}
	else {
		obj.action = aspx + "?" + params
	
	}

	obj.method = "post"
	obj.target = "classyyy"
	obj.submit()

}

function SetLogonForm(formname,framename,aspx,parms) {
	var obj1
	var opts
	var wx
	var hx
	var t

	t = 1
	wx = 450
	hx = 180
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=0"

	obj1 = eval("parent." + framename + "." + formname)

	//OpenDialog('','classwin',wx,hx,t,opts)

	//obj1 = eval("parent." + framename + "." + formname)
	obj1.action = aspx
alert(obj1.action)
	obj1.method = "post"
//	obj1.target = framename
 
	obj1.submit()
	//return true;

}
function SubmitThisPopupForm(obj,aspx,params) {
	var opts
	var wx
	var hx
	var t
	t = 1
	wx = 550
	hx = 350
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"

	OpenDialog('','classyyy',wx,hx,t,opts)

	if (params == '') {
		obj.action =  aspx 
	}
	else {
		obj.action = aspx + "?" + params
	
	}

	obj.method = "post"
	obj.target = "classyyy"
	obj.submit()

}
function SubmitThisMsgBoxForm(obj,aspx,params) {
	var opts
	var wx
	var hx
	var t
	t = 1
	wx = 550
	hx = 350
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=0"

	OpenDialog('','msgbox',wx,hx,t,opts)

	if (params == '') {
		obj.action =  aspx 
	}
	else {
		obj.action = aspx + "?" + params
	
	}

	obj.method = "post"
	obj.target = "msgbox"
	obj.submit()

}

function SubmitForm(obj,targetframe,aspx,params) {
	if (params == '') {
		obj.action =  aspx 
	}
	else {
		obj.action = aspx + "?" + params
	
	}

//alert(obj.action)
//alert(aspx)

	obj.method = "post"
	//obj.target = targetframe
	obj.submit()

}

function SubmitCustomerForm(obj,targetframe,aspx,params) {
	var obj1
	var opts
	var wx
	var hx
	var t
	t = 1
	wx = 150
	hx = 100

	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=0"

	OpenDialog('','classyyy',wx,hx,t,opts)

	if (params == '') {
		obj.action =  aspx 
	}
	else {
		obj.action = aspx + "?" + params
	
	}
	
	obj.method = "post"
	//obj.target = targetframe
	obj.target = "classyyy"
	obj.submit()

}
function SubmitQuoteCheckOut(totitems) {
	
	//var obj1
	var wx
	var hx
	var t
	t = 1
	wx = 550
	hx = 550
	opts = "menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=1"
	
	if (totitems == 0) {
		alert("There are no items in your Quote basket - Cannot checkout")
		return false;
	}

	OpenDialog('QuoteCheckoutFrame.Asp','classxxx',wx,hx,t,opts)

}

function test() {

alert("here")


}
function loadnewpage(framename,pagetoload) {
		// parent.topFrame.location.replace('toprounder.asp');
		parent.framename.location.replace(pagetoload);
}

function loadnav(frame) {

if (frame == 1)
    parent.topFrame.location.href = "agimage.htm";
else if (frame == 2)
    parent.topFrame.location.href = "mainindex.asp";
else if (frame == 3)
    parent.topFrame.location.href = "toprounder.asp";
else if (frame == 4)
    parent.topFrame.location.href = "topright.htm";
else if (frame == 5)
     parent.topFrame.location.href = "toprounder.asp";
else if (frame == 6)
    window.topFrame.location.href = "frame5.html";
else if (frame == 7)
    parent.bottomleft.location.replace("cartsummary.asp")
else if (frame == 8)
    parent.bottomleft.location.href = "dummybottomleft.htm" ;
return true;

}
function loadadminnav(framename,aspx,subcat,items) {

	var obj1
	obj1 = eval("parent." + framename + ".location")
	obj1.href = aspx + "?subcat=" + subcat + "&hasitems=" + items

return true;

}

function loaditemmenu(framename,aspx) {

	var obj1
	obj1 = eval("parent." + framename + ".location")
	obj1.href = aspx

return true;

}
function loadactions(framename,aspx,mtot) {

	var obj1
	if (mtot == "") {
		mtot = 0
	}
	obj1 = eval("parent." + framename + ".location")
	obj1.href = aspx+"?totitems=" + mtot

return true;

}
function LoadCartAction(action) {

if (action == 1)
    parent.actionframe.location.href = "lb_cartaction.asp?act="+action;
else if (action == 2)
    parent.actionframe.location.href = "lb_cartaction.asp?act="+action;
else if (action == 3)
    parent.topFrame.location.href = "toprounder.asp";
else if (action == 4)
    parent.topFrame.location.href = "topright.htm";
else if (action == 5)
     parent.topFrame.location.href = "toprounder.asp";
else if (action == 6)
    window.topFrame.location.href = "frame5.html";
else if (action == 7)
    parent.bottomleft.location.replace("cartsummary.asp")
else if (action == 8)
    parent.bottomleft.location.href = "dummybottomleft.htm" ;
return true;

}
function LoadAsp(action,frame) {
	var obj1
	obj1 = eval("parent.mainframe." + formname)
if (action == 1)
    parent.actionframe.location.href = "lb_cartaction.asp?act="+action;
else if (action == 2)
    parent.actionframe.location.href = "lb_cartaction.asp?act="+action;
else if (action == 3)
    parent.topFrame.location.href = "toprounder.asp";
else if (action == 4)
    parent.topFrame.location.href = "topright.htm";
else if (action == 5)
     parent.topFrame.location.href = "toprounder.asp";
else if (action == 6)
    window.topFrame.location.href = "frame5.html";
else if (action == 7)
    parent.bottomleft.location.replace("cartsummary.asp")
else if (action == 8)
    parent.bottomleft.location.href = "dummybottomleft.htm" ;
return true;

}
function test() {

alert("Test")

}