
function eShopOnClick(){
	var i = 0;
	var url = null;
	var tmpElement = window.event.srcElement;
	while((tmpElement != null)&&(i<100)){
		i++;
		if(tmpElement.tagName == "A"){
			url = tmpElement.href;
		}
		if(tmpElement.id=="eShopOffer"){
			window.event.returnValue = false;
			if(url!=null)
				OpenWindow(url,"","_blank",100,100);
			break;
		}
		tmpElement = tmpElement.parentElement;
	}
	
}


function DeluxeTrackerPing(httpMode, GameCode, EventID, Instance)
{
	var tracker=new Image();
	var now = new Date();
	var timeVal = Math.floor(now.valueOf() / 1000);
	var timeZoneOffset = now.getTimezoneOffset() / 60;
	tracker.src="" + httpMode + g_ZoneServer + "/utility/trackinggif.aspx?Game=" + GameCode + "&EventID=" + EventID + "&Instance=" + Instance + "&ClientTime=" + timeVal + "&ClientTimeZone=" + timeZoneOffset;
}


function CTagIt(eventName)
{
	var o = new Image();
	var ZoneUrl = document.URL;
	var TPUrl = "http://" + document.domain;
	var ZoneDir = (ZoneUrl.substring(TPUrl.length));
	if (ZoneDir.lastIndexOf(".") > -1)
		TPUrl += ZoneDir.substring(0, ZoneDir.lastIndexOf("."));
	else
		TPUrl += ZoneDir;
	o.src = "http://" + g_TaxonomyServer + "/c.gif?NA=1127&NC=1222&PI=7333&DI=554&PS=7446&TP=" + TPUrl + "/" + escape(eventName)+ ".htm";
}


function HtmlEncode(text)
{
	text = text.replace("&", "&amp;");
	text = text.replace("'", "&apos;");
	text = text.replace("\"", "&quot;");
	text = text.replace("<", "&lt;");
	text = text.replace(">", "&gt;");
	return text;
}

function HtmlDecode(text)
{
	text = text.replace(new RegExp("&nbsp;", "gi"), " ");
	text = text.replace(new RegExp("&amp;", "gi"), "&");
	text = text.replace(new RegExp("&apos;", "gi"), "'");
	text = text.replace(new RegExp("&quot;", "gi"), "\"");
	text = text.replace(new RegExp("&lt;", "gi"), "<");
	text = text.replace(new RegExp("&gt;", "gi"), ">");
	text = text.replace(new RegExp("&copy;", "gi"), "\u00A9");
	text = text.replace(new RegExp("&reg;", "gi"), "\u00AE");
	text = text.replace(new RegExp("&trade;", "gi"), "\u2122");
	text = text.replace(new RegExp("\&\#([0-9]+);", "gi"), DecimalCharReplace);
	text = text.replace(new RegExp("\&\#x([0-9A-F]+);", "gi"), HexadecimalCharReplace);
	return text;
}

function DecimalCharReplace(match, submatch)
{
	return String.fromCharCode(parseInt(submatch,10));
}

function HexadecimalCharReplace(match, submatch)
{
	return String.fromCharCode(parseInt(submatch,16));
}

//This function elimiate ascii special character and leave only 0 to 9,A to Z,a to z in the str
function NoSpecialChar(str)
{
    //First remove &amp;,#x0AE; replaced at server side from &
    str = str.replace("&amp;","");  //&
    str = str.replace("#x0AE;",""); //®
     
    var newStr = "";
    for(i=0;i<str.length;i++)
    {
        var ASCIICode = str.charCodeAt(i);
		//     0 to 9                                     A to Z                                 a to z
        if( (ASCIICode>=48 && ASCIICode<=57) || (ASCIICode>=65 && ASCIICode<=90) || (ASCIICode>=97 && ASCIICode<=122))
            newStr = newStr + str.charAt(i);
    }
	return newStr;
}
if( document.implementation.hasFeature("XPath", "3.0") )
{
    if( typeof XMLDocument == "undefined" ) { XMLDocument = Document; }
  
    XMLDocument.prototype.selectNodes = function(cXPathString, xNode)
    {
        var aResult = [];
        try
        {
            if( !xNode ) { xNode = this; } 
            
            var aItems = this.evaluate(cXPathString, xNode, {
                normalResolver:
                document.createNSResolver(document.documentElement),
                    lookupNamespaceURI : function (prefix) 
                    {
                        var ns = {
                            'xhtml' : 'http://www.w3.org/1999/xhtml',
                            'mathml': 'http://www.w3.org/1998/Math/MathML',
                            'msncp' : 'urn:schemas-microsoft-com/contentpublishing/content'
                        };
                        return ns[prefix] || null;
                    }
                }, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
            
            
            for( var i = 0; i < aItems.snapshotLength; i++)
            {
                aResult[i] =  aItems.snapshotItem(i);       
            }
        }
        catch (e)
        {
            alert(e.message);
        }
        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"; }
    }
}