﻿
//IE FF兼容 追加事件

//if (window.attachEvent) {
//	window.attachEvent("onload", function () { indexinit(); });
//	window.attachEvent("onclick", function () { clickItem(); });
//	window.attachEvent("onkeydown", iekeydown);
//}
//else { //FireFox
//	window.addEventListener("load", function () { indexinit(); }, true);
//	window.addEventListener("click", function () { clickItem(); }, true);
//	window.addEventListener("keydown", firefoxkeydown, true);
//}
//function iekeydown(evt) {
//	selectItem(evt);
//}
//function firefoxkeydown(evt) {
//	selectItem(evt);
//}




if (document.addEventListener) {//如果是Firefox   5:   
	document.addEventListener("keypress", fireFoxHandler, true);
}
else {
	document.attachEvent("onkeypress", ieHandler);

	
}
function fireFoxHandler(evt) {
	//alert("firefox");
	if (evt.keyCode == 13) {
		logaddsearch();
	}
	
}
function ieHandler(evt) {
	//alert("IE");
	if (evt.keyCode == 13) {
		logaddsearch();
	}
	
}


function logaddsearch() {
	if (document.activeElement.id == "logemailtb"
             || document.activeElement.id == "logpasstb"
             || document.activeElement.id == "login11_lbtn_login1") {
		cuslogin('logemailtb', 'logpasstb');
		document.activeElement.id = "logpasstb";
		document.getElementById("logpasstb").focus();
		return false;
	}
	else if (document.activeElement.id == "searchShopInput"
             || document.activeElement.id == "ibtn_Search") {
		searchShop();
		document.activeElement.id = "img001"
		document.activeElement.id = "searchShopInput";
		document.getElementById("searchShopInput").focus();
		return false;
	}
}


//function showhide() {
//    var div1 = document.getElementById("div1");
//    if (div1.style.display == "none") {
//        div1.style.display = "block";
//    }
//    else {
//        div1.style.display = "none";
//    }
//}


//获得xml文档对象
function getXmldoc(xml) {
	try //Internet Explorer
        {
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async = "false";
		xmlDoc.loadXML(xml);
	}
	catch (e) {
		try // Firefox, Mozilla, Opera, etc.
            {
			parser = new DOMParser();
			xmlDoc = parser.parseFromString(xml, "text/xml");
		}
		catch (e) {
			alert(e.message);
			return;
		}
	}
	return xmlDoc;
}

//解析xml        strxml 为xml格式的字符串
function strToXml(strxml) {
	var ObjDomXml;
	var doc;
	//IE
	if (window.ActiveXObject) {
		ObjDomXml = new ActiveXObject("Microsoft.XMLDOM");
		doc = ObjDomXml;
		doc.async = "false";
		doc.loadXML(strxml);
	}
	//FF
	else {
		ObjDomXml = new DOMParser();
		doc = ObjDomXml.parseFromString(strxml, "text/xml");
	}

	return doc;
}




//调用方法              onkeypress="onlyNumber(event)"
function onlyNumber(e) {
	var isIE = false;
	var isFF = false;
	var isSa = false;

	if ((navigator.userAgent.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4)) isIE = true;
	if (navigator.userAgent.indexOf("Firefox") > 0) isFF = true;
	if (navigator.userAgent.indexOf("Safari") > 0) isSa = true;

	var iKeyCode;
	iKeyCode = window.event ? e.keyCode : e.which;
	if (!(((iKeyCode >= 48) && (iKeyCode <= 57)) || (iKeyCode == 13) || (iKeyCode == 46) || (iKeyCode == 45) || (iKeyCode == 37) || (iKeyCode == 39) || (iKeyCode == 8))) {
		if (isIE) {
			e.returnValue = false;
		}
		else {
			e.preventDefault();
		}
	}

}


//添加商品
function addProduct(id, typeId) {
	if ($('checkoutId') != null && $('checkoutId') != undefined) {
		$('checkoutId').display = 'none';
	}

	xml = getCookie("shopinfo");

	xmlDoc = getXmldoc(xml);
	for (var i = 0; i < xmlDoc.getElementsByTagName("Table").length; i++) {
		if (xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("pid")[0].childNodes[0].nodeValue == id
            && xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("OrderType")[0].childNodes[0].nodeValue == getCookie('OrderType'))
			return;
	}
	var temp = new Product(); //保存到对象变量
	temp.pid = id;
	temp.productPrice = $F('productPrice' + id);
	temp.number = 1;

	var ds = xmlDoc.documentElement;
	var root = xmlDoc.createElement('Table');
	xid = xmlDoc.createElement('pid');
	newtext = xmlDoc.createTextNode(temp.pid);
	xid.appendChild(newtext);
	root.appendChild(xid);

	xid = xmlDoc.createElement('productPrice');
	newtext = xmlDoc.createTextNode(temp.productPrice);
	xid.appendChild(newtext);
	root.appendChild(xid);

	xid = xmlDoc.createElement('TypeId');
	newtext = xmlDoc.createTextNode(typeId);
	xid.appendChild(newtext);
	root.appendChild(xid);

	xid = xmlDoc.createElement('GameId');
	newtext = xmlDoc.createTextNode(getCookie('gameId'));
	xid.appendChild(newtext);
	root.appendChild(xid);

	xid = xmlDoc.createElement('number');
	newtext = xmlDoc.createTextNode(temp.number);
	xid.appendChild(newtext);
	root.appendChild(xid);

	xid = xmlDoc.createElement('OrderType');
	newtext = xmlDoc.createTextNode(getCookie('OrderType'));
	xid.appendChild(newtext);
	root.appendChild(xid);


	ds.appendChild(root);
	if (isIE()) {
		setCookie("shopinfo", ds.xml, 1);
	}
	else {
		str = serializeXml(xmlDoc.documentElement);
		setCookie("shopinfo", str, 1);

	}

	getShop();
	location = "#gouwuche";
}

