﻿// JScript 文件
function SenPaySafeCard() {
    //	if($("#amount").val().replace(" ","")=="0"||$("#amount").val().replace(" ","")=="0.00")
    //	{
    //		alert("Sie müssen nicht alles kaufen!");
    //		return false;
    //	}
    //	document.getElementById("btn_go1").innerHTML="<img src='/img/loading.gif' />";
    //	document.getElementById("btn_go2").innerHTML="<img src='/img/loading.gif' />";
    //	document.getElementById("btn_go3").innerHTML="<img src='/img/loading.gif' />";
    //	document.getElementById("btn_go4").innerHTML="<img src='/img/loading.gif' />";
    //alert("test");
    //return false;
    var v = "f";
    $.ajax(
	{
	    type: "post",
	    url: "/js/GoldHandler.ashx",
	    data: "ot=CheckOut&hell=hello",
	    success: function() {
	        alert("ok");
	        return false;
	    },
	    error: function() {
	        alert("error");
	        return false;
	    }
	});
    v;
    return false;
}


function SelectLaguage() {
    var url = "";
    var game_name = "";
    game_name = $("select[@name='LanguageSelect'] option[@selected]").text();

    if (game_name == "German") {
        url = "http://de.metin2.mobi";
    }
    else if (game_name == "Spanish") {
        url = "http://es.metin2.mobi";
    }
    else if (game_name == "French") {
        url = "http://fr.metin2.mobi";
    }
    else if (game_name == "Italian") {
        url = "http://it.metin2.mobi";
    }
    else if (game_name == "Polska") {
        url = "http://pl.metin2.mobi";
    }
    else {
        url = "http://www.metin2.mobi";
    }
    location.replace(url);
}

function SetLanguageCode(l_code) {
    $.ajax({
        type: "post",
        url: "/js/GoldHandler.ashx",
        data: "ot=SetLanguageCode&l_code=" + l_code,
        success: function(ResponseText) {
            location.replace("/");
        },
        error: function(ResponseText) {
            alert(ResponseText);
        }
    });
}

function GetAlert(name) {
    $.ajax({
        type: "post",
        url: "/js/GoldHandler.ashx",
        data: "ot=GetAlert&name=" + name,
        success: function(ResponseText) {
            ScreenConvert();

            var ShowDiv = "<div style=\"background:url(/img/smallbox-top.png) no-repeat top;margin-bottom:-3px; height:12px\"></div><div id='divShow' style=\"text-align:center; margin:0px;;padding:15px;background:url(/img/smallbox-bg.png) 0% 100%;\">" + ResponseText + "<br/><span style='text-align:center;padding:20px;'><input style='margin-left:74px;' class=\"btn-login\" type=\"button\" onclick=\"DialogHide();\" value=\" Confirm \"></span></div><div style=\"background:url(/img/smallbox-bottom.png) no-repeat bottom;margin-top:-3px;height:10px\"></div>";

            DialogShow(ShowDiv, 250, 120, 308, 120);
            jQuery("#DialogMove").draggable();
        },
        error: function(ResponseText) {
            alert(ResponseText);
        }
    });
}

function SendEmailToUs() {
    var user_email = $("#user_email").val();
    //alert(user_email);
    if (user_email == "") {
        GetAlert("EmailNotNull");
        $("#user_email").focus();
        return;
    }
    else {
        //add
        if (CheckSpecialChar(user_email)) {
            GetAlert("NotInvalidChar");
            $("#user_email").focus();
            return;
        }
        //

        //check email 
        var emailPat = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
        var matchArray = $("#user_email").val().match(emailPat);
        if (matchArray == null) {
            GetAlert("CorrectEmail");
            $("#user_email").val = "";
            $("#user_email").focus();
            return;
        }
    }

    $.ajax({
        type: "post",
        url: "/js/GoldHandler.ashx",
        data: "ot=AddUserEmail&email=" + user_email,
        success: function(ResponseText) {
            alert(ResponseText);
        },
        error: function() {
            alert(ResponseText);
        }
    });
}

function ModifyUserInformation() {
    var HtmlUserAlter = "<div style=\"background:url(/img/smallbox-top.png) 0% 100%;height:12px\"></div><div id='divInner'><iframe src='ModifyUserInformation.aspx' frameborder='0'  scrolling='no'width='308' height='220'></iframe></div><div style=\"background:url(/img/smallbox-bottom.png) 0% 100%;height:12px\"></div>"
    ScreenConvert();
    DialogShow(HtmlUserAlter, 350, 200, 308, 220);
    jQuery("#DialogMove").draggable({ handle: "#divInner" });
    //.draggable({ handle: "#divPopTitle"} );
}
function CloseNow() {
    parent.location.replace("checkout.html");
}
function ExecuteModify() {
    //验证名
    if ($("#FirstName").val() == "") {
        GetAlert("firstInputFullName");
        $("#FirstName").focus();
        return;
    }

    //add 
    var firstname = "";
    firstname = $("#FirstName").val();
    firstname = TrimString(firstname);
    if (firstname.length < 2) {
        GetAlert("firstBetween2to50");
        $("#FirstName").focus();
        return;
    }
    //	
    //验证姓
    if ($("#LastName").val() == "") {
        GetAlert("lastInputFullName");
        $("#LastName").focus();
        return;
    }

    //add 
    var lastname = "";
    lastname = $("#LastName").val();
    lastname = TrimString(lastname);
    if (lastname.length < 2) {
        GetAlert("lastBetween2to50");
        $("#LastName").focus();
        return;
    }
    //add 
    var u_email = $("#UserEmail").val();
    //
    if (u_email == "") {
        GetAlert("EmailNotNull");
        $("#UserEmail").focus();
        return;
    }
    else {
        //add
        if (CheckSpecialChar(u_email)) {
            GetAlert("NotInvalidChar");
            $("#UserEmail").focus();
            return;
        }
        //

        //check email 
        var emailPat = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
        var matchArray = $("#UserEmail").val().match(emailPat);
        if (matchArray == null) {
            GetAlert("CorrectEmail");
            $("#UserEmail").val = "";
            $("#UserEmail").focus();
            return;
        }
    }

    if ($("#ddlCountry").val() == "0") {
        GetAlert("ChooseContry");
        return;
    }

    var tel_no1 = $("#TelNo1").val();
    tel_no1 = TrimString(tel_no1);
    if (tel_no1 == "") {
        GetAlert("InputTel");
        $("#TelNo1").focus();
        return;
    }
    if (CheckSpecialChar(tel_no1)) {
        GetAlert("NotInvalidChar");
        $("#TelNo1").focus();
        return;
    }
    if (isNaN(tel_no1)) {
        GetAlert("TelMustBeInt");
        $("#TelNo1").focus();
        return;
    }
    var tel_no2 = $("#TelNo2").val();
    tel_no2 = TrimString(tel_no2);
    if (tel_no2 == "") {
        GetAlert("InputTel");
        $("#TelNo2").focus();
        return;
    }
    if (CheckSpecialChar(tel_no2)) {
        GetAlert("NotInvalidChar");
        $("#TelNo2").focus();
        return;
    }
    if (isNaN(tel_no2)) {
        GetAlert("TelMustBeInt");
        $("#TelNo2").focus();
        return;
    }
    var u_remark = $("#UserRemark").val();
    if (CheckSpecialChar(u_remark)) {
        GetAlert("NotInvalidChar");
        $("#UserRemark").focus();
        return;
    }
    if (u_remark.length > 500) {
        GetAlert("LessThan500");
        $("#UserRemark").focus();
        return;
    }

    //start
    //新增姓名详细统计.分别统计姓和名在拼接传入数据库
    //BY:2009-10-12
    //Cedrus
    var first_name = $("#FirstName").val();
    var last_name = $("#LastName").val();
    var user_name = first_name + "|" + last_name;
    //end
    var user_email = $("#UserEmail").val();
    var user_tel = $("#tel_type").val() + $("#TelNo1").val() + "-" + $("#TelNo2").val();
    var user_remark = $("#UserRemark").val();
    var country = $("#ddlCountry").val();

    $.ajax({
        type: "post",
        url: "/js/GoldHandler.ashx",
        data: "ot=update_user_information&user_name=" + user_name + "&user_email=" + user_email + "&user_tel=" + user_tel + "&user_remark=" + user_remark + "&user_country=" + country,
        success: function() {
            parent.location.replace("checkout.html");
        },
        error: function() {
            DialogHide();
        }
    });
}

function get_gold_html_list() {
    var game_id = $("#ddlGame").val();
    var server_id = $("#ddlServer").val();
    var fraction_id = $("#ddlFraction").val();
    $.ajax({
        type: "post",
        url: "/js/GoldHandler.ashx",
        data: "ot=get_gold_price_list&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id,
        success: function(msg) {
            document.getElementById("gold_price_list").innerHTML = msg;
        },
        error: function() {
            alert("error!");
        }
    });
}

