var affParam;
var par = window.location.href.substr(window.location.href.indexOf("?")+1);
var parampair = par.split("&");
var j = 0;

// Checks if any parameters are passed in the URL
for (i=0;i<parampair.length;i++)
{
	// If parameters where passed, check if the 'affiliate' parameter is there
	if(parampair[i].indexOf("affiliate") > -1)
		j = i;		
}

var paramlist = parampair[j].split("=");

// Default value for 'affiliate', in case no value is passed in the URL
var affParam = "int";

if (par != "") 
{
	for (i=0;i<paramlist.length;i++)
	{
		if (paramlist.length == 2)
		{
			// If the 'affiliate' parameter was passed and it has a value, assign it to the variable
			if (paramlist[0].toLowerCase() == "affiliate")
				affParam = paramlist[1];
      	}
	}
}

if (affParam == "")
	affParam = "int";

function goToURL(target)
{
var URL = "http://www.ikegelpro.com/"+target+"?affiliate="+affParam;	

document.location.href = URL;
}

function goToOrderURL()
{
var orderURL = "http://www.ikegelpro.com/Merchant2/merchant.mvc?Screen=PLST&Store_Code=Ikegelpro&affiliate="+affParam;	

window.open(orderURL,'_blank');
}

