var gbl_bearType; // used for the refresh page

function orderBear(bearType,index) // opens up a window so that the bear can be ordered and passes the type and name of the bear
{
	genBear = eval(bearType); // set the temporary generic bear type
	gbl_bearType = bearType; // set the bearType to the global temporary variable
	
	clearImg_page(); // hide all the image layers that show
	showOrderImg_page(); // show the order image page

	genBear[index].fillOrder(); // fill out the order page
	
	repositionOrderLayer(); // dynamically position the order layers
}

function fillOrder() // set up the order page for a real fur bear
{
	// get the references to the layers
	descrInfo=GetObject('orderbeardescr');
	orderInfo=GetObject('orderinfo');

	// set the title
	tempVar="<center><table border='2' class='"+css_title+"'><tr><td>Ordering Information</td></tr></table></center>";
	writeInfo(dispTtle,tempVar);

 	// change the bear image
	document.images['orderbearimg'].src = this.loadbearImg().src;

	// put in the description of the bear on the order page
	tempVar=this.spec;
	writeInfo(descrInfo,tempVar); // write the info out to the page
	
	// put in the cost of the bear
	tempVar="<center>";
	
	if(this.cost == 'Not for sale'){ // a portfolio bear
		if(bearType  == 'friendz'){ // ordering a friendz item
			tempVar+="Send me an e-mail if you are interested in a custom made item<BR><a class='smallLinks' href=\"mailto:wahmbearz@shaw.ca?subject=Interested in a custom item\">";
			tempVar+="Please send an Email</a>";
		} else {
			tempVar+="Send me an e-mail if you are interested in a custom made bear<BR><a class='smallLinks' href=\"mailto:wahmbearz@shaw.ca?subject=Interested in a custom made bear\">";
			tempVar+="Please send an Email</a>";
		}
	}

	else if(this.cost == 'HOLD'){ // the bear is spoken for and is awaiting recieving the money
		tempVar+="This bear has tentatively been sold."
	}
	
	else if(this.cost == 'SOLD'){ // this bear has been sold
		tempVar+="This bear has been sold."
	}

	else{ // show paypal icon
		tempVar+="<P class='"+css_clickinstr+"'>Cost is: $"+this.cost+".00 USD. <a class='smallLinks' href=\"mailto:wahmbearz@shaw.ca?subject=Shipping charges for "+this.name+"\">Contact me</a> for shipping charges<BR><BR>"
		tempVar+="To pay for the bear through Paypal please click the button below<BR>";
		tempVar+="<a href='javascript:doNothing()' onclick=\"window.open('https://www.paypal.com/cart/add=1&business=wahmbearz%40shaw.ca&item_name="+this.name+"&item_number=wahmbear3&amount="+this.cost+".00&return=http%3A//www.wahmbearz.com/thankyou.html&cancel_return=http%3A//www.wahmbearz.com','cartwin','width=600,height=400,scrollbars,location,resizable,status')\"><img src='images/sc-but-01.gif' border='0'></a>";
		tempVar+="<BR>Alternate purchase options are available<BR><a class='smallLinks' href=\"mailto:wahmbearz@shaw.ca?subject=Alternate purchase options for "+this.name+"\">Please send me an Email</a></P></center>";
	}

		
	tempVar+="</center>";
	writeInfo(orderInfo,tempVar);
	
}

function refreshOrder() // refreshes the order page
{
	clearOrderImg_page(); // clear the iamge page
	ListBears(gbl_bearType); // list the bears
}