//火狐下获得XML字符串
function serializeXml(xmlDoc) {
	var oSerializer = new XMLSerializer();
	return oSerializer.serializeToString(xmlDoc);
}

//显示总价  
function TotalAccount() {
	$('Total').innerHTML = ws2(GetTotal());
}
//获得购物车内的商品总价（所选币种单位）
function GetTotal() {
	var total = 0;
	xml = getCookie("shopinfo");

	xmlDoc = getXmldoc(xml);
	for (var i = 0; i < xmlDoc.getElementsByTagName("Table").length; i++) {
		number = parseInt(xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("number")[0].childNodes[0].nodeValue);
		price = parseFloat(xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("productPrice")[0].childNodes[0].nodeValue);
		total += number * changeRate(price);
	}
	return total;
}
//获得购物车内的商品总价（美元）
function GetTotalUSD() {
	var total = 0;
	xml = getCookie("shopinfo");

	xmlDoc = getXmldoc(xml);
	for (var i = 0; i < xmlDoc.getElementsByTagName("Table").length; i++) {
		number = parseInt(xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("number")[0].childNodes[0].nodeValue);
		price = parseFloat(xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("productPrice")[0].childNodes[0].nodeValue);
		total += number * price;
	}
	return total;
}




//删除一件商品
function deleteProduct(id, orderType) {
	xml = getCookie("shopinfo");

	xmlDoc = getXmldoc(xml);
	for (var i = 0; i < xmlDoc.getElementsByTagName("Table").length; i++) {
		if (xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("pid")[0].childNodes[0].nodeValue == id
        && xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("OrderType")[0].childNodes[0].nodeValue == orderType) {
			node = xmlDoc.getElementsByTagName("Table")[i];
			xmlDoc.documentElement.removeChild(node);
			break;
		}
	}
	if (isIE()) {
		if (xmlDoc.getElementsByTagName("Table").length == 0)
			setCookie("shopinfo", '<NewDataSet />', 1);
		else
			setCookie("shopinfo", xmlDoc.documentElement.xml, 1);
	}
	else {
		if (xmlDoc.getElementsByTagName("Table").length == 0)
			setCookie("shopinfo", '<NewDataSet />', 1);
		else {
			str = serializeXml(xmlDoc.documentElement);
			setCookie("shopinfo", str, 1);
		}

	}
	getShop();
}

//减少商品数量
function minishNumber(id) {
	var number = Number($(id).innerHTML);
	if (number > 1) {
		number = number - 1;
		$(id).innerHTML = number;
		SetShopNumber(id, number);
	}
}
//增加商品数量
function addnumber(id) {
	var number = Number($(id).innerHTML);
	if (number < 10) {
		number = number + 1;
		$(id).innerHTML = number;
		SetShopNumber(id, number);
	}
}
//将指定商品数量保存到cookie
function SetShopNumber(id, number) {
	xml = getCookie("shopinfo");

	xmlDoc = getXmldoc(xml);
	for (var i = 0; i < xmlDoc.getElementsByTagName("Table").length; i++) {
		if ('number' + xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("pid")[0].childNodes[0].nodeValue == id) {
			xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("number")[0].childNodes[0].nodeValue = number;
			break;
		}
	}
	if (isIE()) {
		setCookie("shopinfo", xmlDoc.documentElement.xml, 1);
	}
	else {
		str = serializeXml(xmlDoc.documentElement);
		setCookie("shopinfo", str, 1);

	}
	getShop();
}
function getShop() {
	if (document.URL.toLowerCase().indexOf("index") > -1 || document.URL.toLowerCase().indexOf("index") > -1 ||
        document.URL.toLowerCase().indexOf("woweuitemsshow") > -1 || document.URL.toLowerCase().indexOf("wowusitemsshow") > -1 ||
        document.URL.toLowerCase().indexOf("wowushotitems") > -1 || document.URL.toLowerCase().indexOf("wowushotitems") > -1) {
		GetShopInfo();
	}
	else {

		GetShopInfo_new();
	}
}



function isIE() { //ie? 
	if (window.navigator.userAgent.toLowerCase().indexOf("msie") >= 1)
		return true;
	else
		return false;
}

var isSerch = false;

function serch(selectType) {
	isSerch = true;
	var Professional = $F('drpProfessional');
	var itemsName = $F('itemsName');
	//    if (itemsName == null || itemsName == '') {
	//        itemsName = getCookie('key');
	//    }
	var minLavel = $F('minLavel');
	var maxLavel = $F('maxLavel');
	var gid = getCookie('gameId');
	var typeId = getCookie("clickid");
	var raidName = '';
	try {
		if ($('RaidList') != null && $('RaidList') != undefined) {
			raidName = $F('RaidList');
		}
	} catch (e)
    { }
	var url = '';
	if (parseInt(minLavel) >= parseInt(maxLavel)) {
		alert('the lowest level cannot be higher than the highest nor equal to the highest!');
		return;
	}
	if (Professional == "-1" && (itemsName == null || itemsName.replace(/(^\s*)|(\s*$)/g, "") == '') && (minLavel == null || minLavel == '') && (maxLavel == null || maxLavel == '') && (raidName == '' || raidName == '-1')) {
		alert('please input serch qualification !');
		return;
	}
	else {
		if (clickId != "1") {
			url = "/ashx/serch1.ashx?key=" + itemsName + "&min=" + minLavel + "&max=" + maxLavel + "&gid=" + gid + "&Professional=" + Professional + "&a=" + selectType + "&typeid=" + typeId + "&startNumber=" + currindex + "&number=" + pageRow + "&OrderType=" + getCookie('OrderType') + "&raidName=" + raidName;  //+ "&raind=" + new Date().getSeconds();

		}
		else {
			url = "/ashx/serch1.ashx?key=" + itemsName + "&min=" + minLavel + "&max=" + maxLavel + "&gid=" + gid + "&Professional=" + Professional + "&typeid=1&a=" + selectType + "&startNumber=" + currindex + "&number=" + pageRow + "&OrderType=" + getCookie('OrderType') + "&raidName=" + raidName;  //+ "&raind=" + new Date().getSeconds();
		}
	}
	if (selectType == "1") {
		var myAjax = new Ajax.Request(
                                        url,
                                        {
                                        	method: "get",
                                        	onComplete: ShowItems_new
                                        }
                                    );
		//setCookie("selectShopType", "", 1);
		//setCookie("key", "", 1);
	} else if (selectType == "0") {

		var myAjax = new Ajax.Request(
                                        url,
                                        {
                                        	method: "get",
                                        	onComplete: SetTotalTow_serch
                                        }
                                    );
	}
}