function order_no_search_onclick() {

    var order_no = $("#order_no").val();
    if (CheckSpecialChar(order_no)) {
        GetAlert("NotInvalidChar");
        $("#order_no").focus();
        return;
    }
    order_no = order_no.replace(" ", "");
    //alert(order_no);
    $.ajax({
        type: "post",
        url: "/js/GoldHandler.ashx",
        data: "ot=get_order&order_no=" + order_no,
        success: function(msg) {
            ScreenConvert();

            var ShowDiv = "<div style=\"background:url(/img/smallbox-top.png) no-repeat top;margin-bottom:-3px; height:12px\"></div><div id='divShow' style=\"margin:0px;padding:10px;background:url(/img/smallbox-bg.png) 0% 100%;\">" + msg + "<br/><span style='text-align:center'><input style='margin-left:62px;' class=\"btn-login\" type=\"button\" onclick=\"DialogHide();\" value=\" Confirm \"></span></div><div style=\"background:url(/img/smallbox-bottom.png) no-repeat bottom;margin-top:-3px;height:10px\"></div>";

            DialogShow(ShowDiv, 250, 120, 308, 120);
            jQuery("#DialogMove").draggable();
        },
        error: function() {
            GetAlert("AlertError");
        }
    });
}

function SendPaypal() {
    if ($("#amount").val().replace(" ", "") == "0" || $("#amount").val().replace(" ", "") == "0.00") {
        alert("Sie müssen nicht alles kaufen!");
        return;
    }
    document.getElementById("btn_go1").innerHTML = "<img src='/img/loading.gif' />";
    document.getElementById("btn_go2").innerHTML = "<img src='/img/loading.gif' />";
    document.getElementById("btn_go3").innerHTML = "<img src='/img/loading.gif' />";
    document.getElementById("btn_go4").innerHTML = "<img src='/img/loading.gif' />";

    if (document.getElementById("Span1") != null) {
        document.getElementById("Span1").innerHTML = "<img src='/img/loading.gif' />";
    }
    $.ajax(
	{
	    type: "post",
	    url: "/js/GoldHandler.ashx",
	    data: "ot=CheckOut&hell=hello",
	    success: function() {
	        $("#aspnetForm").attr("action", "https://www.paypal.com/cgi-bin/webscr").submit();
	    },
	    error: function() {
	        $("#aspnetForm").attr("action", "https://www.paypal.com/cgi-bin/webscr").submit();
	    }
	});

}

//MoneyBookersJavaScript.
function SendMoneyBookers() {

    if ($("#amount").val().replace(" ", "") == "0" || $("#amount").val().replace(" ", "") == "0.00") {
        alert("Sie müssen nicht alles kaufen!");
        return;
    }
    document.getElementById("btn_go1").innerHTML = "<img src='/img/loading.gif' />";
    document.getElementById("btn_go2").innerHTML = "<img src='/img/loading.gif' />";
    document.getElementById("btn_go3").innerHTML = "<img src='/img/loading.gif' />";
    document.getElementById("btn_go4").innerHTML = "<img src='/img/loading.gif' />";
    if (document.getElementById("Span5") != null) {
        document.getElementById("Span5").innerHTML = "<img src='/img/loading.gif' />";
    }
    if (document.getElementById("Span6") != null) {
        document.getElementById("Span6").innerHTML = "<img src='/img/loading.gif' />";
    }
    $.ajax(
	{
	    type: "post",
	    url: "/js/GoldHandler.ashx",
	    data: "ot=CheckOut&hell=hello",
	    success: function() {
	    $("#aspnetForm").attr("action", "https://www.moneybookers.com/app/payment.pl").submit();
	    },
	    error: function() {
	    $("#aspnetForm").attr("action", "https://www.moneybookers.com/app/payment.pl").submit();
	    }
	});

}


function AddCDkeyToCar() {
    var cdkey_id = "";
    for (var i = 0; i < document.getElementsByName("cdkey_id").length; i++) {
        if (document.getElementsByName("cdkey_id")[i].checked == true) {
            cdkey_id = document.getElementsByName("cdkey_id")[i].value;
        }
    }
    if (cdkey_id == "") {
        GetAlert("ChooLessThanOne");
        return;
    }

    var price = document.getElementById("cdkey_price" + cdkey_id).innerHTML;


    //user infor
    var user_infor_display = document.getElementById("ctl00_ContentPlaceHolder1_userInformation").style.display;
    if (user_infor_display == "none") {
        var user_name = "";
        var user_email = "";
        var user_tel = "";
        var user_remark = "";
        var country = "";
    }
    else {
        if ($("#UserName").val() == "") {
            GetAlert("InputFullName");
            $("#UserName").focus();
            return;
        }

        //add 
        var u_name = "";
        u_name = $("#UserName").val();
        u_name = TrimString(u_name);
        if (u_name.length < 2) {
            GetAlert("Between2to50");
            $("#UserName").focus();
            return;
        }
        if (CheckSpecialChar(u_name)) {
            GetAlert("NotInvalidChar");
            $("#UserName").focus();
            return;
        }
        //	

        //add 
        var u_email = $("#UserEmail").val();
        //
        if (u_email == "") {
            GetAlert("EmailNotNull");
            $("#UserEmail").focus();
            return;
        }
        else {
            //add
            if (CheckSpecialChar(u_email)) {
                GetAlert("NotInvalidChar");
                $("#UserEmail").focus();
                return;
            }
            //

            //check email 
            var emailPat = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
            var matchArray = $("#UserEmail").val().match(emailPat);
            if (matchArray == null) {
                GetAlert("CorrectEmail");
                $("#UserEmail").val = "";
                $("#UserEmail").focus();
                return;
            }
        }

        if ($("#ddlCountry").val() == "0") {
            GetAlert("ChooseContry");
            return;
        }

        var tel_no1 = $("#TelNo1").val();
        tel_no1 = TrimString(tel_no1);
        if (tel_no1 == "") {
            GetAlert("InputTel");
            $("#TelNo1").focus();
            return;
        }
        if (CheckSpecialChar(tel_no1)) {
            GetAlert("NotInvalidChar");
            $("#TelNo1").focus();
            return;
        }
        if (isNaN(tel_no1)) {
            GetAlert("TelMustBeInt");
            $("#TelNo1").focus();
            return;
        }
        var tel_no2 = $("#TelNo2").val();
        tel_no2 = TrimString(tel_no2);
        if (tel_no2 == "") {
            GetAlert("InputTel");
            $("#TelNo2").focus();
            return;
        }
        if (CheckSpecialChar(tel_no2)) {
            GetAlert("NotInvalidChar");
            $("#TelNo2").focus();
            return;
        }
        if (isNaN(tel_no2)) {
            GetAlert("TelMustBeInt");
            $("#TelNo2").focus();
            return;
        }
        var u_remark = $("#UserRemark").val();
        if (CheckSpecialChar(u_remark)) {
            GetAlert("NotInvalidChar");
            $("#UserRemark").focus();
            return;
        }
        if (u_remark.length > 500) {
            GetAlert("LessThan500");
            $("#UserRemark").focus();
            return;
        }

        //		if(document.getElementById("YesItem").checked==false)
        //		{
        //			alert("Sie müssen sich mit dem AGB einverstanden erklären");
        //			return;
        //		}
        var user_name = $("#UserName").val();
        var user_email = $("#UserEmail").val();
        var user_tel = $("#tel_type").val() + $("#TelNo1").val() + "-" + $("#TelNo2").val();
        var user_remark = $("#UserRemark").val();
        var country = $("#ddlCountry").val();
    }

    //end userinfor	//end user infor
    //
    $.ajax({
        type: "post",
        url: "/js/GoldHandler.ashx",
        data: "ot=add_cdkey_car&cdkey_id=" + cdkey_id + "&cdkey_price=" + price + "&user_name=" + user_name + "&user_email=" + user_email + "&user_tel=" + user_tel + "&user_remark=" + user_remark + "&user_country=" + country,
        success: function(msg) {
            if (parseInt(msg) > 0) {
                location.replace("checkout.aspx");
            }
        },
        error: function(msg) {
            GetAlert("AlertError");
        }
    });
}

