var mes_hide_sign;

function show_mes(txt,left,top) {
	var mes=document.getElementById("mes");
	var box=document.getElementById("box");
	mes.style.display="";
	mes.style.left=left+"px";
	mes.style.top =top +"px";
	box.innerHTML=txt;
}

function show_mes2(txt,left,top) {
	var mes2=document.getElementById("mes2");
	var box2=document.getElementById("box2");
	mes2.style.display="";
	mes2.style.left=left+"px";
	mes2.style.top =top +"px";
	box2.innerHTML=txt;
}

function show_mesbytype(type){
	txt_type = '';
//	alert(typeof(mes_hide_sign));
	if (typeof(mes_hide_sign)=="number") clearTimeout(mes_hide_sign);
	var top_offset_num = 3;//头的偏移量
	var left_offset_num = 0;//左的偏移量
//	alert(document.getElementById("f2f_trade").value);
//	alert(document.sellgold.f2f_trade.value);
	if(type=='character'){/*
		if(document.getElementById("serverarea5").checked || document.getElementById("serverarea8").checked){//us
			if (document.getElementById("f2f_trade").value==1){
				txt_type='We will trade gold with you in game.(<a href="http://'+document.location.host+'/f2f_tutorial.php" target="_blank"><font color=blue><u>How to do in-game trading with us?</u></font></a>)';
				box_width=232;
			}else{*/
				txt_type='No Trial Character';
				box_width=102;/*
			}
		}*/
		left_ie=352+left_offset_num;
		left_ff=352+left_offset_num;
//		top_ie=$("#usa_tel3").offset().top - 273;
//		top_ff=$("#usa_tel3").offset().top - 260;
		top_ie=$("#character_to").offset().top-210;
		top_ff=$("#character_to").offset().top-210;
//		top_ie=172+top_offset_num;
//		top_ff=164+top_offset_num;
		var box=document.getElementById("box");
		box.style.width=box_width+"px";
	}
	if(type=='coupon'){
	    if(document.getElementById("coupon_code").value.length>0){ 
			var url='remote_checkcoupon.php?coupon_code='+document.getElementById("coupon_code").value+'&coupon_site=wowmine.com';
			var return_info = XMLHttpLoadFile(url);
			if(return_info==803){
				txt_type='Invalid code!';
			}
			else
			{
				txt_type=return_info;
			}
		}
		left_ie=332+left_offset_num;
		left_ff=332+left_offset_num;
		top_ie=$("#usa_tel3").offset().top - 180;
		top_ff=$("#usa_tel3").offset().top - 180;
//		top_ie=205+top_offset_num;
//		top_ff=190+top_offset_num;
		var box2=document.getElementById("box2");
		box2.style.width=260+"px";
	}
	if(type=='email'){
		txt_type='The order status will be sent to your email.';
		left_ie=352+left_offset_num;
		left_ff=352+left_offset_num;
		top_ie=$("#TBEmail").offset().top - 210;
		top_ff=$("#TBEmail").offset().top - 210;
//		top_ie=$("#usa_tel3").offset().top - 153;
//		top_ff=$("#usa_tel3").offset().top - 150;
//		top_ie=291+top_offset_num;
//		top_ff=272+top_offset_num;
		var box=document.getElementById("box");
		box.style.width=260+"px";
	}
	if(type=='phone'){
		txt_type='We may call you for ingame delivery issues, please make sure we can reach you by this phone number.';
		left_ie=573+left_offset_num;
		left_ff=560+left_offset_num;
		top_ie=$("#usa_tel1").offset().top - 210;
		top_ff=$("#usa_tel1").offset().top - 210;
//		top_ie=322+top_offset_num;
//		top_ff=300+top_offset_num;
	}
	if(type=='convenient_time'){
		txt_type='Assume Pacific Time if a time zone is not specified.';
		left_ie=440+left_offset_num;
		left_ff=470+left_offset_num;
		top_ie=$("#usa_tel1").offset().top - 180;
		top_ff=$("#usa_tel1").offset().top - 180;
//		top_ie=322+top_offset_num;
//		top_ff=300+top_offset_num;
	}
	if(navigator.userAgent.indexOf("MSIE")>0){//IE
		left_type=left_ie;
		top_type=top_ie;
	}
    if(navigator.userAgent.indexOf("Firefox")>0){//FIREFOX
		left_type=left_ff;
		top_type=top_ff;
	};
	if(type=='coupon'){
		if(document.getElementById("coupon_code").value.length>0&&document.getElementById("coupon_code").value.length!=9){
			show_mes2(txt_type,left_type,top_type);
		}else document.getElementById('mes2').style.display='none';
	}else
	    show_mes(txt_type,left_type,top_type);
}