function serch_1() {
	var selectType = getCookie("selectShopType");
	var key = getCookie('key');
	$('itemsName').value = key;
	if (key == null || key == '' || key == ' ' || selectType == null || selectType == '' || selectType == ' ')
		return;
	var url = "/ashx/SerchAllTypeItems.ashx?key=" + key + "&OrderType=" + selectType;
	switch (selectType) {
		case "ITEM":
			serch('0');
			break;
		case "RAID":
			var myAjax = new Ajax.Request(
                                        url,
                                        {
                                        	method: "get",
                                        	onComplete: ShowItems_new
                                        }
                                    );
			break;
		case "PVP":
			var myAjax = new Ajax.Request(
                                        url,
                                        {
                                        	method: "get",
                                        	onComplete: ShowArenaget
                                        }
                                    );
			break;
		case "TIRE":
			var myAjax = new Ajax.Request(
                                        url,
                                        {
                                        	method: "get",
                                        	onComplete: ShowTIRE
                                        }
                                    );
			break;
		default:
			break;
	}
}


//设置所选择币种
function SetCurrency() {
	var a = document.getElementsByName("sex");
	if (a.length == 0)
		return;
	if (getCookie('rates') == '') {
		return;
	}
	switch (getMoneyType()) {
		case "$":
			a[0].checked = true;
			break;
		case "€":
			a[1].checked = true;
			break;
		case "£":
			a[2].checked = true;
			break;
		case "A$":
			a[3].checked = true;
			break;
		case "C$":
			a[4].checked = true;
			break;
	}
}


//联系在线客服
function clickImg() {
	if (win == null)
		win = window.open('http://67.228.234.126:8080/login.aspx?web=ignah', 'newWindow', 'width=600,height=521,center=yes,alwaysRaised=yes,location=no,menubar=no,resizable=yes,scrollbars=no');
	else {
		if (win.closed)
			win = window.open('http://67.228.234.126:8080/login.aspx?web=ignah', 'newWindow', 'width=600,height=521,center=yes,alwaysRaised=yes,location=no,menubar=no,resizable=yes,scrollbars=no');
		else
			win.focus();
	}
}

var win;

//获得contact消息
function ShowContact() {
	var url = "/ashx/contact.ashx";
	var myAjax = new Ajax.Request(
                                    url,
                                    {
                                    	method: "get",
                                    	onComplete: getcontact
                                    }
                                );
}
//显示contact消息
function getcontact(xmlhttp) {
	var temp = $('showMsg');
	temp.innerHTML = xmlhttp.responseText;
}

//获得about消息
function ShowAbout() {
	var url = "/ashx/about.ashx";
	var myAjax = new Ajax.Request(
                                    url,
                                    {
                                    	method: "get",
                                    	onComplete: getAbout
                                    }
                                );
}
//显示about消息
function getAbout(xmlhttp) {
	var temp = $('ShowAbout');
	temp.innerHTML = xmlhttp.responseText;
}
//设置每分钟获得一次当前时间
function StartShowTime() {
	setvisit();
	ShowTime();
	setInterval('ShowTime()', 60000);
}
//显示当前时间
function ShowTime() {
	now = new Date();
	$('showTime').innerHTML = now.toDateString() + ' ' + now.toTimeString().substring(0, 5);



}

//调用方法             onkeypress="money(this.value)"
//钱
function money(str) {
	var nc = event.keyCode;
	var s = str;
	if ((nc >= 48) && (nc <= 57)) {
		if (s.substring(0, 1) == "0" && s.indexOf('.') < 0) {
			event.keyCode = 0;
			return;
		}
		else {

			if (s.indexOf('.') > 0) {
				if (s.indexOf('.') < s.length - 4) {
					event.keyCode = 0; return;
				}
			}
		}
	} else if (nc == 46) {
		if (s.length < 1) {
			event.keyCode = 0; return;
		}
		for (var i = 0; i < s.length; i++) {
			if (s.charAt(i) == '.') {
				event.keyCode = 0; return;
			}
		}
	}
	else {
		event.keyCode = 0; return;
	}
}

function timeStyle(str) {
	var nc = event.keyCode;
	var s = str;
	if ((nc >= 48) && (nc <= 57)) {
		if (s.indexOf('.') > 0) {
			if (s.indexOf('.') < s.length - 2) {
				event.keyCode = 0; return;
			}

		}
	} else if (nc == 46) {
		if (s.length < 1) {
			event.keyCode = 0; return;
		}
		for (var i = 0; i < s.length; i++) {
			if (s.charAt(i) == '.') {
				event.keyCode = 0; return;
			}
		}
	}
	else {
		event.keyCode = 0; return;
	}
}

//禁用字符
function charuse() {
	if (event.keyCode == 124) {
		event.returnValue = false;
	}
}

//textarea最大长度
function maxtextarea(tb, len) {
	var tbvalue = tb.value;
	if (tbvalue.length >= len) {
		event.returnValue = false;
		alert("Over max words!");
	}
}

