function GetThis(T, C, U, L)
{
var targetUrl = 'http://www.myspace.com/Modules/PostTo/Pages/?' + 't=' + encodeURIComponent(T)
+ '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
window.open(targetUrl, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no');
}

function showGrd(c) {
	if (document.getElementById("grd"+c).style.display == "none")
	{
		document.getElementById("grd"+c).style.display = "block";
		document.getElementById(c).innerHTML = "Hide availibility";		
	}
	else if (document.getElementById("grd"+c).style.display == "block")
	{
		document.getElementById("grd"+c).style.display = "none";	
		document.getElementById(c).innerHTML = "Show availibility";
	} 
}

function printManikin(strStage) {
	var strUrl = "print_manikin_1.aspx?";
	var strTmp = "";
	
	strUrl += "stage=" + strStage;
	
	strTmp = document.getElementById("shirtImage").firstChild.firstChild.src;
	
	strTmp = strTmp.substring(strTmp.lastIndexOf("/") + 1);
	
	strUrl += "&shirt=" + strTmp;
	
	strTmp = document.getElementById("shortImage").firstChild.firstChild.src;
	
	strTmp = strTmp.substring(strTmp.lastIndexOf("/") + 1);
	
	strUrl += "&short=" + strTmp;
	
	strTmp = document.getElementById("sockImage").firstChild.firstChild.src;
	
	strTmp = strTmp.substring(strTmp.lastIndexOf("/") + 1);
		
	strUrl += "&sock=" + strTmp;
	
	if(strStage != "training" && strStage != "tracksuit") {
	
	strUrl += "&shirtn=" + arrSelections["shirt"].strVariationParentID + "&shirtcol=" + arrSelections["shirt"].strColour;
	// add short style + colour
	strUrl += "&shortn=" + arrSelections["short"].strVariationParentID + "&shortcol=" + arrSelections["short"].strColour;
	// add sock style + colour
	strUrl += "&sockn=" + arrSelections["sock"].strVariationParentID + "&sockcol=" + arrSelections["sock"].strColour;
	}
		
	if(strStage == "tracksuit") {
		strTmp = document.getElementById("tracksuitImage").firstChild.firstChild.src;
		strTmp = strTmp.substring(strTmp.lastIndexOf("/") + 1);
		strUrl += "&tracksuit=" + strTmp;
	}
	window.open(strUrl, "printMan", "width=567,height=600,resizable=yes,scrollbars=yes");
}






// cross-browser fns
if(window.HTMLElement) {
	HTMLElement.prototype.insertAdjacentElement=function(where,parsedNode){
		switch(where){
			case "beforeBegin":
				this.parentNode.insertBefore(parsedNode,this);
				break;
			case "afterBegin":
				this.insertBefore(parsedNode,this.firstChild);
				break;
			case "beforeEnd":
				this.appendChild(parsedNode);
				break;
			case "afterEnd":
				if(this.nextSibling)
					this.parentNode.insertBefore(parsedNode,this.nextSibling);
				else
					this.parentNode.appendChild(parsedNode);
				break;
		}
	}
}
// mozXPath [http://km0ti0n.blunted.co.uk/mozxpath/] km0ti0n@gmail.com
// Code licensed under Creative Commons Attribution-ShareAlike License 
// http://creativecommons.org/licenses/by-sa/2.5/
if( document.implementation.hasFeature("XPath", "3.0") )
{
	XMLDocument.prototype.selectNodes = function(cXPathString, xNode)
	{
		if( !xNode ) { xNode = this; } 

		var oNSResolver = this.createNSResolver(this.documentElement)
		var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
		var aResult = [];
		for( var i = 0; i < aItems.snapshotLength; i++)
		{
			aResult[i] =  aItems.snapshotItem(i);
		}
		
		return aResult;
	}
	XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode)
	{
		if( !xNode ) { xNode = this; } 

		var xItems = this.selectNodes(cXPathString, xNode);
		if( xItems.length > 0 )
		{
			return xItems[0];
		}
		else
		{
			return null;
		}
	}

	Element.prototype.selectNodes = function(cXPathString)
	{
		if(this.ownerDocument.selectNodes)
		{
			return this.ownerDocument.selectNodes(cXPathString, this);
		}
		else{throw "For XML Elements Only";}
	}

	Element.prototype.selectSingleNode = function(cXPathString)
	{	
		if(this.ownerDocument.selectSingleNode)
		{
			return this.ownerDocument.selectSingleNode(cXPathString, this);
		}
		else{throw "For XML Elements Only";}
	}

}

function highlighmenu(section){
	if(document.getElementById(""+section)) {
		document.getElementById(""+section).className = "kleftmenuCurrent";
	}
}

// Print web page
function printpage() {
	window.print();
}

