////
// read cookie
function getCookie (name) {
	var dcookie = document.cookie; 
	var cname = name + "=";
	var clen = dcookie.length;
	var cbegin = 0;

	while (cbegin < clen) {
		var vbegin = cbegin + cname.length;
		if (dcookie.substring(cbegin, vbegin) == cname) { 
			var vend = dcookie.indexOf (";", vbegin);
			if (vend == -1) vend = clen;
				return unescape(dcookie.substring(vbegin, vend));
		}
		cbegin = dcookie.indexOf(" ", cbegin) + 1;
		if (cbegin == 0) break;
		}
	return null;
}
////
// set cookie
function setCookie (name, value, expires) {
  if (!expires) expires = new Date();
    document.cookie = name + "=" + escape (value) +
    "; expires=Monday, 01-Dec-2010 05:00:00 GMT "; 
} 

////
// get cookie first values
function initializeCookies () {
	if (!getCookie("_balance"))
		setCookie("_balance", 200);
	if (!getCookie("_drink"))
		setCookie("_drink", "");
	if (!getCookie("_ndrinks"))
		setCookie("_ndrinks", 0);
	if (!getCookie("_tips"))
		setCookie("_tips", 0);
}
initializeCookies();

////
//
function popupStatus(){
	window.open("accountinfo.html","account","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,width=160,height=270,left=100,top=200");
}

////
//
function creditVisitor () {
	if (getCookie("_tips"))
		setCookie("_tips", eval(getCookie("_tips")) + 1);
	else
		setCookie("_tips", 1);
}
////
// get the answer
function submitLine (form) {
	setCookie ("_babe", "desiree");
	setCookie ("_pickupline", form.pickupline.options[form.pickupline.selectedIndex].value);
}
////
// 
function evaluateSituation () {
	var money = eval(getCookie("_balance"));
	var ndrinks = eval(getCookie("_ndrinks"));
	var tips = eval(getCookie("_tips"));
	
	if ((money == rich) && (ndrinks == 2) && (tips >= phd)) 
		return 4
	else
	if ((money >= paidUp) && (ndrinks == 2) && (tips >= phd))
		return 3
	else
	if ((money >= rich) && (ndrinks == 2) && (tips >= sophmore))
		return 3
	else
	if (ndrinks >= drunk)
		return 1
	else
	if ((money < paidUp) && (tips < sophmore))
		return 1
	else
	if ((money <= paidUp) && (ndrinks == 0) && (tips < sophmore))
		return 1
	else
		return 2;
}


////
//Browsercheck, and sets <div> for ie, and <layer> for ns
	var n = (document.layers) ? 1:0;
	var ie = (document.all) ? 1:0;
	var layer=(n)?'layer':'div'

/********************************************************************************
Object constructor part.
Setting the objects methods and properties
********************************************************************************/
function dragObj(obj,nest){
	nest=(!nest) ? '':'document.'+nest+'.'										
    this.css=(n) ? eval(nest+'document.'+obj):eval('document.all.'+obj+'.style')		
    this.evnt=(n)? eval(nest+'document.'+obj):eval(obj);
	this.getLeft=b_getLeft;
	this.getTop=b_getTop;
	this.moveIt=b_moveIt;
	this.name=obj				
	return this
}
function b_moveIt(x,y){
	this.css.left=x
	this.css.top=y
}
function b_getLeft(){
  	x=(n)? this.css.left:this.css.pixelLeft
	return x
}
function b_getTop(){
  	y=(n)? this.css.top:this.css.pixelTop
	return y
}
/********************************************************************************
Capturing events, when the user mouseovers a layer
the variable/property of that layer names .isOver will
be true, and that means if the user clicks
when he is on top of that layer it becomes draggable
********************************************************************************/
function dragInit(){
	if(n) document.captureEvents(Event.MOUSEMOVE | Event.MOUSEDOWN | Event.MOUSEUP)
	document.onmousedown=mdown
	document.onmouseup=mup
	document.onmousemove=mmove;
}
function mmover(num){
	if(loaded) oDrag[num].isOver=true
}
function mmout(num){
	if(loaded) oDrag[num].isOver=false
}
function mup(){
	for(var i=0; i<oDrag.length;i++){
		if(oDrag[i].isOver) {
			oDrag[i].drag=false
		}	
	}
}
function mdown(num){
	x=(n)?num.pageX:event.x
    y=(n)?num.pageY:event.y
	for(var i=0; i<oDrag.length;i++){
		if(oDrag[i].isOver) {
			oDrag[i].drag=true
			oDrag[i].clickedX=x-oDrag[i].getLeft()
			oDrag[i].clickedY=y-oDrag[i].getTop()
			cZIndex++
			oDrag[i].css.zIndex=cZIndex
		}
	}
}
function mmove(e){
	x=(n)?e.pageX:event.x
    y=(n)?e.pageY:event.y
	for(var i=0; i<oDrag.length;i++){
	if(oDrag[i].drag)
		oDrag[i].moveIt(x-oDrag[i].clickedX,y-oDrag[i].clickedY)
	}
}

/********************************************************************************
Init, here's where you set how many draggable layers you want.
Make one more "Drag[3]=new dragObj('divDrag3')" and as i did here, ++ the number
to add draggable layers. You also have to add them in the stylesheet (in the <style></style>)
To make another one that's sized 100*200 and with a background-color of red add this:
#divDrag3{position:absolute; height:100; width:200; clip:rect(0,200,100,0); background-color:red; layer-background-color:red}
Get the picture?
There's one more thing you have to do to add layers, look further down for explanation.
********************************************************************************/
var loaded; 
function init(){
	dragInit()
	oDrag=new Array()
	oDrag[0]=new dragObj('divDrag0')
	loaded=true;
}
/********************************************************************************
Set this variable to the zIndex you want it to start at, (if you have several
layers and want it to start on the top, change to somthing higher then the uppermost layer
********************************************************************************/
cZIndex=10
//Inits the page on page load

//if(n || ie) onload=init;

/*
	document.write('<'+layer+' id="divDrag0" onmouseover="mmover(0)" onmouseout="mmout(0)">');
	// content start
	var balance=200;
	balance = (eval(getCookie("_balance")))? eval(getCookie("_balance")) : balance;	
	document.write("<center>");
	document.write("<img src=\"images/acctbanner.gif\"><br>");
	document.write("<b>Your Account Balance:</b><br>");
	document.write("$" + balance);
	document.write("<br>");
	document.write("<b>Number Of Drinks You Have Ordered:</b><br>");
	document.write(eval(getCookie("_ndrinks")));
	document.write("<br>");
	document.write("<b>Number Of The Budster's Pages About Fashion And Romance You Have Read:</b><br>");
	document.write(eval(getCookie("_tips")));
	document.write("<br>");
	document.write("</center>");
	// content end
	document.write('</'+layer+'>');
*/	