//读COOKIE
function getCookie(cookiename) {
	var result = '';
	var mycookie = document.cookie;
	var start2 = mycookie.indexOf(cookiename + "=");
	if (start2 > -1) {
		start = mycookie.indexOf("=", start2) + 1;
		var end = mycookie.indexOf(";", start);

		if (end == -1) {
			end = mycookie.length;
		}

		result = unescape(mycookie.substring(start, end));

	}
	return result;
}

//写入COOKIE
function setCookie(cookiename, cookievalue, hours) {
	var date = new Date();
	date.setTime(date.getTime() + Number(hours) * 3600 * 1000);
	temp = escape(cookievalue);
	document.cookie = cookiename + "=" + temp + "; path=/;expires = " + date.toGMTString();
	//var o = 0;
}

function QingChuCookie() {
	setCookie('selectShopType', ' ', 1);
	setCookie('key', ' ', 1);
}

//已经计算了用户优惠率
function changeRate(moneyvalue) {
	var rates = getCookie("rateValue");
	moneyvalue = Math.round(Number(moneyvalue) * getwebrate() * cusrate() * 100) / 100;

	if (rates == null || rates == "") {
		return moneyvalue;
	}
	var result;
	result = Math.round(Number(moneyvalue) * Number(rates) * 100) / 100;
	return result;
}

//没有计算用户优惠
function changeRate2(moneyvalue) {
	var rates = getCookie("rateValue");

	moneyvalue = Math.round(Number(moneyvalue) * 100) / 100;

	if (rates == null || rates == "") {
		return moneyvalue;
	}
	return Math.round(Number(moneyvalue) * Number(rates) * 100) / 100;
}

//当所选币种改变时调用
function changemoney(imoneytype) {
	var fuhao;
	switch (imoneytype) {
		case "USD":
			fuhao = "$";
			break;
		case "EUR":
			fuhao = "€";
			break;
		case "GBP":
			fuhao = "£";
			break;
		case "AUD":
			fuhao = "A$";
			break;
		case "CAD":
			fuhao = "C$";
			break;
		default:
			break;
	}

	setCookie("moneyType", fuhao, 1);
	setCookie("moneyType1", imoneytype, 3); //yun 币种
	var url = "/ashx/moneytype.ashx?moneytype=" + imoneytype;

	var myAjax = new Ajax.Request(
                                        url,
                                        {
                                        	method: "get",
                                        	onComplete: getrateDo_lx
                                        }
                                    );

}


function getrateDo_lx(xmlhttp) {
	var r = xmlhttp.responseText;
	if (isNaN(r)) {
		return;
	}
	setCookie("rateValue", r, 1); //设置汇率
	try {
		SetCurrency(); //设置币种选项
	} catch (e)
    { }
	try {
		if (document.URL.toLowerCase().indexOf("aionusitems") > -1 ||
         document.URL.toLowerCase().indexOf("aioneuitems") > -1 ||
         document.URL.toLowerCase().indexOf("wowusitems") > -1 ||
         document.URL.toLowerCase().indexOf("woweuitems") > -1 ||

         document.URL.toLowerCase().indexOf("wowpvp") > -1 ||
         document.URL.toLowerCase().indexOf("wowtirer") > -1 ||
         document.URL.toLowerCase().indexOf("raid") > -1 ||

         document.URL.toLowerCase().indexOf("aionusitems") > -1 ||
         document.URL.toLowerCase().indexOf("aioneuitems") > -1) {
			GetShopInfo_new();
		}
		else if (document.URL.toLowerCase().indexOf("checkbuy") > -1) {
			try {
				getBuyInfo(); //CheckBuy.html调用
				radi_bind();
			} catch (e)
            { }
		}

		else {
			GetShopInfo(); //获得购物车中商品信息
		}
	}
	catch (e)
    { }
	if (document.URL.toLowerCase().indexOf("wowusitemsshow") > -1 ||
    document.URL.toLowerCase().indexOf("woweuitemsshow") > -1) {
		try {
			GetItemsList(); //获得指定小类下的全部商品
		} catch (e)
        { }
	}
	if (document.URL.toLowerCase().indexOf("diymaterial") > -1) {
		try {
			GetAllSkillMaterials();
		} catch (e)
       { }
	}

	if (document.URL.toLowerCase().indexOf("wowushotitems") > -1 ||
    document.URL.toLowerCase().indexOf("woweuhotitems") > -1) {
		try {
			GetHotList();
		}
		catch (e) { }
	}
	if (document.URL.toLowerCase().indexOf("wowusitems") > -1 ||
     document.URL.toLowerCase().indexOf("woweuitems") > -1) {
		try {
			GetAllShopInfoById(-1); //获得所选大类下的全部商品信息
			showData();

		} catch (e)
        { }
	}
	if (document.URL.toLowerCase().indexOf("raid") > -1
    || document.URL.toLowerCase().indexOf("wowpvp") > -1
    || document.URL.toLowerCase().indexOf("wowtirer") > -1
    || document.URL.toLowerCase().indexOf("raidsuccess") > -1) {
		try {
			showData();
		}
		catch (e)
        { }
	}


	if (document.URL.toLowerCase().indexOf("raidwowitem") > -1) {
		try {
			Raidloadinfo();
		}
		catch (e)
        { }
	}
}

//数据对象
var Equipmentlist;

//change moneytype  获取货币类型
function getMoneyType() {
	var moneyType = getCookie("moneyType");
	if (moneyType == '')
		changemoney("USD");
	return moneyType;
}

function getserialpot() {
	var md = new Date();
	var year = md.getYear();
	year = year.toString();
	year = year.substring(2, 4);

	if (year.length == 1) {
		year = "0" + year;
	}

	var month = md.getMonth() + 1;
	if (month < 10) {
		month = "0" + month;
	}

	var day = md.getDate();
	if (day < 10) {
		day = "0" + day;
	}

	var s = "0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z";
	var arr = s.split(" ");

	var sn4 = "";
	while (sn4.length <= 3) {
		sn4 += arr[Math.round(Math.random() * 100) % 36];
	}
	return "UPI" + year + month + day + sn4 + "POT";
}
//web language
function getwebrate() {

	try {
		var language = "";

		if (document.all) {
			language = navigator.systemLanguage;
		}
		else {
			language = navigator.language;
		}

		if (language.toLowerCase() == "zh-cn") {
			//return 1.17;
			return 1;
		}
		else {
			return 1;
		}
	}
	catch (err) {
		return 1;
	}
}