function AddPLToCar() {
    var game_id = $("#ddlGame").val();
    var server_id = $("#ddlServer").val();
    var fraction_id = $("#ddlFraction").val();
    var start_level = $("#StartLevel").val();
    var end_level = $("#EndLevel").val();
    var character_name = $("#CharacterName").val();
    var delivery_method = $("#delivery_method").val();
    var need_time = document.getElementById("NeedTime").innerHTML.replace("Hours", "").replace("Stunden", "").replace("hora(s)", "").replace("Godzin", "").replace("Heures", "").replace("Horas", "").replace("Saat", "").replace("De ore", "").replace("Ώρες", "").Trim();
    var need_price = document.getElementById("TotalPrice").innerHTML.replace("€", "").replace("￡", "").replace("$", "").replace("zł", "").replace("PLZ", "").replace("EUR", "").replace("USD", "").replace("GBP", "").replace("Leu", "").Trim();
    var hello = "ot=add_pl&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&start_level=" + start_level + "&end_level=" + end_level + "&character_name=" + character_name + "&need_time=" + need_time + "&need_price=" + need_price;

    //pl infor
    //	var euCountryType="none";//document.getElementById("ctl00_ContentPlaceHolder1_euCountryType");
    //	if(euCountryType.style.display=="none")
    //	{
    //		//alert("meiyou ");
    //	}
    //	else
    //	{
    //		var CountyType=document.getElementsByName("CountyType");
    //		var flag="false";
    //		for(var i=0;i<CountyType.length;i++)
    //		{
    //			if(CountyType[i].checked)
    //			{
    //				flag="true";
    //			}
    //		}
    //		if(flag=="false")
    //		{
    //			//alert("Please Select County!");
    //			//return;
    //		}
    //	}


    if ($("#ddlServer").val() == "0") {
        GetAlert("ChooseServer");
        return;
    }

    var tempPrice = /^[0-9]+.?[0-9]*$/;
    if (!tempPrice.test(document.getElementById("TotalPrice").innerHTML.replace("€", "").replace("￡", "").replace("$", "").replace("zł", "").replace("PLZ", "").replace("EUR", "").replace("USD", "").replace("GBP", "").replace("Leu", "").Trim())) {
        GetAlert("ChooseCorrectLevel");
        return;
    }

    var start_level = $("#StartLevel").val();
    var end_level = $("#EndLevel").val();
    if (parseInt(start_level) >= parseInt(end_level)) {
        GetAlert("ChooseCorrectLevel");
        return;
    }

    if (need_time == "0") {
        GetAlert("ChooseCorrectLevel");
        return;
    }

    if ($("#CharacterName").val() == "") {
        GetAlert("CorrectCharacterName");
        $("#CharacterName").focus();
        return;
    }
    var c_name = $("#CharacterName").val();
    c_name = TrimString(c_name);
    if (c_name.length < 2) {
        GetAlert("CorrectCharacterName");
        $("#CharacterName").focus();
        return;
    }
    if (CheckSpecialChar(c_name)) {
        GetAlert("NotInvalidChar");
        $("#CharacterName").focus();
        return;
    }
    //end gold infor

    //user infor
    var user_infor_display = ""; //document.getElementById("ctl00_ContentPlaceHolder1_userInformation").style.display;
    if (user_infor_display == "none") {
        var user_name = "";
        var user_email = "";
        var user_tel = "";
        var user_remark = "";
        var country = "";
    }
    else {
        //验证名
        if ($("#FirstName").val() == "") {
            GetAlert("firstInputFullName");
            $("#FirstName").focus();
            return;
        }

        //add 
        var firstname = "";
        firstname = $("#FirstName").val();
        firstname = TrimString(firstname);
        if (firstname.length < 2) {
            GetAlert("firstBetween2to50");
            $("#FirstName").focus();
            return;
        }
        //	
        //验证姓
        if ($("#LastName").val() == "") {
            GetAlert("lastInputFullName");
            $("#LastName").focus();
            return;
        }

        //add 
        var lastname = "";
        lastname = $("#LastName").val();
        lastname = TrimString(lastname);
        if (lastname.length < 2) {
            GetAlert("lastBetween2to50");
            $("#LastName").focus();
            return;
        }
        //	

        //add 
        var u_email = $("#UserEmail").val();
        //
        if (u_email == "") {
            GetAlert("EmailNotNull");
            $("#UserEmail").focus();
            return;
        }
        else {
            //add
            if (CheckSpecialChar(u_email)) {
                GetAlert("NotInvalidChar");
                $("#UserEmail").focus();
                return;
            }
            //

            //check email 
            var emailPat = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
            var matchArray = $("#UserEmail").val().match(emailPat);
            if (matchArray == null) {
                GetAlert("CorrectEmail");
                $("#UserEmail").val = "";
                $("#UserEmail").focus();
                return;
            }
        }

        if ($("#ddlCountry").val() == "0") {
            GetAlert("ChooseContry");
            return;
        }

        var tel_no1 = $("#TelNo1").val();
        tel_no1 = TrimString(tel_no1);
        if (tel_no1 == "") {
            GetAlert("InputTel");
            $("#TelNo1").focus();
            return;
        }
        if (CheckSpecialChar(tel_no1)) {
            GetAlert("NotInvalidChar");
            $("#TelNo1").focus();
            return;
        }
        if (isNaN(tel_no1)) {
            GetAlert("TelMustBeInt");
            $("#TelNo1").focus();
            return;
        }
        var tel_no2 = $("#TelNo2").val();
        tel_no2 = TrimString(tel_no2);
        if (tel_no2 == "") {
            GetAlert("InputTel");
            $("#TelNo2").focus();
            return;
        }
        if (CheckSpecialChar(tel_no2)) {
            GetAlert("NotInvalidChar");
            $("#TelNo2").focus();
            return;
        }
        if (isNaN(tel_no2)) {
            GetAlert("TelMustBeInt");
            $("#TelNo2").focus();
            return;
        }

        //alter by hetianxu 20090520
        //add post code
        var post_code = $("#txtPostCode").val();
        //alert(post_code);
        if (post_code == "") {
            GetAlert("AlertPostCodeBeInt");
            $("#txtPostCode").focus();
            return;
        }
        if (CheckSpecialChar(post_code)) {
            GetAlert("NotInvalidChar");
            $("#txtPostCode").focus();
            return;
        }
        //		if(isNaN(post_code))
        //		{
        //			GetAlert("AlertPostCodeBeInt");
        //			$("#txtPostCode").focus();
        //			return;
        //		}
        //end alter
        //alter by htx 20090522
        //add city and cityDistance
        var city_distance = $("#txtCity").val();
        //alert(post_code);
        if (city_distance == "") {
            GetAlert("AlertCityNotNull");
            $("#txtPostCode").focus();
            return;
        }
        if (CheckSpecialChar(city_distance)) {
            GetAlert("NotInvalidChar");
            $("#txtCity").focus();
            return;
        }
        city_distance = city_distance + "|" + $("#hcityDistance").val();
        post_code = post_code + "|" + city_distance;
        //alert(post_code);
        //end

        var u_remark = $("#UserRemark").val();
        if (CheckSpecialChar(u_remark)) {
            GetAlert("NotInvalidChar");
            $("#UserRemark").focus();
            return;
        }
        if (u_remark.length > 500) {
            GetAlert("LessThan500");
            $("#UserRemark").focus();
            return;
        }

        //		if(document.getElementById("YesItem").checked==false)
        //		{
        //			alert("Sie müssen sich mit dem AGB einverstanden erklären");
        //			return;
        //		}
        //start
        //新增姓名详细统计.分别统计姓和名在拼接传入数据库
        //BY:2009-10-12
        //Cedrus
        var first_name = $("#FirstName").val();
        var last_name = $("#LastName").val();
        var user_name = first_name + "|" + last_name;
        //end
        var user_email = $("#UserEmail").val();
        var user_tel = $("#tel_type").val() + $("#TelNo1").val() + "-" + $("#TelNo2").val();
        var user_remark = $("#UserRemark").val();
        var country = $("#ddlCountry").val();
        var account = $("#AccountName").val(); //获取账号名
        var password = $("#Password").val();   //获取账号密码
        var msn = $("#MSN").val();
        //alert(game_id); 
    }

    $.ajax({
        type: "post",
        url: "/js/GoldHandler.ashx",
        data: "ot=getplp&game_id=" + game_id + "&level_start=" + start_level + "&level_end=" + end_level,
        success: function(msg) {
            //alert(msg);
            //var pric=msg.split("/");
            need_price = msg.toString().replace("€", "").replace("￡", "").replace("$", "").replace("zł", "").replace("PLZ", "").replace("EUR", "").replace("USD", "").replace("GBP", "").replace("Leu", "").Trim();
            //need_price = need_price.innerHTML.replace("€","").replace("￡","").replace("$","").replace("zł","").replace("PLZ","").replace("EUR","").replace("USD","").replace("GBP","")
            //alert(need_price);

            $.ajax({
                type: "post",
                url: "/js/GoldHandler.ashx",
                data: "ot=add_pl&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&start_level=" + start_level + "&end_level=" + end_level + "&character_name=" + character_name + "&need_time=" + need_time + "&need_price=" + need_price + "&user_name=" + user_name + "&user_email=" + user_email + "&user_tel=" + user_tel + "&user_remark=" + user_remark + "&user_country=" + country + "&delivery_method=" + delivery_method + "&post_code=" + post_code + "&user_account=" + account + "&user_password=" + password + "&msn=" + msn,
                success: function(msg) {
                    if (parseInt(msg) > 0) {
                        location.replace("checkout.aspx");
                    }
                },
                error: function(msg) {
                    GetAlert("AlertError");
                }
            });
        },
        error: function(msg) {
            GetAlert("AlertError");
            return;
        }
    });

}
/*gold*/
function selectLevel() {
    var start_level = $("#StartLevel").val();
    var end_level = $("#EndLevel").val();
    if (parseInt(start_level) >= parseInt(end_level)) {
        document.getElementById("NeedTime").innerHTML = '0';
        document.getElementById("TotalPrice").innerHTML = '0.00';
        return;
    }
    var game_id = $("#ddlGame").val();
    var params = "&game_id=" + game_id + "&level_start=" + start_level + "&level_end=" + end_level;

    getHTMLtoRegionalRole("getplt", params, 'NeedTime');
    getHTMLtoRegionalRole("getplp", params, 'TotalPrice');
}