function show_mesbytype2(type){
	txt_type = '';
//	alert(typeof(mes_hide_sign));
	if (typeof(mes_hide_sign)=="number") clearTimeout(mes_hide_sign);
	var top_offset_num = 3;//头的偏移量
	var left_offset_num = 0;//左的偏移量
//	alert(document.getElementById("f2f_trade").value);
//	alert(document.sellgold.f2f_trade.value);
	if(type=='phone'){
		txt_type='We may call you for ingame delivery issues, please make sure we can reach you by this phone number.';
		left_ie=$("#usa_tel3").offset().left - 10;
		left_ff=$("#usa_tel3").offset().left + 120;
		top_ie=$("#usa_tel3").offset().top - 235;
		top_ff=$("#usa_tel3").offset().top - 26;
//		top_ie=322+top_offset_num;
//		top_ff=300+top_offset_num;
	}
	if(navigator.userAgent.indexOf("MSIE")>0){//IE
		left_type=left_ie;
		top_type=top_ie;
	}
    if(navigator.userAgent.indexOf("Firefox")>0){//FIREFOX
		left_type=left_ff;
		top_type=top_ff;
	};
	if(type=='coupon'){
		if(document.getElementById("coupon_code").value.length>0&&document.getElementById("coupon_code").value.length!=9){
			show_mes2(txt_type,left_type,top_type);
		}else document.getElementById('mes2').style.display='none';
	}else
	    show_mes(txt_type,left_type,top_type);
}

function hide_mes() {
		document.getElementById('mes').style.display='none';
		var box=document.getElementById("box");
		box.style.width=180+"px";
}