//log rate
function cusrate() {
	var uinfo = getCookie("customerinfo");

	var rate = 1;
	try {
		if (uinfo != null && uinfo != '') {
			var arr = uinfo.split("|||");
			var r = parseFloat(arr[8]) / 100.0;

			rate = rate - r;
		}
	}
	catch (err) {

	}

	return rate;
}
function getmoneytype2() {
	var tp = getMoneyType();

	var result = "USD";

	if (tp == "$") {
		result = "USD";
	}
	else if (tp == "€") {
		result = "EUR";
	}
	else if (tp == "£") {
		result = "GBP";
	}
	else if (tp == "A$") {
		result = "AUD";
	}
	else if (tp == "C$") {
		result = "CAD";
	}
	return result;
}

//showrep
function showrep() {
	if ($("rad1").checked == true) {
		$("repddl").style.display = "none";
	}

	if ($("rad2").checked == true) {
		$("repddl").style.display = "";
	}
}

//getuid
function getuid() {
	var uid = 0;

	var uinfo = getCookie("customerinfo");

	if (uinfo != null) {
		var arr = uinfo.split("|||");
		uid = arr[0];
	}

	uid = parseInt(uid);

	if (uid == null || isNaN(uid)) {
		uid = 0;
	}
	uid = parseInt(uid);

	if (isNaN(uid)) {
		uid = 0;
	}
	return uid;
}

//huang hang
function hh() {
	var D = document;
	F(D.body);
	function F(n) {
		var u, r, c, x;
		if (n.nodeType == 3) {
			u = n.data.search(/\S{10}/);
			if (u >= 0) {
				r = n.splitText(u + 10);
				n.parentNode.insertBefore(D.createElement("WBR"), r);
			}
		}
		else if (n.tagName != "STYLE" && n.tagName != "SCRIPT") {
			for (c = 0; x = n.childNodes[c]; ++c) {
				F(x);
			}
		}
	}
}

//
function witerlivechat(xmlhttp) {

	var result = xmlhttp.responseText;

	if (result != null && result.length >= 1) {
		window.open("" + result + "");
	}
}

function openLiveChat(obj, mess) {
	var url = "/ashx/getlivechat.ashx";
	var myAjax = new Ajax.Request(
                    url,
                    {
                    	method: "get", onComplete: witerlivechat
                    }
      );
}




//get current url 
function getpagetype() {
	var cpage = window.location.href;
	var arr = cpage.split(".");
	var hz;
	if (arr.length == 0) {
		return "";
	}
	else {
		hz = arr[arr.length - 1].toLowerCase();
	}

	if (hz.indexOf("aspx") > 0) {
		return "aspx";
	}

	if (hz.indexOf("htm") > 0 && hz.indexOf("html") < 0) {
		return "htm";
	}

	if (hz.indexOf("html") > 0) {
		return "html";
	}
}
//open complaint page
function opencp() {
	var curl = "customer_complaint" + "." + getpagetype();
	curl = "customer_complaint.html"
	window.open(curl, "_self")
}

//customer points
function upoints() {
	var jifen = 0;

	var url = "/ashx/jifen.ashx?cid=" + getuid();

	var myAjax = new Ajax.Request(
                                        url,
                                        {
                                        	method: "get",
                                        	onComplete: getponitsdo0
                                        }
                                   );
}

function getponitsdo0(xmlhttp) {
	var jifen = xmlhttp.responseText;

	$("spjifen").innerHTML = jifen;

	if ($("spjifen2") != null) {
		$("spjifen2").innerHTML = jifen;
	}
}

//ws 2
function ws2(sz) {
	return Math.round(parseFloat(sz) * 100) / 100;
}

//jude login
function islogin() {
	if (getuid() == 0) {
		window.location.href = "/";
	}
}


//jude login
function checklogin() {
	if (getuid() == 0) {
		if ($("checklogin") != null) {
			$("checklogin").style.display = "";
			$("spbody").style.display = "none";
			if ($("k2serverlist") != null) {
				$("k2serverlist").style.display = "none";
			}
		}
	} else {
		if ($("checklogin") != null) {
			$("checklogin").style.display = "none";
			$("spbody").style.display = "";
			if ($("k2serverlist") != null) {
				$("k2serverlist").style.display = "";
			}
		}
	}
}

function Product() {
	this.pid = "";
	this.pname = "";
	this.pLevel = "-1";
	this.pbeizhu = "";
	this.purl = "";
	this.ptid = "";
	this.productserial = "";
	this.tid = "";
	this.productGames = "0";
	this.productServer = "0";
	this.productstock = "0";
	this.productPrice = "0";
	this.productTaskid = "0";
	this.cid = "0";
	this.sid = "0";
	this.beizhu = "";
	this.productDelivery = "";
	this.number = "0";

}

Array.prototype.remove = function (dx) {
	if (isNaN(dx) || dx > this.length) { return false; }
	for (var i = 0, n = 0; i < this.length; i++) {
		if (this[i] != this[dx]) {
			this[n++] = this[i]
		}
	}
	this.length -= 1
}

function GetObjPos(ATarget) {
	var target = ATarget;
	var pos = new CPos(target.offsetLeft, target.offsetTop);

	var target = target.offsetParent;
	while (target) {
		pos.x += target.offsetLeft;
		pos.y += target.offsetTop;

		target = target.offsetParent
	}

	return pos;
}
function SetDisplay(str) {
	$('showShopReamark').style.display = str;
}