function getHTMLtoRegionalRole(ot, params, rid) {

    $.ajax({
        type: "post",
        url: "/js/GoldHandler.ashx",
        data: "ot=" + ot + params,
        success: function(transport) {
            document.getElementById(rid).innerHTML = transport;
            return;
        },
        error: function() {
            GetAlert("AlertError");
            return;
        }
    });
}

function removeOrder(id, type) {
    var ot = "delplcart";
    var oid = "plid";
    if (type == "gold") {
        ot = "delgcart";
        oid = "gid";
    }
    else if (type == "soft") {
        ot = "delscart";
        oid = "sid";
    }
    $.ajax({
        type: "post",
        url: "ajax.aspx",
        data: "ot=" + ot + "&" + oid + "=" + id,
        success: function(transport) {
            var rp = transport.responseText;
            if (rp == 'true') {
                document.location.reload();
            }
            document.location.reload();
            return;
        },
        error: function(transport) {
            document.location.reload();
            return;
        }
    });
}

function GameChange() {
    var url = "";
    var game_name = "";
    game_name = $("select[@name='ddlGame'] option[@selected]").text();

    url = "metin2-yang-" + game_name.replace(/( )/g, "-").toLowerCase().replace("metin2-", "") + ".html"
    location.replace(url);
}

function PLGameChange() {
    var url = "";
    var game_name = "";

    game_name = $("select[@name='ddlGame'] option[@selected]").text();

    url = "metin2-power-leveling-" + game_name.replace(/( )/g, "-").toLowerCase().replace("metin2-", "") + ".html"
    location.replace(url);
}
String.prototype.Trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
function CdKeyGameChange() {
    var url = "";
    var game_name = "";
    if (parseInt($("#ddlGame").val()) > 58) {
        game_name = $("select[@name='ddlGame'] option[@selected]").text();
    }
    else {
        game_name = "world-of-warcraft-eu";
    }
    game_name = game_name.Trim();
    url = game_name.replace(/( )/g, "-").toLowerCase() + "-cd-key-gametime-card.html"
    //alert($("select[@name='ddlGame'] option[@selected]").value);
    if ($("#ddlGame").val() == "80") {
        url = game_name.replace(/( )/g, "-").toLowerCase() + "-card.html"
    }
    location.replace(url);
}


function AddToCar() {
    //gold infor
    //	var euCountryType=document.getElementById("ctl00_ContentPlaceHolder1_euCountryType");
    //	if(euCountryType.style.display=="none")
    //	{
    //		//alert("meiyou ");
    //	}
    //	else
    //	{
    //		var CountyType=document.getElementsByName("CountyType");
    //		var flag="false";
    //		for(var i=0;i<CountyType.length;i++)
    //		{
    //			if(CountyType[i].checked)
    //			{
    //				flag="true";
    //			}
    //		}
    //		if(flag=="false")
    //		{
    //			//alert("Region Auswählen!");
    //			//return;
    //		}
    //	}

    if ($("#ddlServer").val() == "0") {
        GetAlert("ChooseServer");
        return;
    }
    if ($("#ddlAmount").val() == "0") {
        GetAlert("ChooseAmount");
        return;
    }
    var tempPrice = /^[0-9]+.?[0-9]*$/;
    if (!tempPrice.test(document.getElementById("TotalPrice").innerHTML.replace("€", "").replace("￡", "").replace("$", "").replace("zł", "").replace("PLZ", "").replace("EUR", "").replace("USD", "").replace("GBP", "").replace("Leu", "").Trim())) {
        GetAlert("PleaseConfirm");
        return;
    }
    if (document.getElementById("TotalPrice").innerHTML.replace("€", "").replace("￡", "").replace("$", "").replace("zł", "").replace("PLZ", "").replace("EUR", "").replace("USD", "").replace("GBP", "").replace("Leu", "").Trim() == "0") {
        GetAlert("PleaseConfirm");
        return;
    }
    if ($("#CharacterName").val() == "") {
        GetAlert("CorrectCharacterName");
        $("#CharacterName").focus();
        return;
    }
    var c_name = $("#CharacterName").val();
    c_name = TrimString(c_name);
    if (c_name.length < 2) {
        GetAlert("CorrectCharacterName");
        $("#CharacterName").focus();
        return;
    }
    if (CheckSpecialChar(c_name)) {
        GetAlert("NotInvalidChar");
        $("#CharacterName").focus();
        return;
    }

    //Cesc Add
    var buyTypeTemp = $("#delivery_method").val();
    var checkedSize = $("#red:checked").size();
    if (buyTypeTemp == "2") {
        if (checkedSize == 1) {
            var checkAccountname = $("#Accountname").val();
            var checkAPwd = $("#password").val();
            if (checkAccountname == "") {
                GetAlert("NotAccountname");
                $("#Accountname").focus();
                return;
            }
            if (checkAPwd == "") {
                GetAlert("Notpassword");
                $("#password").focus();
                return;
            }
        }
    }
    //end gold infor

    //user infor
    //user infor
    var user_infor_display = "display"; //document.getElementById("ctl00_ContentPlaceHolder1_userInformation").style.display;
    if (user_infor_display == "none") {
        var user_name = "";
        var user_email = "";
        var user_tel = "";
        var user_remark = "";
        var country = "";
    }
    else {

        //验证名
        if ($("#FirstName").val() == "") {
            GetAlert("firstInputFullName");
            $("#FirstName").focus();
            return;
        }

        //add 
        var firstname = "";
        firstname = $("#FirstName").val();
        firstname = TrimString(firstname);
        if (firstname.length < 2) {
            GetAlert("firstBetween2to50");
            $("#FirstName").focus();
            return;
        }
        //	
        //验证姓
        if ($("#LastName").val() == "") {
            GetAlert("lastInputFullName");
            $("#LastName").focus();
            return;
        }



        //add 
        var lastname = "";
        lastname = $("#LastName").val();
        lastname = TrimString(lastname);
        if (lastname.length < 2) {
            GetAlert("lastBetween2to50");
            $("#LastName").focus();
            return;
        }
        //	

        //add 
        var u_email = $("#UserEmail").val();
        //
        if (u_email == "") {
            GetAlert("EmailNotNull");
            $("#UserEmail").focus();
            return;
        }
        else {
            //add
            if (CheckSpecialChar(u_email)) {
                GetAlert("NotInvalidChar");
                $("#UserEmail").focus();
                return;
            }
            //

            //check email 
            var emailPat = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
            var matchArray = $("#UserEmail").val().match(emailPat);
            if (matchArray == null) {
                GetAlert("CorrectEmail");
                $("#UserEmail").val = "";
                $("#UserEmail").focus();
                return;
            }
        }

        if ($("#ddlCountry").val() == "0") {
            GetAlert("ChooseContry");
            return;
        }

        var tel_no1 = $("#TelNo1").val();
        tel_no1 = TrimString(tel_no1);
        if (tel_no1 == "") {
            GetAlert("InputTel");
            $("#TelNo1").focus();
            return;
        }
        if (CheckSpecialChar(tel_no1)) {
            GetAlert("NotInvalidChar");
            $("#TelNo1").focus();
            return;
        }
        if (isNaN(tel_no1)) {
            GetAlert("TelMustBeInt");
            $("#TelNo1").focus();
            return;
        }
        var tel_no2 = $("#TelNo2").val();
        tel_no2 = TrimString(tel_no2);
        if (tel_no2 == "") {
            GetAlert("InputTel");
            $("#TelNo2").focus();
            return;
        }
        if (CheckSpecialChar(tel_no2)) {
            GetAlert("NotInvalidChar");
            $("#TelNo2").focus();
            return;
        }
        if (isNaN(tel_no2)) {
            GetAlert("TelMustBeInt");
            $("#TelNo2").focus();
            return;
        }

        //alter by hetianxu 20090520
        //add post code
        var post_code = $("#txtPostCode").val();
        //alert(post_code);
        if (post_code == "") {
            GetAlert("AlertPostCodeBeInt");
            $("#txtPostCode").focus();
            return;
        }
        if (CheckSpecialChar(post_code)) {
            GetAlert("NotInvalidChar");
            $("#txtPostCode").focus();
            return;
        }
        //		if(isNaN(post_code))
        //		{
        //			GetAlert("AlertPostCodeBeInt");
        //			$("#txtPostCode").focus();
        //			return;
        //		}
        //end alter
        //alter by htx 20090522
        //add city and cityDistance
        var city_distance = $("#txtCity").val();
        //alert(post_code);
        if (city_distance == "") {
            GetAlert("AlertCityNotNull");
            $("#txtPostCode").focus();
            return;
        }
        if (CheckSpecialChar(city_distance)) {
            GetAlert("NotInvalidChar");
            $("#txtCity").focus();
            return;
        }
        city_distance = city_distance + "|" + $("#hcityDistance").val();
        post_code = post_code + "|" + city_distance;
        //alert(post_code);
        //end

        var u_remark = $("#UserRemark").val();
        if (CheckSpecialChar(u_remark)) {
            GetAlert("NotInvalidChar");
            $("#UserRemark").focus();
            return;
        }
        if (u_remark.length > 500) {
            GetAlert("LessThan500");
            $("#UserRemark").focus();
            return;
        }



        //		if(document.getElementById("YesItem").checked==false)
        //		{
        //			alert("Sie müssen sich mit dem AGB einverstanden erklären");
        //			return;
        //		}
        //start
        //新增姓名详细统计.分别统计姓和名在拼接传入数据库
        //BY:2009-10-12
        //Cedrus
        var first_name = $("#FirstName").val();
        var last_name = $("#LastName").val();
        var user_name = first_name + "|" + last_name;
        //end
        var user_email = $("#UserEmail").val();
        var user_tel = $("#tel_type").val() + $("#TelNo1").val() + "-" + $("#TelNo2").val();
        var user_remark = $("#UserRemark").val();
        var country = $("#ddlCountry").val();
    }

    //end userinfor

    var game_id = $("#ddlGame").val();
    var server_id = $("#ddlServer").val();
    var fraction_id = $("#ddlFraction").val();
    var amount = $("#ddlAmount").val();
    var price = document.getElementById("TotalPrice").innerHTML.replace("€", "").replace("￡", "").replace("$", "").replace("zł", "").replace("PLZ", "").replace("EUR", "").replace("USD", "").replace("GBP", "").replace("Leu", "").Trim();
    var character_name = $("#CharacterName").val();
    var delivery_method = $("#delivery_method").val();
    var Goldaccount = $("#Accountname").val();
    var GoldAPass = $("#password").val();
    var msn = $("#MSN").val();
    var price;
    $.ajax({
        type: "post",
        url: "/js/GoldHandler.ashx",
        data: "ot=GetGoldPrice&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&amount=" + amount,
        success: function(msg) {
            //alert(msg);
            var pric = msg.split("/");
            price = pric[1].replace("€", "").replace("￡", "").replace("$", "").replace("zł", "").replace("PLZ", "").replace("EUR", "").replace("USD", "").replace("GBP", "").replace("Leu", "").Trim();


            $.ajax({
                type: "post",
                url: "/js/GoldHandler.ashx",
                data: "ot=addToCar&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&amount=" + amount + "&price=" + price + "&character_name=" + character_name + "&user_name=" + user_name + "&user_email=" + user_email + "&user_tel=" + user_tel + "&user_remark=" + user_remark + "&country=" + country + "&delivery_method=" + delivery_method + "&post_code=" + post_code + "&goldaccount=" + Goldaccount + "&goldapass=" + GoldAPass + "&msn=" + msn,
                success: function(msg) {
                    var url = "checkout.aspx";
                    location.replace(url);
                },
                error: function(msg) {
                    GetAlert("AlertError");
                }
            });
        },
        error: function(msg) {
            GetAlert("AlertError");
            return;
        }
    });

}