function getCountryCode(country){
     // get selected country
	 
//	 var usatel1 = $("#usa_tel1");
//	 var usatel2 = document.getElementById("usa_tel2");
//	 var usatel3 = document.getElementById("usa_tel3");
	 
	 if(country == "AD") countryCode = '33';
     if(country == "AE") countryCode = '971';
     if(country == "AF") countryCode = '93';
     if(country == "AG") countryCode = '809';
     if(country == "AI") countryCode = '809';
     if(country == "AL") countryCode = '355';
     if(country == "AM") countryCode = '7';
     if(country == "AN") countryCode = '599';
     if(country == "AO") countryCode = '244';
     if(country == "AR") countryCode = '54';
     if(country == "AT") countryCode = '43';
     if(country == "AU") countryCode = '61';
     if(country == "AW") countryCode = '297';
     if(country == "AZ") countryCode = '7';
     if(country == "BA") countryCode = '387';
     if(country == "BB") countryCode = '809';
     if(country == "BD") countryCode = '880';
     if(country == "BE") countryCode = '32';
     if(country == "BF") countryCode = '226';
     if(country == "BG") countryCode = '359';
     if(country == "BH") countryCode = '973';
     if(country == "BI") countryCode = '257';
     if(country == "BJ") countryCode = '229';
     if(country == "BM") countryCode = '809';
     if(country == "BN") countryCode = '673';
     if(country == "BO") countryCode = '591';
     if(country == "BR") countryCode = '55';
     if(country == "BS") countryCode = '809';
     if(country == "BT") countryCode = '975';
     if(country == "BW") countryCode = '267';
     if(country == "BY") countryCode = '7';
     if(country == "BZ") countryCode = '501';
     if(country == "CA") countryCode = '1';
     if(country == "CF") countryCode = '236';
     if(country == "CG") countryCode = '242';
     if(country == "CH") countryCode = '41';
     if(country == "CI") countryCode = '225';
     if(country == "CL") countryCode = '56';
     if(country == "CM") countryCode = '237';
     if(country == "CN") countryCode = '86';
     if(country == "CO") countryCode = '57';
     if(country == "CR") countryCode = '506';
     if(country == "CU") countryCode = '53';
     if(country == "CV") countryCode = '238';
     if(country == "CY") countryCode = '357';
     if(country == "CZ") countryCode = '420';
     if(country == "DE") countryCode = '49';
     if(country == "DJ") countryCode = '253';
     if(country == "DK") countryCode = '45';
     if(country == "DM") countryCode = '809';
     if(country == "DO") countryCode = '809';
     if(country == "DZ") countryCode = '213';
     if(country == "EC") countryCode = '593';
     if(country == "EE") countryCode = '7';
     if(country == "EG") countryCode = '20';
     if(country == "EH") countryCode = '212';
     if(country == "ER") countryCode = '291';
     if(country == "ES") countryCode = '34';
     if(country == "ET") countryCode = '251';
     if(country == "FO") countryCode = '298';
	 if(country == "FI") countryCode = '358';
     if(country == "FJ") countryCode = '679';
     if(country == "FM") countryCode = '691';
     if(country == "FR") countryCode = '33';
     if(country == "GA") countryCode = '220';
     if(country == "GE") countryCode = '7';
     if(country == "GF") countryCode = '594';
     if(country == "GH") countryCode = '233';
     if(country == "GM") countryCode = '220';
     if(country == "GN") countryCode = '224';
     if(country == "GP") countryCode = '590';
     if(country == "GQ") countryCode = '240';
     if(country == "GR") countryCode = '30';
     if(country == "GT") countryCode = '502';
     if(country == "GW") countryCode = '245';
     if(country == "GY") countryCode = '592';
     if(country == "HK") countryCode = '852';
     if(country == "HN") countryCode = '504';
     if(country == "HR") countryCode = '385';
     if(country == "HT") countryCode = '509';
     if(country == "HU") countryCode = '36';
     if(country == "ID") countryCode = '62';
     if(country == "IE") countryCode = '353';
     if(country == "IL") countryCode = '972';
     if(country == "IN") countryCode = '91';
     if(country == "IQ") countryCode = '964';
     if(country == "IR") countryCode = '98';
     if(country == "IS") countryCode = '354';
     if(country == "IT") countryCode = '39';
     if(country == "JM") countryCode = '809';
     if(country == "JO") countryCode = '962';
     if(country == "JP") countryCode = '81';
     if(country == "KP") countryCode = '850';
     if(country == "LA") countryCode = '856';
     if(country == "MK") countryCode = '389';
     if(country == "ML") countryCode = '223';
     if(country == "MQ") countryCode = '596';
     if(country == "KE") countryCode = '254';
     if(country == "KG") countryCode = '7';
     if(country == "KH") countryCode = '855';
     if(country == "KI") countryCode = '686';
     if(country == "KM") countryCode = '269';
     if(country == "KR") countryCode = '82';
     if(country == "KW") countryCode = '965';
     if(country == "KY") countryCode = '984';
     if(country == "KZ") countryCode = '7';
     if(country == "LB") countryCode = '961';
     if(country == "LC") countryCode = '809';
     if(country == "LI") countryCode = '41';
     if(country == "LK") countryCode = '94';
     if(country == "LR") countryCode = '231';
     if(country == "LS") countryCode = '266';
     if(country == "LT") countryCode = '7';
     if(country == "LU") countryCode = '352';
     if(country == "LV") countryCode = '7';
     if(country == "LY") countryCode = '218';
     if(country == "MA") countryCode = '212';
     if(country == "MC") countryCode = '33';
     if(country == "MD") countryCode = '7';
     if(country == "MG") countryCode = '261';
     if(country == "MM") countryCode = '95';
     if(country == "MN") countryCode = '976';
     if(country == "MR") countryCode = '222';
     if(country == "MS") countryCode = '809';
     if(country == "MT") countryCode = '356';
     if(country == "MU") countryCode = '230';
     if(country == "MX") countryCode = '52';
     if(country == "MY") countryCode = '60';
     if(country == "MZ") countryCode = '258';
     if(country == "NA") countryCode = '264';
     if(country == "NC") countryCode = '687';
     if(country == "NE") countryCode = '227';
     if(country == "NG") countryCode = '234';
     if(country == "NI") countryCode = '505';
     if(country == "NL") countryCode = '31';
     if(country == "NO") countryCode = '47';
     if(country == "NP") countryCode = '977';
     if(country == "NU") countryCode = '683';
     if(country == "NZ") countryCode = '64';
     if(country == "OM") countryCode = '968';
     if(country == "PA") countryCode = '507';
     if(country == "PE") countryCode = '51';
     if(country == "PF") countryCode = '689';
     if(country == "PG") countryCode = '675';
     if(country == "PH") countryCode = '63';
     if(country == "PK") countryCode = '92';
     if(country == "PL") countryCode = '48';
     if(country == "PR") countryCode = '1-787';
     if(country == "PT") countryCode = '351';
     if(country == "PY") countryCode = '595';
     if(country == "QA") countryCode = '974';
     if(country == "RO") countryCode = '40';
     if(country == "RU") countryCode = '7';
     if(country == "RW") countryCode = '250';
     if(country == "SA") countryCode = '966';
     if(country == "SC") countryCode = '248';
     if(country == "SD") countryCode = '249';
     if(country == "SE") countryCode = '46';
     if(country == "SG") countryCode = '65';
     if(country == "SI") countryCode = '386';
     if(country == "SK") countryCode = '421';
     if(country == "SL") countryCode = '232';
     if(country == "SN") countryCode = '221';
     if(country == "SO") countryCode = '252';
     if(country == "SR") countryCode = '597';
     if(country == "SV") countryCode = '503';
     if(country == "SZ") countryCode = '268';
     if(country == "TD") countryCode = '235';
     if(country == "TF") countryCode = '1809';
     if(country == "TG") countryCode = '228';
     if(country == "TH") countryCode = '66';
     if(country == "TJ") countryCode = '7';
     if(country == "TK") countryCode = '690';
     if(country == "TM") countryCode = '7';
     if(country == "TN") countryCode = '216';
     if(country == "TO") countryCode = '676';
     if(country == "TR") countryCode = '90';
     if(country == "TT") countryCode = '809';
     if(country == "TW") countryCode = '886';
     if(country == "TZ") countryCode = '255';
     if(country == "UA") countryCode = '7';
     if(country == "UG") countryCode = '256';
     if(country == "UK") countryCode = '44';
     if(country == "US") countryCode = '1';
     if(country == "UY") countryCode = '598';
     if(country == "UZ") countryCode = '7';
     if(country == "VA") countryCode = '39';
     if(country == "VE") countryCode = '58';
     if(country == "VG") countryCode = '809';
     if(country == "VI") countryCode = '1-340';
     if(country == "VN") countryCode = '84';
     if(country == "VU") countryCode = '678';
     if(country == "YE") countryCode = '967';
     if(country == "YT") countryCode = '269';
     if(country == "YU") countryCode = '389';
     if(country == "ZA") countryCode = '27';
     if(country == "ZM") countryCode = '260';
     if(country == "ZW") countryCode = '263';
	 if(country == "US") countryCode = '';

	 var usatel0 = $("#usa_tel0");
     usatel0.val(countryCode);
//	 if (countryCode != '' && countryCode != 1){
//		 no_local();
//	 }else{
//		 is_local();
//	 }
}