function CPos(x, y) {
	this.x = x;
	this.y = y;
}
function showdiv(divtran, img) {
	var proc = GetObjPos(img);
	var wHeight = document.body.scrollHeight;
	var img1 = getDiv(img);
	var div = getDiv(divtran);
	if (proc.y + div.height > wHeight)
		divtran.style.top = (proc.y - div.height + img1.height) + "px";
	else
		divtran.style.top = proc.y + "px";
	divtran.style.left = (proc.x + 37) + "px";
}

function getDiv(element) {
	element = $(element);
	var display = $(element).getStyle('display');
	if (display != 'none' && display != null) // Safari bug
		return { width: element.offsetWidth, height: element.offsetHeight };

	// All *Width and *Height properties give 0 on elements with display none,
	// so enable the element temporarily
	var els = element.style;
	var originalVisibility = els.visibility;
	var originalPosition = els.position;
	var originalDisplay = els.display;
	els.visibility = 'hidden';
	els.position = 'absolute';
	els.display = 'block';
	var originalWidth = element.clientWidth;
	var originalHeight = element.clientHeight;
	els.display = originalDisplay;
	els.position = originalPosition;
	els.visibility = originalVisibility;
	return { width: originalWidth, height: originalHeight };
}



//game gold
function gamegold(gameid) {
	var url = "/ashx/getgamelist.ashx?gameid=" + gameid;


	var myAjax = new Ajax.Request(
                                    url,
                                    {
                                    	method: "get",
                                    	onComplete: kkserverlistadd
                                    }
                                );
}
function kkserverlistadd(xmlhttp) {
	var result = xmlhttp.responseXML;
	var getserverdll = $("drpServer");
	if (xmlhttp.responseText != "<NewDataSet />") {
		getserverdll.innerHTML = '';
		var pricelist = result.getElementsByTagName("Table");
		for (var i = 0; i < pricelist.length; i++) {
			var op = document.createElement("option");
			op.id = "sop" + i;
			var sname = pricelist[i].getElementsByTagName("serverName")[0].childNodes[0].nodeValue;
			var optext = sname;
			op.appendChild(document.createTextNode(optext));
			getserverdll.appendChild(op);
		}
		getSelectOption();
	}
}

function getpid() {
	var pid = getCookie("pid");

	if (pid == null || pid == "" || isNaN(pid)) {
		pid = "0";
		setCookie_kz("pid", "0", 2.0);
	}
	return pid;
}

function GetRequest() {
	var url = location.search; //获取url中"?"符后的字串   
	var strss = "?";
	if (url.indexOf("?") != -1) {
		var str = url.substr(1);
		strs = str.split("&");
		for (var i = 0; i < strs.length; i++) {
			strss += strs[i].split("=")[0] + "=" + strs[i].split("=")[1] + "&";
		}
	}
	if (strss == "?") {
		strss = "";
	}
	return strss;
}

function setvisit() {
	var pid = getpid();
	var uid = getuid();
	var refurl = document.referrer + GetRequest();
	var cururl = document.URL;

	if (refurl == null || refurl == "") {
		refurl = "";
	}

	//var url = "/ashx/visit.ashx?pid=" + pid + "&uid=" + uid + "&refurl=" + refurl + "&cururl=" + cururl;
	var url = "/ashx/visit.ashx?pid=" + pid + "&uid=" + uid + "&refurl=" + escape(refurl) + "&cururl=" + escape(cururl);
	var myAjax = new Ajax.Request(
                                    url,
                                    {
                                    	method: "get",
                                    	onComplete: setvisitdo
                                    }
                               );
}
function setvisitdo(xmlhttp) {
	var result = xmlhttp.responseText;

	if (getpid() == "0") {
		setCookie_kz("pid", result, 2.0);
	}
}

//domain=ignah.com;


//跨站写入COOKIE
function setCookie_kz(cookiename, cookievalue, hours) {
	var date = new Date();
	date.setTime(date.getTime() + Number(hours) * 3600 * 1000);
	temp = escape(cookievalue);
	document.cookie = cookiename + "=" + temp + "; path=/;expires = " + date.toGMTString() + "domain=upitems.com";
	//var o = 0;
}

function Auto(value) {
	if (value == "" || value.length < 3) {
		//        if ($("AjaxAutoCompleteDIV").style.display == "" &&
		//        innerHtml != "" &&
		//        innerHtml != "<table></table>") {
		$("AjaxAutoCompleteDIV").style.display = "none";
		//            showdiv_showAuto($("AjaxAutoCompleteDIV"), $('searchShopInput'));
		//}
		return;
	}
	$("ShowAutoComplete").innerHTML = "";
	var url = "/ashx/AjaxAutoComplete.ashx?key=" + value;
	var myAjax = new Ajax.Request(
                                    url,
                                    {
                                    	method: "get",
                                    	onComplete: GetAutoCompleteResult
                                    }
                               );
}
var innerHtml = "";
function GetAutoCompleteResult(xmlhttp) {
	if (xmlhttp.responseText != '<NewDataSet />') {
		var fuhao = "'";
		var xml = xmlhttp.responseXML;
		var Equipmentlist = xml.getElementsByTagName("Table");
		var length = Equipmentlist.length;
		var innerHtml = '<table>';

		for (var i = 0; i < length; i++) {
			orderType = Equipmentlist[i].getElementsByTagName("OrderType")[0].childNodes[0].nodeValue;
			productName = Equipmentlist[i].getElementsByTagName("pname")[0].childNodes[0].nodeValue;
			innerHtml += "<tr>";
			innerHtml += "<td onclick=\"javascript:SetSearchShopInputValue('" + productName.replace(fuhao, '\\\'') + "','" + orderType + "');\" onmouseover=\"javascript:AutoCompleteSelect(this);\" onmouseout=\"javascript:AutoCompleteUnSelect(this);\" id=\"AutoComplete_" + i + "\">" + productName + "</td>";
			innerHtml += "</tr>";
			innerHtml += "<tr>";
			innerHtml += "<td><input type='hidden' id='orderType_" + i + "' value='" + orderType + "' /></td>";
			innerHtml += "</tr>";
		}
		innerHtml += "</table>";
		if (innerHtml != "" &&
        innerHtml != "<table></table>") {
			$("ShowAutoComplete").innerHTML = innerHtml;
			if ($("AjaxAutoCompleteDIV").style.display == "none") {
				$("AjaxAutoCompleteDIV").style.display = "";
				showdiv_showAuto($("AjaxAutoCompleteDIV"), $('searchShopInput'));
			}
		}
		else {
			$("AjaxAutoCompleteDIV").style.display = "none";
		}
	}
}