//
function ChangeServer(country_type) {

    var game_id = $("#ddlGame").val();
    var url = "world-of-warcraft-" + country_type + "-gold.html";

    location.replace(url);

    //	$.ajax({
    //		type:"post",
    //		url:"/js/GoldHandler.ashx",
    //		data:"ot=changeEuServers&county_type="+country_type,
    //		success:function(msg)
    //		{
    //			//id:ctl00_ContentPlaceHolder1_server_list,
    //			 document.getElementById("ctl00_ContentPlaceHolder1_server_list").innerHTML=msg;
    //		},
    //		error:function(msg)
    //		{
    //			return;
    //		}
    //	});
}


//
function PlChangeServer(country_type) {

    var game_id = $("#ddlGame").val();
    var url = "world-of-warcraft-" + country_type + "-power-leveling.html";


    location.replace(url);

    //	$.ajax({
    //		type:"post",
    //		url:"/js/GoldHandler.ashx",
    //		data:"ot=changeEuServers&county_type="+country_type,
    //		success:function(msg)
    //		{
    //			//id:ctl00_ContentPlaceHolder1_server_list,
    //			 document.getElementById("ctl00_ContentPlaceHolder1_server_list").innerHTML=msg;
    //		},
    //		error:function(msg)
    //		{
    //			return;
    //		}
    //	});
}

//
function GetGoldPrice() {

    var game_id = $("#ddlGame").val();
    var server_id = $("#ddlServer").val();
    var fraction_id = $("#ddlFraction").val();
    var amount = $("#ddlAmount").val();
    if (server_id == "0") {
        //alert(server_id);
        //document.getElementById("gold_price_list").innerHTML="";
        document.getElementById("PricePerUnit").innerHTML = "0";
        document.getElementById("TotalPrice").innerHTML = "0";
        return;
    }
    if (fraction_id == "0") {
        //alert(fraction_id);
        //document.getElementById("gold_price_list").innerHTML="";
        document.getElementById("PricePerUnit").innerHTML = "0";
        document.getElementById("TotalPrice").innerHTML = "0";
        return;
    }
    //get_gold_html_list()
    if (amount == "0") {
        //alert(amount);
        //document.getElementById("gold_price_list").innerHTML="";
        document.getElementById("PricePerUnit").innerHTML = "0";
        document.getElementById("TotalPrice").innerHTML = "0";
        return;
    }
    //all gold price list

    var hello = "ot=GetGoldPrice&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&amount=" + amount;
    //alert(hello);
    //return;
    //ajax request
    $.ajax({
        type: "post",
        url: "/js/GoldHandler.ashx",
        data: "ot=GetGoldPrice&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&amount=" + amount,
        success: function(msg) {
            //alert(msg);
            var price = msg.split("/");
            document.getElementById("PricePerUnit").innerHTML = price[0];
            document.getElementById("TotalPrice").innerHTML = price[1];
            document.getElementById("EbayPrice").innerHTML = price[2];
        },
        error: function(msg) {
            GetAlert("AlertError");
            return;
        }
    });
}

//
function GetOtherInfor(lang_id) {
    var game = document.getElementById("ddlGame");
    var game_id = game.options[game.selectedIndex].value;

    $.ajax({
        type: "post",
        url: "/js/jsHandler.ashx",
        data: "game_id=" + game_id + "&lang_id=" + lang_id,
        success: function(msg) { document.getElementById("server_fraction").innerHTML = msg; },
        error: function(msg) { alert(msg); }
    });
}


//
function GetTel() {
    var country = document.getElementById("ddlCountry");
    var country_name = country.options[country.selectedIndex].text;

    $.ajax({
        type: "post",
        url: "/js/GetTelHandler.ashx",
        data: "country_name=" + country_name,
        success: function(msg) {
            $("#TelNo1").val(msg);
        },
        error: function(msg) {
            GetAlert("AlertError");
        }
    });
}


function GetPrice() {
    var goldunit = document.getElementById("goldunitlist");
    var goldunit_value = goldunit.options[goldunit.selectedIndex].value;

    var game = document.getElementById("ddlGame");
    var game_id = game.options[game.selectedIndex].value;

    var server = document.getElementById("server_id");
    var server_id = server.options[server.selectedIndex].value;

    var fraction = document.getElementById("fraction_id");
    if (fraction) {
        var fraction_id = fraction.options[fraction.selectedIndex].value;
    }
    else {
        var fraction_id = 0;
    }

    //temp
    fraction_id = 3;

    var temp = "goldunit_id=" + goldunit_value + "&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id;

    $.ajax({
        type: "post",
        url: "/js/getPriceHandler.ashx",
        data: "goldunit_id=" + goldunit_value + "&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id,
        success: function(msg) {
            document.getElementById("gold_unit").innerHTML = msg;
        },
        error: function(msg) {
            GetAlert("AlertError");
        }
    });
}

///tijiao gou wu che


////
var t_DiglogX, t_DiglogY, t_DiglogW, t_DiglogH;