function no_local(){
	var usatel1 = $("#usa_tel1");
	var usatel2 = $("#usa_tel2");
	var usatel3 = $("#usa_tel3");
	var tip_1 = 'Code';
	var tip_2 = 'Number';
	var tip_3 = 'Ext.';

	usatel1.attr('maxlength',4);
	usatel2.attr('maxlength',8);
	usatel3.attr('maxlength',4);
	document.getElementById("usa_tel2").size = 8;
	document.getElementById("usa_tel3").size = 4;
	
	if (usatel1.val() == ''){
		usatel1.val(tip_1);
	}
	if (usatel2.val() == ''){
		usatel2.val(tip_2);
	}
	if (usatel3.val() == ''){
		usatel3.val(tip_3);
	}
	
	usatel1.blur(function(){
		if ((usatel1.val())=='') usatel1.val(tip_1);
	});
	usatel2.blur(function(){
		if ((usatel2.val())=='') usatel2.val(tip_2);
	});
	usatel3.blur(function(){
		if ((usatel3.val())=='') usatel3.val(tip_3);
	});
	
	usatel1.focus(function(){
		if (usatel1.val()==tip_1) usatel1.val('');
	});
	usatel2.focus(function(){
		if (usatel2.val()==tip_2) usatel2.val('');
	});
	usatel3.focus(function(){
		if (usatel3.val()==tip_3) usatel3.val('');
	});
}

function is_local(){
	var usatel1 = $("#usa_tel1");
	var usatel2 = $("#usa_tel2");
	var usatel3 = $("#usa_tel3");
	var tip_1 = 'Code';
	var tip_2 = 'Number';
	var tip_3 = 'Ext.';

	document.getElementById("usa_tel2").size = 8;
	document.getElementById("usa_tel3").size = 4;
	usatel1.attr('maxlength',3);
	usatel2.attr('maxlength',3);
	usatel3.attr('maxlength',4);
	usatel1.val('');
	usatel2.val('');
	usatel3.val('');
	
	usatel1.blur(function(){
		if ((usatel1.val())=='' || usatel1.val()=='Cod') usatel1.val('');
	});
	usatel1.focus(function(){
		if ((usatel1.val())=='' || usatel1.val()=='Cod') usatel1.val('');
	});
	usatel2.blur(function(){
		if ((usatel2.val())=='' || usatel2.val()=='Num') usatel2.val('');
	});
	usatel2.focus(function(){
		if ((usatel2.val())=='' || usatel2.val()=='Num') usatel2.val('');
	});
	usatel3.blur(function(){
		if ((usatel3.val())=='' || usatel3.val()=='Ext.') usatel3.val('');
	});
	usatel3.focus(function(){
		if ((usatel3.val())=='' || usatel3.val()=='Ext.') usatel3.val('');
	});
}
