/*******************************************
Client Script
********************************************/

var ImageDirectory = "vitamin-nutritional-supplements-images/";
var CurrentUrl = window.location.href;

function HandleOnLoadEvents()
{
	SetCurrentPageImage();
}

function SetCurrentPageImage()
{
	ResetMenus();
	if (CurrentUrl.indexOf("Product") > -1)
	{
		document.getElementById("ProductsMenu").style.display = "block";
	}
	else if (CurrentUrl.indexOf("PrivateLabel") > -1)
	{
		document.getElementById("PrivateLabelingMenu").style.display = "block";
	}
	else if (CurrentUrl.indexOf("CustomFormulation") > -1)
	{
		document.getElementById("CustomFormulationsMenu").style.display = "block";
	}
	else if (CurrentUrl.indexOf("Distributor") > -1)
	{
		document.getElementById("DistributorsMenu").style.display = "block";
	}
	else if (CurrentUrl.indexOf("AboutUs") > -1)
	{
		document.getElementById("AboutUsMenu").style.display = "block";
	}
	else
	{
		document.getElementById("DefaultMenu").style.display = "block";
	}
}

function ChangeProductName(s)
{
    var o = document.getElementById("HotProductTitle");
    
    if (o)
    {
        if (s == null)
            o.innerHTML = "Hot New Products From Vitalabs!";
        else
            o.innerHTML = s;
    }
}

function ResetMenus()
{
	document.getElementById("DefaultMenu").style.display = "none";
	document.getElementById("ProductsMenu").style.display = "none";
	document.getElementById("PrivateLabelingMenu").style.display = "none";
	document.getElementById("CustomFormulationsMenu").style.display = "none";
	document.getElementById("DistributorsMenu").style.display = "none";
	document.getElementById("AboutUsMenu").style.display = "none";	
}

function GetUrlBase()
{
    var s = CurrentUrl.replace(/\//g, '/|');
    var UrlArray = s.split('|');
    var r = "";
    
    for (var i = 0; i < UrlArray.length - 1; i++)
    {
        r += UrlArray[i];
    }
    
    return r;
}


function GetPathWithoutExtention(s)
{
	var a = s.split('.');
	var r = "";
	for (var i = 0; i < a.length - 1; i++)
	{
		r += a[i];
	}
	return r;
}

function GetFilename(s)
{
	var a = s.split("/");
	return a[a.length - 1];
}

function PopUp(url)
{
	var PopUpUrl = url;

	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(PopUpUrl, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=350,height=375');");
}	