function StrCode(str) {

    if (encodeURIComponent)

        return encodeURIComponent(str);

    if (escape)

        return escape(str);

}
function Browser() {

    var ua, s, i;

    this.isIE = false;

    this.isNS = false;

    this.isOP = false;

    this.isSF = false;

    ua = navigator.userAgent.toLowerCase();

    s = "opera";

    if ((i = ua.indexOf(s)) >= 0) {

        this.isOP = true; return;

    }

    s = "msie";

    if ((i = ua.indexOf(s)) >= 0) {

        this.isIE = true;

        return;

    }

    s = "netscape6/";

    if ((i = ua.indexOf(s)) >= 0) {

        this.isNS = true;

        return;

    }

    s = "gecko";

    if ((i = ua.indexOf(s)) >= 0) {

        this.isNS = true;

        return;

    }

    s = "safari";

    if ((i = ua.indexOf(s)) >= 0) {

        this.isSF = true;

        return;

    }

}
function DialogShow(showdata, ow, oh, w, h) {

    var objDialog = document.getElementById("DialogMove");

    if (!objDialog)

        objDialog = document.createElement("div");

    t_DiglogW = ow;

    t_DiglogH = oh;

    DialogLoc();

    objDialog.id = "DialogMove";

    var oS = objDialog.style;

    oS.display = "block";

    oS.top = t_DiglogY + "px";

    oS.left = t_DiglogX + "px";

    oS.margin = "0px";

    oS.padding = "0px";

    oS.width = w + "px";

    oS.height = h + "px";

    oS.position = "absolute";

    oS.zIndex = "5";

    //oS.background = "#FFF";

    oS.border = "0px solid #DBD6F6";

    objDialog.innerHTML = showdata;

    document.body.appendChild(objDialog);

}
function DialogHide() {

    ScreenClean();

    var objDialog = document.getElementById("DialogMove");

    if (objDialog)

        objDialog.style.display = "none";

}
function DialogLoc() {

    var dde = document.documentElement;

    if (window.innerWidth) {

        var ww = window.innerWidth;

        var wh = window.innerHeight;

        var bgX = window.pageXOffset;

        var bgY = window.pageYOffset;

    } else {

        var ww = dde.offsetWidth;

        var wh = dde.offsetHeight;

        var bgX = dde.scrollLeft;

        var bgY = dde.scrollTop;

    }

    t_DiglogX = (bgX + ((ww - t_DiglogW) / 2));

    t_DiglogY = (bgY + ((wh - t_DiglogH) / 2));

}
function ScreenConvert() {

    var browser = new Browser();

    var objScreen = document.getElementById("ScreenOver");

    if (!objScreen)

        var objScreen = document.createElement("div");

    var oS = objScreen.style;

    objScreen.id = "ScreenOver";

    oS.display = "block";

    oS.top = oS.left = oS.margin = oS.padding = "0px";

    if (document.documentElement.clientHeight) {

        var wh = document.documentElement.clientHeight + "px";

    } else if (window.innerHeight) {

        var wh = window.innerHeight + "px";

    } else {

        var wh = "100%";

    }

    oS.width = "100%";

    oS.height = wh;

    oS.position = "absolute";

    oS.zIndex = "3";

    if ((!browser.isSF) && (!browser.isOP)) {

        oS.background = "#cccccc";

    } else {

        oS.background = "#cccccc";

    }

    oS.filter = "alpha(opacity=50)";

    oS.opacity = 40 / 100;

    oS.MozOpacity = 40 / 100;

    document.body.appendChild(objScreen);

    var allselect = document.getElementsByTagName("select");

    for (var i = 0; i < allselect.length; i++)

        allselect[i].style.visibility = "hidden";

}
function ScreenClean() {

    var objScreen = document.getElementById("ScreenOver");

    if (objScreen)

        objScreen.style.display = "none";

    var allselect = document.getElementsByTagName("select");

    for (var i = 0; i < allselect.length; i++)

        allselect[i].style.visibility = "visible";

}



function TrimString(str) {
    var i, j;
    if (str == "") return "";
    for (i = 0; i < str.length; i++)
        if (str.charAt(i) != ' ') break;
    if (i >= str.length) return "";
    for (j = str.length - 1; j >= 0; j--)
        if (str.charAt(j) != ' ') break;
    return str.substring(i, j + 1);
}


//==================================================================

function CheckSpecialChar(strSource) {
    var intIndex = -1;
    var regExpInfo = /&/;
    intIndex = strSource.search(regExpInfo);
    if (intIndex == -1) {
        regExpInfo = /</;
        intIndex = strSource.search(regExpInfo);
    }
    if (intIndex == -1) {
        regExpInfo = />/;
        intIndex = strSource.search(regExpInfo);
    }
    if (intIndex == -1) {
        regExpInfo = /"/;
        intIndex = strSource.search(regExpInfo);
    }
    if (intIndex == -1) {
        regExpInfo = /'/;
        intIndex = strSource.search(regExpInfo);
    }
    if (intIndex == -1) {
        regExpInfo = /;/;
        intIndex = strSource.search(regExpInfo);
    }

    //if(intIndex == - 1)
    //{
    // regExpInfo = /\|/;
    // intIndex = strSource.search(regExpInfo);
    //}

    if (intIndex == -1) {
        regExpInfo = /\//;
        intIndex = strSource.search(regExpInfo);
    }

    if (intIndex == -1) {
        regExpInfo = /\\/;
        intIndex = strSource.search(regExpInfo);
    }

    if (intIndex == -1) {
        return false;
    }
    else {
        return true;
    }
}
function SendEbankPay() {
    if ($("#amount").val().replace(" ", "") == "0" || $("#amount").val().replace(" ", "") == "0.00") {
        alert("Sie müssen nicht alles kaufen!");
        return;
    }
    document.getElementById("btn_go1").innerHTML = "<img src='/img/loading.gif' />";
    document.getElementById("btn_go2").innerHTML = "<img src='/img/loading.gif' />";
    document.getElementById("btn_go3").innerHTML = "<img src='/img/loading.gif' />";
    document.getElementById("btn_go4").innerHTML = "<img src='/img/loading.gif' />";
    document.getElementById("Span1").innerHTML = "<img src='/img/loading.gif' />";
    var price = $("#amount").val();
    var order_list = $("#item_name").val();
    //alert(price+"+"+order_list);
    $.ajax({
        url: "/js/GoldHandler.ashx",
        data: "ot=CheckOutHandler_eBank2pay&price=" + price + "&order_list=" + order_list,
        success: function(msg) {
            if (msg == "") {

            }
            else {
                document.location.href = msg;
            }
        }

    });
}