// Open print page using _print extension.
function showPrint() {
	var strPage = window.location.pathname;
	
	strPage = strPage.substring(0, strPage.indexOf("_1.aspx"));
	if(strPage.indexOf("document") == 1) 
	{
		strPage = "document";
	}
	else if(strPage.indexOf("news") == 1) {
		strPage = "news";	
	}
	else if(strPage.indexOf("search") == 1) {
		strPage = "search";	
	}
	else {
		// set document as default
		strPage = "document";	
	}
	/*window.location = strPage + "_print_1.aspx" + window.location.search;*/
	window.open(strPage + "_print_1.aspx" + window.location.search);
	
}

// Search site
function checkSearchFields(objForm)
{	
		if(Trim(objForm.keywords.value) == "") {
			alert("Please enter your keyword(s)");
			objForm.keywords.focus();
			return false;
		}
		else {
			return true;
		}
}


// Trim
function trim(str) {
	return Trim(str);
}
function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1)
	{
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	
	if(TRIM_VALUE=="")
	{
	return "";
	}
	else {
		return TRIM_VALUE;
	}
}//End Function

// Right Trim
function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	
	if(v_length < 0)
	{
		return"";
	}
	
	var iTemp = v_length -1;
	
	while(iTemp > -1)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
			// nothing
		}
		else
		{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} //End While
	
	return strTemp;

} //End Function


// Left Trim
function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	
	if(v_length < 1)
	{
		return"";
	}
	
	var v_length = VALUE.length;
	var strTemp = "";
	
	var iTemp = 0;
	
	while(iTemp < v_length)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
			//nothing
		}
		else
		{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	
	return strTemp;
	
} //End Function

// Show/Hide 
function show(c) {
	if (document.getElementById && document.getElementById(c)!= null) 
		node = document.getElementById(c).style.display='block'; 
	else if (document.layers && document.layers[c]!= null) 
		document.layers[c].display = 'block'; 
	else if (document.all && document.all(c)!= null) 
		document.all[c].style.display = 'block';
} 

function hide(c) {	
	if (document.getElementById && document.getElementById(c)!= null)
		node = document.getElementById(c).style.display='none';
	else if (document.layers && document.layers[c]!= null) 
		document.layers[c].display = 'none';
	else if (document.all && document.all(c)!= null) 
		document.all[c].style.display = 'none';
}
// end Show/Hide 

// returns the value of the given param, empty string if it doesn't exist in the URL
function getUrlParam(strName) {
	var strParams = window.location.search;
	var strParam = "";
	var iPosStart = -1, iPosEnd = -1;
	
	if((iPosStart = strParams.indexOf("?" + strName + "=")) != -1) {
		iPosStart += strName.length + 2;
		iPosEnd = strParams.indexOf("&", iPosStart);
		if(iPosEnd == -1) iPosEnd = strParams.length;
		strParam = strParams.substring(iPosStart, iPosEnd);
	} else if((iPosStart = strParams.indexOf("&" + strName + "=")) != -1) {
		iPosStart += strName.length + 2;
		iPosEnd = strParams.indexOf("&", iPosStart);
		if(iPosEnd == -1) iPosEnd = strParams.length;
		strParam = strParams.substring(iPosStart, iPosEnd);
	}
	return strParam;
}
						

/*** keep alive ***/
var gsDomain = window.location.protocol + "//" + window.location.host;
var gfUsingIP = (((window.location.host.substring(0, 1) >= "0") && (window.location.host.substring(0, 1) <= "9")) || (window.location.host == "localhost"));
var gsFolder = "/";
if(gfUsingIP) {
	gsFolder = "/" + window.location.pathname.substring(1, window.location.pathname.indexOf("/", 1)) + "/";
}
gsDomain += gsFolder;
document.write("<script type=\"text/javascript\" src=\"/assets/scripts/Ajax.js\"></script>");
document.write("<script type=\"text/javascript\" src=\"/assets/scripts/EdeptiveAjax.js\"></script>");
var goAjax = null;
function keepAlive() {
	var strUrl = "";
	var sTiming = document.lastChild.lastChild.innerHTML;
	var sParams = "";

	sTiming = sTiming.substring(sTiming.lastIndexOf("<!--"));
	sTiming = sTiming.substring(5, sTiming.indexOf(" -->"));
	strUrl = gsDomain + "/webservices/keep_alive.asmx/Ping";
	sParams = "Timing=" + sTiming;
	try {
		goAjax = new EdeptiveAjax();
		goAjax.postRequest(strUrl, sParams, onKeepAliveResponse);
	} catch(e) {
		setTimeout("keepAlive()", 1000*1);
	}
}
function onKeepAliveResponse() {
	if(goAjax.checkReadyState("keepAlive", "ping.", "ping..", "ping...") == "OK") {
		if(document.getElementById("keepAlive")) {
			var response = goAjax.request.responseXML.documentElement;
			document.getElementById("keepAlive").innerText = "sid=" + getText(response.firstChild);
		}
		setTimeout("keepAlive()", 1000*60);
	}
}
setTimeout("keepAlive()", 1000*2);