function SetSearchShopInputValue(productName, orderType) {
	$('searchShopInput').value = productName;
	setCookie("selectShopType", orderType, 1);
	$("ShowAutoComplete").innerHTML = '';
	$("AjaxAutoCompleteDIV").style.display = "none";
	searchShop();

	//$('searchShopInput').focus();
}

function AutoCompleteSelect(span) {
	//span.style.backgroundColor = "#ccc";
	if (span != null && span != undefined) {
		span.style.color = "#ffff00";
		span.style.fontWeight = "bolder";
		span.style.cursor = "pointer";
	}
	//span.style.width = "143px";
}

function AutoCompleteUnSelect(span) {
	if (span != null && span != undefined) {
		span.style.backgroundColor = "";
		span.style.fontWeight = "";
		span.style.color = "";
	}
}

function showdiv_showAuto(divtran, img) {
	var proc = GetObjPos(img);
	var wHeight = document.body.scrollHeight;
	var img1 = getDiv(img);
	var div = getDiv(divtran);
	divtran.style.top = (proc.y + 19) + "px";
	divtran.style.left = proc.x + "px";
	divtran.style.height = "143px";
}

function HiddenDiv() {
	//$("AjaxAutoCompleteDIV").style.display = "none";
}

function searchShop() {


	var key = $F('searchShopInput');

	if (getCookie("key") == '') {

		if (key == '') {
			alert('please input keys!');
			$('searchShopInput').focus();
			return;
		}
		else {
			if (key.length < 3) {
				alert('Key length must be greater than 3!');
				$('searchShopInput').focus();
				return;
			}
		}
	}
	setCookie('key', key, 1);

	//setCookie('wowkey', key, 1);
	switch (getCookie("selectShopType")) {
		case "ITEM":
			$('searchShopInput').value = '';
			window.location = '/wowusitems/boe/';
			break;
		case "PVP":
			$('searchShopInput').value = '';
			window.location = '/wowusitems/pvp/';
			break;
		case "RAID":
			$('searchShopInput').value = '';
			window.location = '/wowusitems/raid/';
			break;
		case "TIRE":
			$('searchShopInput').value = '';
			window.location = '/wowusitems/tirer/';
			break;
		case "RIFTITEM":
			$('searchShopInput').value = '';
			window.location = '/riftitems/boe/';
			break;
		case "EDENITEM":
			$('searchShopInput').value = '';
			window.location = '/edenusitems/boe/';
			break;
		default:
			var url = "/ashx/GetItemType.ashx?key=" + key;
			var myAjax = new Ajax.Request(
                                    url,
                                    {
                                    	method: "get",
                                    	onComplete: GetItemTypeResult
                                    }
                               );
			break;
	}
	//    }
	//    if (gid == '11') {
	//        window.location = 'aionusitems.html';
	//        setCookie('aionkey', key, 1);
	//    }
	//window.location = 'search.html';
}

function GetItemTypeResult(xmlhttp) {
	if (xmlhttp.responseText != "") {
		$('searchShopInput').value = '';
		switch (xmlhttp.responseText) {
			//            case "ITEM": 
			//                window.location = '/wowusitems/BOE/'; 
			//                return; 
			//            case "PVP": 
			//                window.location = '/wowusitems/PVP/'; 
			//                return; 
			//            case "RAID": 
			//                window.location = '/wowusitems/RAID/'; 
			//                return; 
			//            case "TIRE": 
			//                window.location = '/wowusitems/TIRER/'; 
			//                return; 
			//            case "RIFTITEM": 
			//                window.location = '/riftitems/boe/'; 
			//                return; 
			//            case "EDENITEM": 
			//                window.location = '/edenusitems/BOE/'; 
			//                return;  
			case "ITEM":
				$('searchShopInput').value = '';
				window.location = '/wowusitems/boe/';
				return;
			case "PVP":
				$('searchShopInput').value = '';
				window.location = '/wowusitems/pvp/';
				return;
			case "RAID":
				$('searchShopInput').value = '';
				window.location = '/wowusitems/raid/';
				return;
			case "TIRE":
				$('searchShopInput').value = '';
				window.location = '/wowusitems/tirer/';
				return;
			case "RIFTITEM":
				$('searchShopInput').value = '';
				window.location = '/riftitems/boe/';
				return;
			case "EDENITEM":
				$('searchShopInput').value = '';
				window.location = '/edenusitems/boe/';
				return;
			default:
				break;
		}
	}
	alert('The item does not exist or your input is incomplete, please select or check the item in the dropdown list and try again.');
}

function clickItem(obj) {
	var id = document.activeElement.id;
	if (id != "searchShopInput") {
		$("AjaxAutoCompleteDIV").style.display = "none";
	}
}

function indexinit() {

	$('searchShopInput').focus();
}