///////////////////////////////////////////////////////////////////////////gudinggoumai//////////////////////////////////////////
function FixedPriceList() {
    var buytype = $("#buytype").val();
    var game_id = $("#ddlGame").val();
    var server_id = $("#ddlServer").val();
    var fraction_id = $("#ddlFraction").val();
    if (server_id == "0") {
        //		//alert(server_id);
        //		//document.getElementById("gold_price_list").innerHTML="";
        //		document.getElementById("PricePerUnit").innerHTML="0";
        //		document.getElementById("TotalPrice").innerHTML="0";
        return;
    }
    if (fraction_id == "0") {
        //alert(fraction_id);
        //document.getElementById("gold_price_list").innerHTML="";
        //		document.getElementById("PricePerUnit").innerHTML="0";
        //		document.getElementById("TotalPrice").innerHTML="0";
        return;
    }
    //get_gold_html_list()

    //all gold price list

    var hello = "ot=GetGoldPrice&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&buytype=" + buytype;
    //alert(hello);
    //return;
    //ajax request
    $.ajax({
        type: "post",
        url: "/js/AJAXHandler.ashx",
        data: "ot=GetGoldList&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&buytype=" + buytype,
        success: function(msg) {
            document.getElementById("GoldList").innerHTML = msg;
        },
        error: function(msg) {
            GetAlert("AlertError");
            return;
        }
    });
}
/////IHopePrice
function IHopePriceToAmount() {
    var buytype = $("#buytype").val();
    var game_id = $("#ddlGame").val();
    var server_id = $("#ddlServer").val();
    var fraction_id = $("#ddlFraction").val();
    var price = $("#YouWantPrice").val();
    if (price == "0" || isNaN(price) || price == 0) {
        $("#YouWantPrice").val("");
        $("#IHopePayPriceAmount").html("0")
        return;
    }
    if (server_id == "0") {
        //		//alert(server_id);
        //		//document.getElementById("gold_price_list").innerHTML="";
        //		document.getElementById("PricePerUnit").innerHTML="0";
        //		document.getElementById("TotalPrice").innerHTML="0";
        return;
    }
    if (fraction_id == "0") {
        //alert(fraction_id);
        //document.getElementById("gold_price_list").innerHTML="";
        //		document.getElementById("PricePerUnit").innerHTML="0";
        //		document.getElementById("TotalPrice").innerHTML="0";
        return;
    }
    //get_gold_html_list()

    //all gold price list

    // var hello = "ot=IHopePriceToAmount&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&buytype=" + buytype;
    //alert(hello);
    //return;
    //ajax request
    $.ajax({
        type: "post",
        url: "/js/AJAXHandler.ashx",
        data: "ot=IHopePriceToAmount&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&buytype=" + buytype + "&price=" + price,
        success: function(msg) {
            var soue = msg.toString().split('|');
            document.getElementById("_pri_c_e").value = soue[0];
            document.getElementById("IHopePayPriceAmount").innerHTML = soue[1];
        },
        error: function(msg) {
            GetAlert("AlertError");
            return;
        }
    });
}
function IhopeSetPrice() {
    var trueprice = $("#_pri_c_e").val();
    var amount = $("#IHopePayPriceAmount").html();
    var price = $("#YouWantPrice").val();
    if (price < 0) {
        amount = 0;
    }
    if (price.lastIndexOf('.') <= -1) {
        price = price + ".00";
    }
    if (trueprice < 0) {
        amount = 0;
    }
    if (trueprice.lastIndexOf('.') <= -1) {
        trueprice = trueprice + ".00";
    }

    var str = trueprice + "|" + price + "|" + amount;
    SetPrice(str);
}
/////IHopeCallPrice
function IHopeCallToPayPriceToAmount() {

    //    var land = $("#land").val();
    //    var phonetype = $("#phonetype").val();
    var phone = $("#phone").val();
    var calltpPrice = $("#calltpPrice").val();


    phone = TrimString(phone);
    if (phone == "") {
        GetAlert("InputTel");
        $("#phone").focus();
        return;
    }
    if (CheckSpecialChar(phone)) {
        GetAlert("NotInvalidChar");
        $("#phone").focus();
        return;
    }

    //    if (isNaN(phone)) {
    //        GetAlert("TelMustBeInt");
    //        $("#phone").focus();
    //        return;
    //    }
    var buytype = $("#buytype").val();
    var game_id = $("#ddlGame").val();
    var server_id = $("#ddlServer").val();
    var fraction_id = $("#ddlFraction").val();

    if (server_id == "0") {
        GetAlert("ChooseServer");
        return;
    }
    if (fraction_id == "0") {
        //alert(fraction_id);
        //document.getElementById("gold_price_list").innerHTML="";
        //		document.getElementById("PricePerUnit").innerHTML="0";
        //		document.getElementById("TotalPrice").innerHTML="0";
        return;
    }
    if (calltpPrice == "0" || isNaN(calltpPrice) || calltpPrice == 0 || calltpPrice > 30) {
        // alert("Max. 30 EUR");
        return;
    }
    //get_gold_html_list()

    //all gold price list

    // var hello = "ot=IHopePriceToAmount&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&buytype=" + buytype;
    //alert(hello);
    //return;
    //ajax request
    $.ajax({
        type: "post",
        url: "/js/AJAXHandler.ashx",
        data: "ot=GetGoldList&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&buytype=" + buytype + "&price=" + calltpPrice,
        success: function(msg) {
            document.getElementById("GoldList").innerHTML = msg;
        },
        error: function(msg) {
            GetAlert("AlertError");
            return;
        }
    });
}
/////IHopeHandyPrice
function IHopeHandyPayPriceToAmount() {
    var land;
    if ($("#land" != null)) {
        land = $("#land").find("option:selected").text();
    }

    //    var phonetype = $("#phonetype").val();
    var phone = $("#phone").val();

    phone = TrimString(phone);
    if (phone == "") {
        GetAlert("InputTel");
        $("#phone").focus();
        return;
    }
    if (CheckSpecialChar(phone)) {
        GetAlert("NotInvalidChar");
        $("#phone").focus();
        return;
    }
    //    if (isNaN(phone)) {
    //        GetAlert("TelMustBeInt");
    //        $("#phone").focus();
    //        return;
    //    }
    var buytype = $("#buytype").val();
    var game_id = $("#ddlGame").val();
    var server_id = $("#ddlServer").val();
    var fraction_id = $("#ddlFraction").val();
    if (server_id == "0") {
        GetAlert("ChooseServer");
        return;
    }
    if (fraction_id == "0") {
        //alert(fraction_id);
        //document.getElementById("gold_price_list").innerHTML="";
        //		document.getElementById("PricePerUnit").innerHTML="0";
        //		document.getElementById("TotalPrice").innerHTML="0";
        return;
    }
    //    if (calltpPrice == "0" || isNaN(calltpPrice) || calltpPrice == 0) {
    //        return;
    //    }
    //get_gold_html_list()

    //all gold price list

    // var hello = "ot=IHopePriceToAmount&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&buytype=" + buytype;
    //alert(hello);
    //return;
    //ajax request
    $.ajax({
        type: "post",
        url: "/js/AJAXHandler.ashx",
        data: "ot=GetGoldList&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&buytype=" + buytype + "&land=" + land,
        success: function(msg) {
            document.getElementById("GoldList").innerHTML = msg;
        },
        error: function(msg) {
            GetAlert("AlertError");
            return;
        }
    });
}
///minimumPrice
function minimumPrice() {
    var game_id = $("#ddlGame").val();
    var server_id = $("#ddlServer").val();
    var fraction_id = $("#ddlFraction").val();
    $.ajax({
        type: "post",
        url: "/js/AJAXHandler.ashx",
        data: "ot=returnMinPrice&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&amount=10",
        success: function(msg) {
            msg = msg * 2.5;
            $("#minprice").html(msg);
        },
        error: function(msg) {
            GetAlert("AlertError");
            return;
        }
    });

}
///getlanguagePrice
function getLanguagePrice() {
    var lang = $("#land").val();
    if (lang != "Deutschland") {
        $("#calltpPrice option[text='9.99']").remove();

    }
}
function SetPrice(price) {

    var str = price.split('|');
    if (str[0] == 0 || str[1] == 0) {
        return;
    }
    document.getElementById("userdeltels").style.display = "block";
    document.getElementById("_pri_c_e").value = str[0];
    document.getElementById("this_price").innerHTML = str[1];
    document.getElementById("this_Amount").innerHTML = str[2];
    GetTel();
    if ($("#land").val() != undefined) {
        var thisland = $("#land").val();
        if (thisland == "Deutschland") {
            $("#ddlCountry").val("Germany - DE");
        }
        if (thisland == "Österreich") {
            $("#ddlCountry").val("Austria - AT");
        }
        if (thisland == "Schweiz") {
            $("#ddlCountry").val("Switzerland - CH");
        }

        var phone = $("#phone").val();
        $("#TelNo2").val(phone);


        var phonetype = $("#phonetype").val();
        if (phonetype == "Festnetz") {
            $("#tel_type").val("h");
        }
        if (phonetype == "Handy") {
            $("#tel_type").val("m");
        }

    }
    GetTel();
    // $("#_pri_c_e").val(price);
}

