// GLOBALS //
//var selectedID ='-1';
/////////////////////


////////////////////////////////////////////////
// SKU SELECTION FUNCTIONS
////////////////////////////////////////////////
/*function highlight(id)
{
	if(selectedID!=id)
	{
		var myDiv = document.getElementById(id);
		myDiv.style.backgroundColor = "F3E7B1";
		//myDiv.style.width= "300px";
		//document.getElementById("mat"+id).style.visibility='visible;';
	}
}

function unhighlight(id)
{
	if(selectedID!=id)
	{
		var myDiv = document.getElementById(id);
		myDiv.style.backgroundColor = "D3D2BC";
		//myDiv.style.widt h= "300px";
	}
	//document.getElementById("mat"+id).style.visibility='hidden';
}

function selected(id, portfolio)
{	
	if(selectedID!='-1') //unhighlight previously highlighted
	{
		var myDiv = document.getElementById(selectedID);
		myDiv.style.backgroundColor="D3D2BC";
		
		//myDiv.style.width= "300px";
	}
	
	selectedID = id; 	
	
	var myDiv2 = document.getElementById(id);
	myDiv2.style.backgroundColor= "B6AA65";
	//myDiv2.style.size= "large";
	//myDiv2.style.backgroundColor= "F3E7B1";
	/*document.getElementById('selectedSKU').firstChild.nodeValue= myDiv2.outerText;
	document.addToCart.selectedIndex.value = id; 
	document.addToCart.portfolio.value = portfolio;
}

////////////////////////////////////////////////
// EDITION CALENDAR FUNCTIONS
////////////////////////////////////////////////

function showEditionSelection()
{
	document.getElementById("popup").style.display = 'block'; 
	
}

function hideEdition()
{
	document.getElementById("popup").style.display = 'none'; 
}	

function mover(id)
{
	var elem = document.getElementById(id);
	elem.style.backgroundColor = "D400D1"; 
}
function mout(id)
{
	var elem = document.getElementById(id);
	elem.style.backgroundColor = "009900"; 
}
function mout2(id)
{
	var elem = document.getElementById(id);
	elem.style.backgroundColor = "993300"; 
}

function oClick(num)
{
	document.addToCart.customEdition.value= num;
	document.getElementById("specialEditionNote").innerHTML = "Ordering Print Number: "+num;
	document.addToCart.quantity.value=1;
	document.addToCart.quantity.readOnly= "true";  
	document.getElementById("cancelCustom").style.display='block';
	hideEdition(); 
}

function cancelCustomEdition()
{
	document.getElementById("specialEditionNote").innerHTML = "&nbsp;"
	document.addToCart.customEdition.value= 0;
	document.getElementById("cancelCustom").style.display='none';
	//document.addToCart.quantity.value=1;
	document.addToCart.quantity.readOnly= false;  
}*/

function customSku(origx, origy, xy, ratePaper, rateStretched, rateUnstretched, percent, account)
{
	var newVal;
	var writei;
	var readi;
	var price;
	var dontChangeSize = false;
	if(xy=="x")
	{
		readi = document.addToCart.x;
		
		if(readi.value<10) { readi.value = 10; }
		if(readi.value>48) { readi.value = 48; }
		
		writei = document.addToCart.y;	
		newVal = (origy * readi.value) / origx;
	}
	else if(xy=="y")
	{
		readi = document.addToCart.y;
		
		if(readi.value<10) { readi.value = 10; }		
		if(readi.value>48) { readi.value = 48; }	
		
		writei = document.addToCart.x;			
		newVal = (origx * readi.value) / origy;
	}
	else
	{
		newVal = document.addToCart.y.value;
		readi = document.addToCart.x;
		dontChangeSize = true;
	}
	
	if(readi.value=="" || readi.value==null || readi.value==0)
	{
		document.getElementById("price").innerHTML = "&nbsp";
		writei.value="";
		readi.value="";
		document.addToCart.customOrder.value=0;
		return 0;
	}
	
	if(dontChangeSize == false)
	{
		//newVal.toFixed(2);
		newVal = roundSimple(newVal.toString(), 2);			
		writei.value = newVal;
	}
	
	//now do some pricing
	if(document.addToCart.material.selectedIndex==0)
	{
		document.getElementById("stretching").style.display="block";		
		document.getElementById("unstretchedGW").style.display="block";
		
		document.getElementById("border").style.display="none";
		if(document.addToCart.stretching.selectedIndex==0)
		{			
			//document.getElementById("unstretchedGW").style.display="block";
			price = readi.value * newVal * rateUnstretched;
		}
		else
		{
			//document.getElementById("unstretchedGW").style.display="none";
			price = readi.value * newVal * rateStretched;
		}
	}
	else
	{
		document.getElementById("stretching").style.display="none";
		document.getElementById("unstretchedGW").style.display="none";
		document.getElementById("border").style.display="block";
		price = readi.value * newVal * ratePaper;	
	}
	
	 
	if(price<15 && account.toLowerCase()!="studioel")
	{
		price=15.00;
	}
	
	percent = percent/100; //get to .60 or whatver...
	
	if(percent<1) 
	{
		percent=percent+1; 
	}
	
	price = price*(percent); 
	price = roundSimple(price.toString(), 2);
	
	document.getElementById("price").innerHTML = "<strong>Price: $"+price+"</strong>";
	document.addToCart.customOrder.value=1;
}

function stretchingPricing()
{
	//now do some pricing
	var price;
	if(document.addToCart.stretching.selectedIndex==0)
	{
		price = document.addToCart.x.value * document.addToCart.y.value * 0.12;
	}
	else
	{
		price = document.addToCart.x.value * document.addToCart.y.value * 0.16;
	}	
	
	price = roundSimple(price.toString(), 2); 
	
	document.getElementById("price").innerHTML = "<strong>Price: $"+price+"</strong>";

}

// SHOWS POPUP LARGER IMAGE //
function showLargerImage()
{
	document.getElementById("popupImage").style.visibility='visible';	
}
function closeLarger()
{
	document.getElementById("popupImage").style.visibility='hidden';	
}

//for editions
function highlightBox(id)
{
	document.getElementById(id).style.border='1px solid #FFFFFF';
	//document.getElementById(id).style.color='#FFFFFF';
}

function unhighlightBox(id)
{
	document.getElementById(id).style.border='1px solid #000000';
	//document.getElementById(id).style.color='#000000';
}

//for edition, set hidden fields and feedback
function selEdition(id, skuNum)
{
	document.forms['addToCart'+skuNum].customEdition.value=id;
	document.forms['addToCart'+skuNum].quantity.value=1;	
	document.forms['addToCart'+skuNum].quantity.readOnly=true;
	
	document.getElementById('num'+skuNum).innerHTML=id + " is selected";
	
	
	closeWindows();
}
