var animationRunning = false;

//Turns links to a different color on mouseover and mouseout
function colorChangeHeader(obj,action)
{
	if(action == "on")
		obj.style.color = "#d37538";
	else
		obj.style.color = "black";
}
function colorChangeLeft(obj,action)
{
	if(action == "on")
		obj.style.color = "#FEE739";
	else
		obj.style.color = "FBF5CE";
}
function doStyle(area,cssName)
{
	document.styleSheets(area).href = "./styles/"+cssName;
}

function mivaSend(strProdName,strProdCode,strResultId)
{
	var baseUrl = "https://secure.netsolhost.com/299232.304114/Merchant2/merchant.mvc?Screen=BASK&Store_Code=RBC&Action=ADPR&Product_Code="+strProdCode+"&Attributes=Yes&Quantity=1";
	document.getElementById("wf").src = baseUrl;
	delay(1000);
	alert(strProdName+ " has been added to your shopping cart.");
	delay(2000);
	resultWrite("result"+strResultId,"Item added to your <a href='./shoppingCart.aspx'>shopping cart</a>.");
}
function resultWrite(spanId,text)
{
	document.getElementById(spanId).innerHTML = text;				
}
function delay(gap)/* gap is in millisecs */
{
	var then,now;
	then = new Date().getTime();
	now=then;
	while((now-then) < gap)
	{
		now=new Date().getTime();
	}
}
function newWindow(url,name,width,height)
{
	var features = "width="+width+",height="+height+",scrollbars=1,location=0,status=0,copyhistory=0,resizable=1";
	window.open(url,name,features)	
}


var menuHeight = 220;
var curMenuHeight = 1;
function toggleExtras() {
	if (animationRunning == true)
	  return;
	else if (curMenuHeight == 1) {
		animationRunning = true;
		setTimeout(menuSlideDown, 50);
	}
	else if (curMenuHeight == menuHeight) {
		animationRunning = true;
	  setTimeout(menuSlideUp, 50);
  }
}

function menuSlideDown() {
	curMenuHeight += 20;
	if (curMenuHeight > menuHeight)
	  curMenuHeight = menuHeight;
	document.getElementById("extrasMenu").style.height = curMenuHeight + "px";
	if (curMenuHeight < menuHeight)
	  setTimeout(menuSlideDown, 50);
	else
	  animationRunning = false;
}

function menuSlideUp() {
	curMenuHeight -= 20;
	if (curMenuHeight < 1)
	  curMenuHeight = 1;
	document.getElementById("extrasMenu").style.height = curMenuHeight + "px";
	if (curMenuHeight > 1)
	  setTimeout(menuSlideUp, 50);
	else
	  animationRunning = false;
}