function AddPSCToCar() {


    if ($("#ddlServer").val() == "0") {
        GetAlert("ChooseServer");
        return;
    }
    var tempPrice = /^[0-9]+.?[0-9]*$/;
    var thistemprice = document.getElementById("_pri_c_e").value.Trim();
    if (!tempPrice.test(thistemprice)) {
        GetAlert("PleaseConfirm");
        return;
    }
    if (document.getElementById("_pri_c_e").value.Trim() == "0") {
        GetAlert("PleaseConfirm");
        return;
    }
    if ($("#CharacterName").val() == "") {
        GetAlert("CorrectCharacterName");
        $("#CharacterName").focus();
        return;
    }
    var c_name = $("#CharacterName").val();
    c_name = TrimString(c_name);
    if (c_name.length < 2) {
        GetAlert("CorrectCharacterName");
        $("#CharacterName").focus();
        return;
    }
    if (CheckSpecialChar(c_name)) {
        GetAlert("NotInvalidChar");
        $("#CharacterName").focus();
        return;
    }

    //Cesc Add
    var buyTypeTemp = $("#delivery_method").val();
    var checkedSize = $("#red:checked").size();
    if (buyTypeTemp == "2") {
        if (checkedSize == 1) {
            var checkAccountname = $("#Accountname").val();
            var checkAPwd = $("#password").val();
            if (checkAccountname == "") {
                GetAlert("NotAccountname");
                $("#Accountname").focus();
                return;
            }
            if (checkAPwd == "") {
                GetAlert("Notpassword");
                $("#password").focus();
                return;
            }
        }
    }
    //end gold infor

    //user infor
    //user infor
    var user_infor_display = "display"; //document.getElementById("ctl00_ContentPlaceHolder1_userInformation").style.display;
    if (user_infor_display == "none") {
        var user_name = "";
        var user_email = "";
        var user_tel = "";
        var user_remark = "";
        var country = "";
    }
    else {

        //验证名
        if ($("#FirstName").val() == "") {
            GetAlert("firstInputFullName");
            $("#FirstName").focus();
            return;
        }

        //add 
        var firstname = "";
        firstname = $("#FirstName").val();
        firstname = TrimString(firstname);
        if (firstname.length < 2) {
            GetAlert("firstBetween2to50");
            $("#FirstName").focus();
            return;
        }
        //	
        //验证姓
        if ($("#LastName").val() == "") {
            GetAlert("lastInputFullName");
            $("#LastName").focus();
            return;
        }



        //add 
        var lastname = "";
        lastname = $("#LastName").val();
        lastname = TrimString(lastname);
        if (lastname.length < 2) {
            GetAlert("lastBetween2to50");
            $("#LastName").focus();
            return;
        }
        //	

        //add 
        var u_email = $("#UserEmail").val();
        //
        if (u_email == "") {
            GetAlert("EmailNotNull");
            $("#UserEmail").focus();
            return;
        }
        else {
            //add
            if (CheckSpecialChar(u_email)) {
                GetAlert("NotInvalidChar");
                $("#UserEmail").focus();
                return;
            }
            //

            //check email 
            var emailPat = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
            var matchArray = $("#UserEmail").val().match(emailPat);
            if (matchArray == null) {
                GetAlert("CorrectEmail");
                $("#UserEmail").val = "";
                $("#UserEmail").focus();
                return;
            }
        }

        if ($("#ddlCountry").val() == "0") {
            GetAlert("ChooseContry");
            return;
        }

        var tel_no1 = $("#TelNo1").val();
        tel_no1 = TrimString(tel_no1);
        if (tel_no1 == "") {
            GetAlert("InputTel");
            $("#TelNo1").focus();
            return;
        }
        if (CheckSpecialChar(tel_no1)) {
            GetAlert("NotInvalidChar");
            $("#TelNo1").focus();
            return;
        }
        if (isNaN(tel_no1)) {
            GetAlert("TelMustBeInt");
            $("#TelNo1").focus();
            return;
        }
        var tel_no2 = $("#TelNo2").val();
        tel_no2 = TrimString(tel_no2);
        if (tel_no2 == "") {
            GetAlert("InputTel");
            $("#TelNo2").focus();
            return;
        }
        if (CheckSpecialChar(tel_no2)) {
            GetAlert("NotInvalidChar");
            $("#TelNo2").focus();
            return;
        }
        if (isNaN(tel_no2)) {
            GetAlert("TelMustBeInt");
            $("#TelNo2").focus();
            return;
        }

        //alter by hetianxu 20090520
        //add post code
        var post_code = $("#txtPostCode").val();
        //alert(post_code);
        if (post_code == "") {
            GetAlert("AlertPostCodeBeInt");
            $("#txtPostCode").focus();
            return;
        }
        if (CheckSpecialChar(post_code)) {
            GetAlert("NotInvalidChar");
            $("#txtPostCode").focus();
            return;
        }
        //		if(isNaN(post_code))
        //		{
        //			GetAlert("AlertPostCodeBeInt");
        //			$("#txtPostCode").focus();
        //			return;
        //		}
        //end alter
        //alter by htx 20090522
        //add city and cityDistance
        var city_distance = $("#txtCity").val();
        //alert(post_code);
        if (city_distance == "") {
            GetAlert("AlertCityNotNull");
            $("#txtPostCode").focus();
            return;
        }
        if (CheckSpecialChar(city_distance)) {
            GetAlert("NotInvalidChar");
            $("#txtCity").focus();
            return;
        }
        city_distance = city_distance + "|" + $("#hcityDistance").val();
        post_code = post_code + "|" + city_distance;
        //alert(post_code);
        //end

        var u_remark = $("#UserRemark").val();
        if (CheckSpecialChar(u_remark)) {
            GetAlert("NotInvalidChar");
            $("#UserRemark").focus();
            return;
        }
        if (u_remark.length > 500) {
            GetAlert("LessThan500");
            $("#UserRemark").focus();
            return;
        }



        //		if(document.getElementById("YesItem").checked==false)
        //		{
        //			alert("Sie müssen sich mit dem AGB einverstanden erklären");
        //			return;
        //		}
        //start
        //新增姓名详细统计.分别统计姓和名在拼接传入数据库
        //BY:2009-10-12
        //Cedrus
        var first_name = $("#FirstName").val();
        var last_name = $("#LastName").val();
        var user_name = first_name + "|" + last_name;
        //end
        var user_email = $("#UserEmail").val();
        var user_tel = $("#tel_type").val() + $("#TelNo1").val() + "-" + $("#TelNo2").val();
        var user_remark = $("#UserRemark").val();
        var country = $("#ddlCountry").val();
    }

    //end userinfor
    var game_id = $("#ddlGame").val();
    var server_id = $("#ddlServer").val();
    var fraction_id = $("#ddlFraction").val();
    var character_name = $("#CharacterName").val();
    var delivery_method = $("#delivery_method").val();
    var Goldaccount = $("#Accountname").val();
    var GoldAPass = $("#password").val();
    var msn = $("#MSN").val();
    var price = $("#_pri_c_e").val().Trim();
    var amount;
    var discount = 1;
    var type = $("#buytype").val();

    var phonetype = "";
    if ($("#phonetype").val() != undefined) {
        phonetype = $("#phonetype").val();
    }
    var phone = $("#phone").val();

    document.getElementById("spanloand").innerHTML = "<img src='/img/loading.gif' />";
    $.ajax({
        type: "post",
        url: "/js/AJAXHandler.ashx",
        data: "ot=GetGoldAmount&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&price=" + price + "&discount=" + discount + "&type=" + type,
        success: function(msg) {
            //alert(msg);
            //			var pric=msg.split("/");
            //			price=pric[1].replace("€","").replace("￡","").replace("$","").replace("zł","").replace("PLZ","").replace("EUR","").replace("USD","").replace("GBP","").Trim();
            amount = msg;


            $.ajax({
                type: "post",
                url: "/js/GoldHandler.ashx",
                data: "ot=addToCar&game_id=" + game_id + "&server_id=" + server_id + "&fraction_id=" + fraction_id + "&amount=" + amount + "&price=" + price + "&character_name=" + character_name + "&user_name=" + user_name + "&user_email=" + user_email + "&user_tel=" + user_tel + "&user_remark=" + user_remark + "&country=" + country + "&delivery_method=" + delivery_method + "&post_code=" + post_code + "&goldaccount=" + Goldaccount + "&goldapass=" + GoldAPass + "&msn=" + msn + "&type=" + type + "&phone=" + phone + "&phoneType=" + phonetype,
                success: function(msg) {
                    if (type == "psc") {
                        $.ajax({
                            type: "post",
                            url: "/js/AJAXHandler.ashx",
                            data: "ot=PSCOnClick&price=" + price,
                            success: function(msg) {
                                if (msg == "error!") {
                                    alert("error!");
                                } else {
                                    parent.location.replace(msg);
                                }
                            },
                            error: function(msg) {
                                GetAlert("AlertError");
                            }
                        });
                    }
                    if (type == "Call2pay") {
                        $.ajax({
                            type: "post",
                            url: "/js/GoldHandler.ashx",
                            data: "ot=CheckCallToPay&price=" + price + "&country=" + country,
                            success: function(msg) {
                                if (msg == "error!") {
                                    alert("error!");
                                } else {
                                    parent.location.replace(msg);
                                }
                            },
                            error: function(msg) {
                                GetAlert("AlertError");
                            }
                        });
                    }
                    if (type == "Handypay") {
                        $.ajax({
                            type: "post",
                            url: "/js/GoldHandler.ashx",
                            data: "ot=CheckHandyToPay&price=" + price,
                            success: function(msg) {
                                if (msg == "error!") {
                                    alert("error!");
                                } else {
                                    parent.location.replace(msg);
                                }
                            },
                            error: function(msg) {
                                GetAlert("AlertError");
                            }
                        });
                    }

                },
                error: function(msg) {
                    GetAlert("AlertError");
                }
            });


        },
        error: function(msg) {
            GetAlert("AlertError");
            return;
        }
    });
}
function MakeAPriceGameChange() {
    var url = "";
    var game_name = "";
    game_name = $("select[@name='ddlGame'] option[@selected]").text();

    url = "metin2-yang-paysafecard-" + game_name.replace(/( )/g, "-").toLowerCase().replace("metin2-", "") + ".html"
    location.replace(url);
}

function MakeCallAPriceGameChange() {
    var url = "";
    var game_name = "";
    game_name = $("select[@name='ddlGame'] option[@selected]").text();

    url = "metin2-yang-Call2pay-" + game_name.replace(/( )/g, "-").toLowerCase().replace("metin2-", "") + ".html"
    location.replace(url);
}

function MakeHandyAPriceGameChange() {
    var url = "";
    var game_name = "";
    game_name = $("select[@name='ddlGame'] option[@selected]").text();

    url = "metin2-yang-Handypay-" + game_name.replace(/( )/g, "-").toLowerCase().replace("metin2-", "") + ".html"
    location.replace(url);
}
