// JavaScript Document
//************************************************************
//CUSTOM CSS/JS FOR VOLUSION PAGE TYPES

function AddCss()
{   
   var spos = document.URL.lastIndexOf("/");
   if (spos != -1)
   {
      var pagePart = document.URL.substring(0,spos);
      var dpos = pagePart.lastIndexOf("-");
      if (dpos != -1)
      {
         var v = pagePart.substring(dpos+1);
   
         var cssFile;
         if (v==="p"){
            cssFile = "ProductDetails";
			document.write('<script type="text/javascript" src="/v/vspfiles/templates/treetopia/js/template_ProductDetails.js"></script>');
		 }
		 else if (v==="s")
            cssFile = "SearchResults";
 
         document.write('<link rel="stylesheet" href="/v/vspfiles/templates/treetopia/css/'+cssFile+'.css" type="text/css">');
      }
   }
}

function AddCss2()
{
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

	var cssFile2;
	if (sPage === "ProductDetails.asp") {
	   cssFile2 = "ProductDetails";
	   document.write('<script type="text/javascript" src="/v/vspfiles/templates/treetopia/js/template_ProductDetails.js"></script>');
	}
	else if (sPage === "ShoppingCart.asp") 
	   cssFile2 = "custom_checkout";
	else if (sPage === "one-page-checkout.asp") 
	   cssFile2 = "custom_checkout";
	else if (sPage === "SearchResults.asp") 
	   cssFile2 = "SearchResults";
	else if (sPage === "PhotoDetails.asp") 
	   cssFile2 = "custom_photodetails";
	else if (sPage === "Receipt.asp") 
	   cssFile2 = "custom_checkout";
	else if (sPage === "orders.asp") 
	   cssFile2 = "custom_checkout";
	else if (sPage === "orderdetails.asp") 
	   cssFile2 = "custom_checkout";
	else if (sPage === "") 
	   cssFile2 = "Home";
	else if (sPage === "default.asp") 
	   cssFile2 = "Home";
	else if (sPage === "Default.asp") 
	   cssFile2 = "Home";

	document.write('<link rel="stylesheet" href="/v/vspfiles/templates/treetopia/css/'+cssFile2+'.css" type="text/css">');
}

AddCss();
AddCss2();

//************************************************************
// TO CHANGE LOGO ON ROLLOVER

function onrollover_header_bg(){
	document.getElementById('header').style.backgroundImage="url('/v/vspfiles/images/custom/logo-rollover.jpg')";	
}

function onrollout_header_bg(){
	document.getElementById('header').style.backgroundImage="url('/v/vspfiles/images/custom/logo.jpg')";
}

//************************************************************
// FUNCTION TO OPEN NEW WINDOW

function OpenNewWindow2(url)
{
	var randomnumber=Math.floor(Math.random()*5001)
	window.open(url, randomnumber, "top=10,left=10,menubar=0,resizable=1,scrollbars=1,width=550,height=700")
}

//************************************************************
// FUNCTION TO CHANGE ADD_TO_CART TO BLUE COLOR ON ROLLOVER

$(document).ready(function(){
var allbtn = document.getElementsByName('btnaddtocart');
for (x in allbtn){ allbtn[x].className = 'btnaddtocart';}
	$(".btnaddtocart").hover(function() {
		$(this).attr("src","/v/vspfiles/templates/treetopia/images/buttons/btn_addtocart-blue.gif");
			}, function() {
		$(this).attr("src","/v/vspfiles/templates/treetopia/images/buttons/btn_addtocart.gif");
	});
});