function selectItem(obj) {
	var keyCode = null;
	//if (isIE()) {
	if (isIE) {
		keyCode = obj.keyCode;
	}
	else {
		keyCode = obj.which;
	}
	var id = document.activeElement.id;
	if (id == "searchShopInput") {
		switch (keyCode) {
			case 38: //上键
				if ($("AjaxAutoCompleteDIV").style.display == "" && $("ShowAutoComplete").innerHTML != "" &&
        $("ShowAutoComplete").innerHTML != "<table></table>") {
					a1("-");
				}
				break;
			case 40: //下键
				if ($("AjaxAutoCompleteDIV").style.display == "" && $("ShowAutoComplete").innerHTML != "" &&
        $("ShowAutoComplete").innerHTML != "<table></table>") {
					a1("+");
				}
				break;
			case 13: //回车
				if ($("AjaxAutoCompleteDIV").style.display == "" && $("ShowAutoComplete").innerHTML != "" &&
        $("ShowAutoComplete").innerHTML != "<table></table>" && sreachID >= 0) {
					var name = '';
					var orderType = '';
					var td_id = "AutoComplete_" + sreachID;
					if ($(td_id) != null && $(td_id) != undefined) {
						name = $(td_id).innerHTML;
						orderType = $("orderType_" + sreachID).value;
						sreachID = -1;
						SetSearchShopInputValue(name, orderType);
					}
				}
				break;
			default:
				break;
		}
	} else {
		$("AjaxAutoCompleteDIV").style.display = "none";
	}
}



function a1(brack) {
	var count = 0;
	for (var i = 0; ; i++) {
		var td_id = "AutoComplete_" + i;
		if ($(td_id) != null && $(td_id) != undefined) {
			index = i;
			AutoCompleteUnSelect($(td_id));
			count++;
		}
		else {
			break;
		}
	}

	if (brack == "-") {
		if (sreachID <= 0) {
			sreachID = count - 1;
		}
		else {
			sreachID--;
		}
	}
	else if (brack == "+") {
		if (sreachID >= count - 1) {
			sreachID = 0;
		}
		else {
			sreachID++;
		}
	}

	span = $("AutoComplete_" + sreachID);
	if (span != null && span != undefined) {
		AutoCompleteSelect(span);
	}
}


//newslist jump    
function goPage(obj) {
	var url = "/newslist/page/" + obj + "/";
	window.location.href = url;
}

function Esc_middleContent() {
	$('middleContent').style.display = "none";
}




function RaidaddProduct(id, typeId) {
	//    if($('checkoutId') != null && $('checkoutId') != undefined)
	//    {
	//        $('checkoutId').display = 'none';
	//    }

	xml = getCookie("shopinfo");
	//xml="";
	//xml="";

	xmlDoc = getXmldoc(xml);
	for (var i = 0; i < xmlDoc.getElementsByTagName("Table").length; i++) {
		if (xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("pid")[0].childNodes[0].nodeValue == id
            && xmlDoc.getElementsByTagName("Table")[i].getElementsByTagName("OrderType")[0].childNodes[0].nodeValue == getCookie('OrderType'))

			document.location = "checkbuy.html";
	}
	var temp = new Product(); //保存到对象变量
	temp.pid = id;
	temp.productPrice = $F('productPrice' + id);
	temp.number = 1;

	var ds = xmlDoc.documentElement;
	var root = xmlDoc.createElement('Table');
	xid = xmlDoc.createElement('pid');
	newtext = xmlDoc.createTextNode(temp.pid);
	xid.appendChild(newtext);
	root.appendChild(xid);

	xid = xmlDoc.createElement('productPrice');
	newtext = xmlDoc.createTextNode(temp.productPrice);
	xid.appendChild(newtext);
	root.appendChild(xid);

	xid = xmlDoc.createElement('TypeId');
	newtext = xmlDoc.createTextNode(typeId);
	xid.appendChild(newtext);
	root.appendChild(xid);

	xid = xmlDoc.createElement('GameId');
	newtext = xmlDoc.createTextNode(getCookie('gameId'));
	xid.appendChild(newtext);
	root.appendChild(xid);

	xid = xmlDoc.createElement('number');
	newtext = xmlDoc.createTextNode(temp.number);
	xid.appendChild(newtext);
	root.appendChild(xid);

	xid = xmlDoc.createElement('OrderType');
	newtext = xmlDoc.createTextNode(getCookie('OrderType'));
	xid.appendChild(newtext);
	root.appendChild(xid);


	ds.appendChild(root);
	if (isIE()) {
		setCookie("shopinfo", ds.xml, 1);
	}
	else {
		str = serializeXml(xmlDoc.documentElement);
		setCookie("shopinfo", str, 1);

	}

	//document.location = "checkbuy.html";
	document.location = "/checkbuy/";
	//getShop();
	//location = "#gouwuche";
}


function sett_div() {
	$('t_div').innerHTML = "<span id=\"transferringus\" class=\"test10\">" + getMoneyType() + "</span><span id=\"transferring\" class=\"test10\">" + changeRate(50) + "</span>";
}


function radi_bind() {
	$('t_div').innerHTML = "<span name=\"RadioButtonList\" id=\"rbtid\"  style=\"color:yellow\"><input type=\"radio\" checked=\"checked\" value=\"0\" name=\"rbtid\" id=\"rbtid_0\"><label for=\"rbtid_0\">" + getMoneyType() + " " + changeRate(0) + "</label><input type=\"radio\"value=\"25\" name=\"rbtid\" id=\"rbtid_1\"><label for=\"rbtid_1\">" + getMoneyType() + " " + changeRate(25) + "</label><input type=\"radio\" value=\"50\" name=\"rbtid\" id=\"rbtid_2\"><label for=\"rbtid_2\">" + getMoneyType() + " " + changeRate(50) + "</label><input type=\"radio\" value=\"75\" name=\"rbtid\" id=\"rbtid_3\"><label for=\"rbtid_3\">" + getMoneyType() + " " + changeRate(75) + "</label></span>"

}


function div_show(pbeizhu) {
	var divid = pbeizhu;
	document.getElementById("showBeiZhu").innerHTML = $F(divid);
}