function createOrderLayers() // create the layers to display order information
{
	Ordertxt=''; // initialize the string to null

	// -- order bear image --
	Ordertxt+="<div id='divorderbearimg' style='POSITION: absolute; VISIBILITY: hidden;";
	Ordertxt+=" TOP: 100px; LEFT: 100px; WIDTH: 240px; z-Index: 200;'>";
	Ordertxt+="<table border='3'><tr><td>";
	Ordertxt+="<img id='orderbearimg' src='images/index/blank.gif'";
	Ordertxt+=" width='240'></td></tr></table>";
	Ordertxt+="</div>";

	// -- order bear description
	Ordertxt+="<div id='divorderbeardescr' style='POSITION: absolute; VISIBILITY: hidden;";
	Ordertxt+=" TOP: 100px; LEFT: 100px; WIDTH: 360px; HEIGHT: 150px; z-Index: 200;'>";
	Ordertxt+="<table border='3' class='"+css_order+"'>";
	Ordertxt+="<tr><td id='orderbeardescr'>TEST</td></tr></table>";
	Ordertxt+="</div>";

	// -- order bear info
	Ordertxt+="<div id='divorderinfo' style='POSITION: absolute; VISIBILITY: hidden;";
	Ordertxt+=" TOP: 100px; LEFT: 100px; WIDTH: 360px; HEIGHT: 250px; z-Index: 200;'>";
	Ordertxt+="<table border='3' class='"+css_order+"'>";
	Ordertxt+="<tr><td id='orderinfo'><center>&nbsp</center></td></tr></table>";
	Ordertxt+="</div>";
	
	// -- order close button
	Ordertxt+="<div id='divcloseButton' style='POSITION: absolute; VISIBILITY: hidden;";
	Ordertxt+=" TOP: 100px; LEFT: 100px; WIDTH: 240px; HEIGHT: 20px; z-Index: 200;'>";
	Ordertxt+="<center><table><tr><td id='closeButton'>";
	
	// adjust button info based on screen size
	if(sizeSelection == 0) Ordertxt+="<form ID=Form1><input type='button' value='GALLERY'";
	else Ordertxt+="<form ID=Form1><input type='button' value='RETURN TO GALLERY'";
	
	Ordertxt+="onClick='javascript:refreshOrder()' ID=Button1></form></td></tr></table></center>";
	Ordertxt+="</div>";

	// write out the information to the page
	bearOrder = GetObject('orderMain'); // get the reference to the layer
	writeInfo(bearOrder,Ordertxt); // write the info out

	adjustOrderLayers(); //position the order layers
	
	isOrderLayerDisplayed=true; // the order layers are displayed
}

function getOrderLayerRefs() // get the references to the order layers
{
	orderImgDiv=GetObject('divorderbearimg'); // get pointer to the image layer
	orderDescrDiv=GetObject('divorderbeardescr'); // get the pointer to the descr layer
	orderInfoDiv=GetObject('divorderinfo'); // get the title to the info layer
	orderClsDiv=GetObject('divcloseButton'); // get the pointer to the close button
	orderBearImgDiv=GetObject('orderbearimg'); // get the pointer to the bear image
}

function repositionOrderLayer() // dynamically position the order layers
{
	orderClsDiv.style.left=stripPx(dispBckGnd.style.left)+backGround_brder; // set the left hand side of the button
	orderClsDiv.style.top=stripPx(dispBckGnd.style.top)+backGround_brder; // set the top of the button
	
	orderImgDiv.style.left=stripPx(dispBckGnd.style.left)+backGround_brder; // set the left hand side of the bear image
	orderImgDiv.style.top=stripPx(orderClsDiv.style.top)+stripPx(orderClsDiv.style.height)+backGround_brder; // set the top of the bear image

	orderDescrDiv.style.left=stripPx(orderImgDiv.style.left)+stripPx(orderImgDiv.style.width)+(4*backGround_brder); // position the left side of the bear description layer
	orderDescrDiv.style.top=stripPx(dispBckGnd.style.top)+(2*backGround_brder); // position the top of the bear description layer
	
	orderInfoDiv.style.left=stripPx(orderDescrDiv.style.left); // position the payment layer
	orderInfoDiv.style.top=stripPx(orderDescrDiv.style.top)+stripPx(orderDescrDiv.style.height)+(2*backGround_brder); // position the payment layer
}

