﻿// JScript 文件
var delivery_option_array = new Array('delivery_mode_f2f', 'delivery_mode_guya','delivery_mode_mail');
function DOMCall(name) {
	if (document.getElementById)
    	return document.getElementById(name);
	else if (document.all)
		return document.all[name];
	else if (document.layers)
		return document.layers[name];
	else if (document.getElementByName)
		return document.getElementByName(name);
}

function showMe(pid,pclass,produt_Type) {	
	var pop_out;	
	if (pid != '') {
		//pop_out_loading = '<table width="266" cellspacing="0" cellpadding="0" style="border: 1px solid #666666"><tr><td>';
		pop_out_loading = '<table width="100%" bgcolor="#BFC6C4" cellspacing="2" cellpadding="10" style="border: 5px solid white">';
		//pop_out_loading += '<tr><td><img src="../images/payment/pixel_trans.gif" border="0" alt="" width="100%" height="18"></td></tr>';
		pop_out_loading += '<tr><td align="center"><img src="../images/payment/loading.gif" border="0" alt="" width="20" height="20"></td></tr>';
		//pop_out_loading += '<tr><td><img src="../images/payment/pixel_trans.gif" border="0" alt="" width="100%" height="18"></td></tr>';
		pop_out_loading += '</table>';
		//pop_out_loading += '</td></tr></table>';
		var myWidth = 0, myHeight = 0;		
		if (typeof(window.innerWidth) == 'number') {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		
		if (typeof(document.getElementById('theLayer')) != 'undefined' && document.getElementById('theLayer') != null) {
			document.getElementById('theLayer').style.left = ((myWidth / 2) - 133)+"px";
			document.getElementById('theLayer').style.top = (f_scrollTop() + 262)+"px";
			document.getElementById('theLayer').innerHTML = pop_out_loading;
			document.getElementById('theLayer').style.visibility = "visible";
		}				
		
		if (typeof(document.getElementById('theLayerIframe')) != 'undefined' && document.getElementById('theLayerIframe') != null) {
			document.getElementById('theLayerIframe').style.left = ((myWidth / 2) - 133)+"px";
			document.getElementById('theLayerIframe').style.top = (f_scrollTop() + 262)+"px";
			document.getElementById('theLayerIframe').style.visibility = "visible";
		}
		
		var products_info=""; //游戏信息
		var products_name="";//信息title
		var products_gameName="";
		var products_gameRegion="";
		var products_gameServer="";
		var products_price="";
		var cbo=new CallBackObject();
	    this.id=pid;
	    this.action=pclass;
        cbo.OnComplete=function(responseText, responseXML){      
        if(responseText.indexOf('product_result') < 0){
             hideme();
             alert('Error,Please log in first.');location.href='reg.aspx';;   
        }else{	 	                
            var cn_sec=responseXML.getElementsByTagName("product_result")
            for(var i=0;i<cn_sec.length;i++){       
                products_info=cn_sec[i].getElementsByTagName("product_info")[0].firstChild.data.replace(/[\r\n]/g,"")//游戏信息                                   
				products_gameName=cn_sec[i].getElementsByTagName("product_gamename")[0].firstChild.data.replace(/[\r\n]/g,"") //游戏名称
				products_gameRegion=cn_sec[i].getElementsByTagName("product_gameregion")[0].firstChild.data.replace(/[\r\n]/g,"")//游戏派系
				products_gameServer=cn_sec[i].getElementsByTagName("product_gameserver")[0].firstChild.data.replace(/[\r\n]/g,"")//游戏服务器
				products_price=cn_sec[i].getElementsByTagName("product_price")[0].firstChild.data.replace(/[\r\n]/g,"") //价钱
				product_Units=cn_sec[i].getElementsByTagName("product_Units")[0].firstChild.data.replace(/[\r\n]/g,"") //单位
				product_Money=cn_sec[i].getElementsByTagName("product_Money")[0].firstChild.data.replace(/[\r\n]/g,"") //货币名称
				product_Number=cn_sec[i].getElementsByTagName("product_Number")[0].firstChild.data.replace(/[\r\n]/g,"") //数量
				//pop_out = '<table width="390" cellspacing="0" cellpadding="0" style="border: 1px solid #666666;"><tr><td>';
				pop_out = '<table width="100%" bgcolor="#bfc6c4" cellspacing="2" cellpadding="10" style="border: 5px solid white;"><tr><td>';
				pop_out += '<input id="buyqty" type="hidden" name="buyqty" value="1">';
				pop_out += '<input id="buy_now_qty" type="hidden" name="buy_now_qty" value="'+pid+'">';	//关键字
				pop_out += '<input id="products_bundle" type="hidden" name="products_bundle" value="'+pclass+'">';//类型
				pop_out +='<input id="products_Type" type="hidden" name="products_Type" value="'+produt_Type+'">'
				pop_out += '<input id="product_Title" type="hidden" name="product_Title" value="'+product_Number+'">'		
				pop_out += '<input id="gamename" type="hidden" name="gamename" value="'+products_gameName+'">';
				pop_out += '<input id="gameregion" type="hidden" name="gameregion" value="'+products_gameRegion+'">';
				pop_out += '<input id="gameserver" type="hidden" name="gameserver" value="'+products_gameServer+'">';
				pop_out += '<input id="price" type="hidden" name="price" value="'+products_price+'">';
				pop_out += '<table border="0" width="100%" bgcolor="#bfc6c4" cellspacing="0" cellpadding="2">';
				pop_out += '<tr><td colspan="3">'+products_info+'';
				pop_out += 'for '+product_Number+'&nbsp;'+product_Units+'&nbsp;'+product_Money+'<br></td></tr>';			       
				pop_out += '<tr><td colspan="3"><b>delivery information</b></td></tr>';
				pop_out += '<tr><td colspan="3"><img src="../images/payment/pixel_black.gif" border="0" alt="" width="100%" height="1"></td></tr>';
				pop_out += '<tr><td align="right" colspan="3"><div style="color:#ff0000; text-align:right;">&nbsp;* required</div></td></tr>';	
				pop_out += '<tr><td><input type="radio" value="1" name="extra_info[delivery_mode]" id="delivery_mode_f2f" onClick="showDeliveryInfo(1)" style="background:#BFC6C4; color:#000000;width:25px;" ><label for="delivery_mode_f2f">Face to face trade</label></td>';
				pop_out += '<td><input type="radio" value="2" name="extra_info[delivery_mode]" id="delivery_mode_guya" onClick="showDeliveryInfo(2)" style="background:#BFC6C4; color:#000000;width:20px;" ><label for="delivery_mode_guya">Put into my account</label></td>';	
				pop_out+='<td><input type="radio" value="3" name="extra_info[delivery_mode]" id="delivery_mode_mail" onClick="showDeliveryInfo(3)" style="background:#BFC6C4; color:#000000;width:20px;" ><label for="delivery_mode_mail">Mail</label></td></tr>';      
				pop_out += '<tr height="40"><td class="smalltext" colspan="3"><div id="delivery_mode_note" style="border: 1px solid #ff0000; background-color: #ffffed; padding: 1px;">';
				pop_out+='Please ensure that you filled in an accurate "in game time" for a timely delivery.';
				pop_out+='</div></td></tr>';
				pop_out += '<tr><td align="right" class="smalltext" width="35%">character name:</td><td class="smalltext" colspan="2"><div align="left"><input type="text" size="45" id="extra_info_char_name" style="border:solid 1px #666666; width:100px;"> <span class="redindicator">*</span></div></td></tr>';
				pop_out += '<tbody id="delivery_sec_1" ><tr><td align="right" class="smalltext">in game time:</td><td class="smalltext" colspan="2"><div align="left"><input type="text" size="10" id="extra_info_char_online_hr" style="border:solid 1px #666666; width:100px;"> <span class="redindicator">*</span>hour(s) <img src="../images/payment/help_info.gif" border="0" alt="" width="12" height="12" onmouseover="ddrivetip(\'this is the time when you are going to log into the game after checkout in hours.\', \'\', 250);" onmouseout="hideddrivetip();"></div></td></tr>';
				pop_out += '<tr><td align="right" class="smalltext">in game duration:</td><td class="smalltext" colspan="2"><div align="left"><input type="text" size="10" id="extra_info_char_online_dur" style="border:solid 1px #666666; width:100px;"> hour(s) <img src="../images/payment/help_info.gif" border="0" alt="" width="12" height="12" onmouseover="ddrivetip(\'this is the approximate duration will be logged into the game in hours.\', \'\', 220);" onmouseout="hideddrivetip();"></div></td></tr></tbody>';				
				pop_out += '<tbody id="delivery_sec_2" style=\"display:none\"><tr><td align="right" class="smallText">Account name:</td><td class="smallText" colspan="2"><div align="left"><input type="text" size="45" id="extra_info_char_account_name" style="border:solid 1px #666666; width:100px;"> <span class="redIndicator">*</span></div></td></tr>';
				pop_out += '<tr><td align="right" class="smallText">Password:</td><td class="smallText" colspan="2"><div align="left"><input type="text" size="45" id="extra_info_char_account_pwd" style="border:solid 1px #666666; width:100px;"> <span class="redIndicator">*</span></div></td></tr></tbody>';
				pop_out += '<tbody id="delivery_sec_3" ><tr><td colspan="3"></td></tr></tbody>';
				pop_out += '<tr><td></td><td class="smalltext" colspan="2"><div id="div_action_msg" style="color:red;"></div><td></tr>';
				pop_out += '<tr><td class="smalltext" colspan="3"><br><img src="../images/payment/pixel_black.gif" border="0" alt="" width="100%" height="1"></td></tr>';
				pop_out += '<tr><td></td><td colspan="2"><table border="0" cellspacing="0" cellpadding="2"><tr><td><a href="javascript:;" onclick="hideme();"><font color="#000"><u>cancel</u></font>&nbsp;&nbsp;</td><td><img src="../images/payment/submit.gif" style="border:none; cursor:pointer;" alt="" onclick="add_to_cart_form_checking();" /></td></tr></table></td></tr>';		
				pop_out += '</table></td></tr></table>';
				//pop_out += '</td></tr></table>';
		        if (typeof(document.getElementById('theLayer')) != 'undefined' && document.getElementById('theLayer') != null)
			        document.getElementById('theLayer').innerHTML = pop_out;                
                }
            }
        };             
        cbo.DoCallBackPost("../ajax/AjaxOrder.aspx","id="+this.id+"&action="+this.action+"");
    }
}
function hideme() {
	if (typeof(document.getElementById('theLayer')) != 'undefined' && document.getElementById('theLayer') != null) {
		document.getElementById('theLayer').style.visibility = "hidden";
	}
	if (typeof(document.getElementById('theLayerIframe')) != 'undefined' && document.getElementById('theLayerIframe') != null) {
		document.getElementById('theLayerIframe').style.visibility = "hidden";
	}
}

function add_to_cart_form_checking () {    
	var error_message = '';
	var mode = 1;
	var char_name_obj = DOMCall('extra_info_char_name');
	var online_hr_obj = DOMCall('extra_info_char_online_hr');
	var online_dur_obj = DOMCall('extra_info_char_online_dur');
	var char_account_name_obj = DOMCall('extra_info_char_account_name');
	var char_account_pwd_obj = DOMCall('extra_info_char_account_pwd');
	var buy_now_qty=DOMCall('buy_now_qty');
	var products_bundle=DOMCall('products_bundle');
	var gamename=DOMCall('gamename');	
	var gameregion=DOMCall('gameregion');
	var gameserver=DOMCall('gameserver');
	var price=DOMCall('price');	
	var product_type=DOMCall('products_Type');
	var product_Title=DOMCall('product_Title');
	for (var opt_cnt=0; opt_cnt < delivery_option_array.length; opt_cnt++) {
		var tmp_opt_obj = DOMCall(delivery_option_array[opt_cnt]);
		if (tmp_opt_obj != null && tmp_opt_obj.checked) {
			mode = opt_cnt+1;			
		}
	}
	if (char_name_obj != null) {
		if (trim_str(char_name_obj.value) == '') {
			error_message = error_message + "* " + 'Please enter Character name' + "<br>";
		}
	}	
	if (mode == 1) {
		if (online_hr_obj != null) {
			if (trim_str(online_hr_obj.value) != '') {
			 	if (!validateInteger(online_hr_obj.value)) {
					error_message = error_message + "* " + 'Invalid In game time value' + "<br>";
				} else if (online_hr_obj.value > 48) {
					error_message = error_message + "* " + 'In game time cannot be more than 48 hours' + "<br>";
				}
			} else {
				error_message = error_message + "* " + 'Please enter In game time' + "<br>";
			}
		}
		if (online_dur_obj != null) {
			if (trim_str(online_dur_obj.value) != '') {
			 	if (!validateInteger(online_dur_obj.value)) {
					error_message = error_message + "* " + 'Invalid In game duration value' + "<br>";
				} else if (online_dur_obj.value < 1) {
					error_message = error_message + "* " + 'In game duration must be greater than 0' + "<br>";
				} else if (online_dur_obj.value > 24) {
					error_message = error_message + "* " + 'In game duration cannot be more than 24 hours' + "<br>";
				}
			}
		}
	} else if (mode == 2) {
		if (char_account_name_obj != null) {
			if (trim_str(char_account_name_obj.value) == '') {
				error_message = error_message + "* " + 'Please enter Account name' + "<br>";
			}
		}
		if (char_account_pwd_obj != null) {
			if (trim_str(char_account_pwd_obj.value) == '') {
				error_message = error_message + "* " + 'Please enter Password' + "<br>";
			}
		}
	}else if (mode == 3){}
	if (trim_str(error_message) != '') {
		var action_msn_obj = DOMCall('div_action_msg');
		if (action_msn_obj != null)	action_msn_obj.innerHTML = '<table border="0" width="100%" bordercolor="#A7A7A7" bgcolor="#BFC6C4" cellspacing="2" cellpadding="2"><tr><td class="main"><font color="red">'+error_message+'</font></td></tr></table>';
		return false;
	} else {
		var pamartes="action=save&mode="+mode; //交易类型			
		    pamartes+="&char_name_obj="+char_name_obj.value;//角色名
		    pamartes+="&online_hr_obj="+online_hr_obj.value;//在线时间
		    pamartes+="&online_dur_obj="+online_dur_obj.value;//时间描述
		    pamartes+="&char_account_name_obj="+char_account_name_obj.value;//用户名
		    pamartes+="&char_account_pwd_obj="+char_account_pwd_obj.value;//密码		    
			pamartes+="&key="+buy_now_qty.value;//id号
			pamartes+="&pclass="+products_bundle.value;//类型
			pamartes+="&gamename="+gamename.value; //游戏名称id
			//oyster
			pamartes+="&gamefactions="+top.gamefactions; //游戏阵营ID
			
			pamartes+="&gameregion="+gameregion.value; //游戏区	
			pamartes+="&gameserver="+gameserver.value; //游戏服务器	
			pamartes+="&price="+price.value;//价钱			
			pamartes+="&product_type="+product_type.value;//类型
			pamartes+="&product_Title="+product_Title.value;//数量			
		    var cbo=new CallBackObject();
            cbo.OnComplete=function(responseText, responseXML){	                    
	        	if(responseText=="true"){					
					window.location.href='shopping.aspx';					
				}else{			
					alert(responseText);
				}
            };			                       
           cbo.DoCallBackPost("../ajax/AjaxPay.aspx",pamartes);
	}
}


function showDeliveryInfo(mode) {
	var delivery_message_array = new Array('Please ensure that you filled in an accurate "in game time" for a timely delivery.', 'We will log in to your account and transfer the gold onto the character you specified.', 'We will deliver to the character name you specified via in-game mail.');
	var delivery_mode_note_obj = DOMCall('delivery_mode_note');
	if (delivery_mode_note_obj != null) {
		DOMCall('delivery_mode_note').innerHTML = '';
	}
	for (var opt_cnt=0; opt_cnt < delivery_option_array.length; opt_cnt++) {
		var tmp_opt_obj = DOMCall(delivery_option_array[opt_cnt]);
		var opt_pos = opt_cnt+1;
		if (mode == opt_pos) {
			DOMCall('delivery_sec_'+opt_pos).style.display = "";		
			if (delivery_mode_note_obj != null) {
				DOMCall('delivery_mode_note').innerHTML = delivery_message_array[opt_cnt];
			}
		} else {
			DOMCall('delivery_sec_'+opt_pos).style.display = "none";
		}
	}
	var action_msn_obj = DOMCall('div_action_msg');
	if (action_msn_obj != null)	action_msn_obj.innerHTML = '';
}
function AddCookie(strClass,strKey){
    var cbo=new CallBackObject();
        cbo.OnComplete=function(responseText, responseXML){	 	    
        	if(responseText=="true"){
				alert('Item has been put into the shopping cart!');					
			}else{					
				alert('Error,Please log in first.');location.href='reg.aspx';;
			}
        };			
        cbo.DoCallBackPost("../ajax/AjaxCart.aspx","action="+strClass+"&strID="+strKey+""); 
}

function Book(pid,pclass,produt_Type){
    var pop_out;	
	if (pid != '') {
		//pop_out_loading = '<table width="266" cellspacing="0" cellpadding="0" style="border: 1px solid #666666"><tr><td>';
		pop_out_loading = '<table width="100%" bgcolor="#BFC6C4" cellspacing="2" cellpadding="10" style="border: 5px solid white">';
		//pop_out_loading += '<tr><td><img src="../images/payment/pixel_trans.gif" border="0" alt="" width="100%" height="18"></td></tr>';
		pop_out_loading += '<tr><td align="center"><img src="../images/payment/loading.gif" border="0" alt="" width="20" height="20"></td></tr>';
		//pop_out_loading += '<tr><td><img src="../images/payment/pixel_trans.gif" border="0" alt="" width="100%" height="18"></td></tr>';
		pop_out_loading += '</table>';
		//pop_out_loading += '</td></tr></table>';
		var myWidth = 0, myHeight = 0;		
		if (typeof(window.innerWidth) == 'number') {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		
		if (typeof(document.getElementById('theLayer')) != 'undefined' && document.getElementById('theLayer') != null) {
			document.getElementById('theLayer').style.left = ((myWidth / 2) - 133)+"px";
			document.getElementById('theLayer').style.top = (f_scrollTop() + 262)+"px";
			document.getElementById('theLayer').innerHTML = pop_out_loading;
			document.getElementById('theLayer').style.visibility = "visible";
		}				
		
		if (typeof(document.getElementById('theLayerIframe')) != 'undefined' && document.getElementById('theLayerIframe') != null) {
			document.getElementById('theLayerIframe').style.left = ((myWidth / 2) - 133)+"px";
			document.getElementById('theLayerIframe').style.top = (f_scrollTop() + 262)+"px";
			document.getElementById('theLayerIframe').style.visibility = "visible";
		}		
		var products_info=""; //游戏信息
		var products_name="";//信息title
		var products_gameName="";
		var products_gameRegion="";
		var products_gameServer="";
		var products_price="";
	    var cbo=new CallBackObject();
	    this.id=pid;
	    this.action=pclass;	    
        cbo.OnComplete=function(responseText, responseXML){ 
        if(responseText.indexOf('product_result') < 0){
             hideme();
             alert('Error,Please log in first.');location.href='reg.aspx'
        }else{	 	                                        
            var cn_sec=responseXML.getElementsByTagName("product_result")                    
            for(var i=0;i<cn_sec.length;i++){                           
                products_info=cn_sec[i].getElementsByTagName("product_info")[0].firstChild.data.replace(/[\r\n]/g,"")//游戏信息  
				products_gameName=cn_sec[i].getElementsByTagName("product_gamename")[0].firstChild.data.replace(/[\r\n]/g,"") //游戏名称				
				products_gameRegion=cn_sec[i].getElementsByTagName("product_gameregion")[0].firstChild.data.replace(/[\r\n]/g,"")//游戏派系				
				products_gameServer=cn_sec[i].getElementsByTagName("product_gameserver")[0].firstChild.data.replace(/[\r\n]/g,"")//游戏服务器				
				products_price=cn_sec[i].getElementsByTagName("product_price")[0].firstChild.data.replace(/[\r\n]/g,"") //价钱				
				product_Units=cn_sec[i].getElementsByTagName("product_Units")[0].firstChild.data.replace(/[\r\n]/g,"") //单位				
				product_Money=cn_sec[i].getElementsByTagName("product_Money")[0].firstChild.data.replace(/[\r\n]/g,"") //货币名称				
				product_Number=cn_sec[i].getElementsByTagName("product_Number")[0].firstChild.data.replace(/[\r\n]/g,"") //数量
				//pop_out = '<table width="390px" cellspacing="0" cellpadding="0" style="border: 1px solid #666666;"><tr><td>';
				pop_out = '<table width="100%" bgcolor="#bfc6c4" cellspacing="2" cellpadding="10" style="border: 5px solid white;"><tr><td>';
				pop_out += '<input type="hidden" name="buyqty" value="1">';
				pop_out += '<input type="hidden" name="buy_now_qty" value="'+pid+'">';	//关键字
				pop_out += '<input type="hidden" name="products_bundle" value="'+pclass+'">';//类型
				pop_out +='<input type="hidden" name="products_Type" value="'+produt_Type+'">'
				pop_out += '<input type="hidden" name="product_Title" value="'+product_Number+'">'		
				pop_out += '<input type="hidden" name="gamename" value="'+products_gameName+'">';
				pop_out += '<input type="hidden" name="gameregion" value="'+products_gameRegion+'">';
				pop_out += '<input type="hidden" name="gameserver" value="'+products_gameServer+'">';
				pop_out += '<input type="hidden" name="price" value="'+products_price+'">';	
				pop_out += '<table border="0" width="100%" bgcolor="#bfc6c4" cellspacing="0" cellpadding="2">';		        
				pop_out += '<tr><td colspan="2">'+products_info+'';
				pop_out += 'for '+product_Number+'&nbsp;'+product_Units+'&nbsp;'+product_Money+'<br></td></tr>';
				pop_out += '<tr><td class="smalltext" colspan="2"><b>delivery information</b></td></tr>';
				pop_out += '<tr><td class="smalltext" colspan="2"><br><img src="../images/payment/pixel_black.gif" border="0" alt="" width="100%" height="1"></td></tr>';
				pop_out += '<tr><td align="right" class="requiredinfo" colspan="2"><div style="color:#ff0000; text-align:right;">&nbsp;* required</div></td></tr>';		
				pop_out += '<tr height="40"><td class="smalltext" colspan="2"><div id="delivery_mode_note" style="border: 1px solid #ff0000; background-color: #ffffed; padding: 1px;">';
				pop_out+='Please enter your required number of gold coins.';
				pop_out+='</div></td></tr>';
				pop_out += '<tr><td align="right" class="smalltext" width="35%">character name:</td><td class="smalltext"><input type="text" size="45" id="extra_info_char_name" style="border:solid 1px #666666; width:100px;"> <span class="redindicator">*</span></td></tr>';
				pop_out += '<tr><td align="right" class="smalltext">Valid Hours:</td><td class="smalltext"><input type="text" size="10" id="extra_info_valid_hours" style="border:solid 1px #666666; width:100px;"> <span class="redindicator">*</span>Hours <img src="../images/payment/help_info.gif" border="0" alt="" width="12" height="12" onmouseover="ddrivetip(\'Please enter your valid Hours.\', \'\', 220);" onmouseout="hideddrivetip();"></td></tr></tbody>';						        
				pop_out += '<tr><td class="smalltext" colspan="2"><div id="div_action_msg" style="color:red;"></div><td></tr>';
				pop_out += '<tr><td class="smalltext" colspan="2"><br><img src="../images/payment/pixel_black.gif" border="0" alt="" width="100%" height="1"></td></tr>';
				pop_out += '<tr><td></td><td><table border="0" cellspacing="0" cellpadding="2"><tr><td><a href="javascript:;" onclick="hideme();"><font color="#000"><u>cancel</u></font>&nbsp;&nbsp;</td><td><img src="../images/payment/submit.gif" style="border:none; cursor:pointer;" alt="" onclick="book_checking();" /></td></tr></table></td></tr>';		
				pop_out += '</table></td></tr></table>';
				//pop_out += '</td></tr></table>';		        
		        if (typeof(document.getElementById('theLayer')) != 'undefined' && document.getElementById('theLayer') != null)
			        document.getElementById('theLayer').innerHTML = pop_out;                
                }
            }
        };             
        cbo.DoCallBackPost("../ajax/AjaxOrder.aspx","id="+this.id+"&action="+this.action+"");
    }
}

function book_checking(){
    var error_message = '';
    var char_name_obj = DOMCall('extra_info_char_name');
    var valid_hours_obj=DOMCall('extra_info_valid_hours');
    var action_msn_obj = DOMCall('div_action_msg');
    if (char_name_obj != null) {
		if (trim_str(char_name_obj.value) == '') {
			error_message = error_message + "* " + 'Please enter Character name' + "<br>";
		}
	}
	if(valid_hours_obj != null){
	    if(trim_str(valid_hours_obj.value)==''){
	        error_message = error_message + "* " + 'Please enter your valid Hours.' + "<br>";
	    }
	}
	if (trim_str(error_message) != '') {
		var action_msn_obj = DOMCall('div_action_msg');
		if (action_msn_obj != null)	action_msn_obj.innerHTML = '<table border="0" width="100%" bordercolor="#A7A7A7" bgcolor="#BFC6C4" cellspacing="2" cellpadding="2"><tr><td class="main"><font color="red">'+error_message+'</font></td></tr></table>';
		return false;
	} else {
	    var gamename=DOMCall('gamename');
	    var gameregion=DOMCall('gameregion');
	    var gameserver=DOMCall('gameserver');
	    var price=DOMCall('price');
	    var name=DOMCall('product_Title');	    
	    var buy_now_qty=DOMCall('buy_now_qty');
	    var products_bundle=DOMCall('products_bundle');
	    var pamartes="action=save"; //交易类型			
		    pamartes+="&char_name_obj="+char_name_obj.value;//角色名
		    pamartes+="&valid_hours_obj="+valid_hours_obj.value//在线时间	    
			pamartes+="&key="+buy_now_qty.value;//id号
			pamartes+="&pclass="+products_bundle.value;//类型
			pamartes+="&gamename="+gamename.value; //游戏名称id
			pamartes+="&gameregion="+gameregion.value; //游戏区	
			pamartes+="&gameserver="+gameserver.value; //游戏服务器	
			pamartes+="&price="+price.value;//价钱
			pamartes+="&product_Title="+name.value;//标题	
			pamartes+="&product_type=Gold";					
		    var cbo=new CallBackObject();
            cbo.OnComplete=function(responseText, responseXML){	 	    
	        	if(responseText=="true"){
					alert('Order by success!');	
					hideme();
				}else{					
					alert(responseText);
				}
            };			
          cbo.DoCallBackPost("../ajax/AjaxBook.aspx?"+pamartes,null);
          //location.href = "../ajax/AjaxBook.aspx?"+pamartes;
	}
}

function obj_Buy(pid,pclass){
    var pop_out;	
	if (pid != '') {
		//pop_out_loading = '<table width="266" cellspacing="0" cellpadding="0" style="border: 1px solid #666666"><tr><td>';
		pop_out_loading = '<table width="100%" bgcolor="#BFC6C4" cellspacing="2" cellpadding="10" style="border: 5px solid white">';
		//pop_out_loading += '<tr><td><img src="../images/payment/pixel_trans.gif" border="0" alt="" width="100%" height="18"></td></tr>';
		pop_out_loading += '<tr><td align="center"><img src="../images/payment/loading.gif" border="0" alt="" width="20" height="20"></td></tr>';
		//pop_out_loading += '<tr><td><img src="../images/payment/pixel_trans.gif" border="0" alt="" width="100%" height="18"></td></tr>';
		pop_out_loading += '</table>';
		//pop_out_loading += '</td></tr></table>';
		var myWidth = 0, myHeight = 0;		
		if (typeof(window.innerWidth) == 'number') {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		
		if (typeof(document.getElementById('theLayer')) != 'undefined' && document.getElementById('theLayer') != null) {
			document.getElementById('theLayer').style.left = ((myWidth / 2) - 133)+"px";
			document.getElementById('theLayer').style.top = (f_scrollTop() + 262)+"px";
			document.getElementById('theLayer').innerHTML = pop_out_loading;
			document.getElementById('theLayer').style.visibility = "visible";
		}				
		
		if (typeof(document.getElementById('theLayerIframe')) != 'undefined' && document.getElementById('theLayerIframe') != null) {
			document.getElementById('theLayerIframe').style.left = ((myWidth / 2) - 133)+"px";
			document.getElementById('theLayerIframe').style.top = (f_scrollTop() + 262)+"px";
			document.getElementById('theLayerIframe').style.visibility = "visible";
		}		
        //pop_out = '<table width="390px" cellspacing="0" cellpadding="0" style="border: 1px solid #666666;"><tr><td>';
        pop_out = '<table width="100%" bgcolor="#bfc6c4" cellspacing="2" cellpadding="10" style="border: 5px solid white;"><tr><td>';
        pop_out += '<table border="0" width="100%" bgcolor="#bfc6c4" cellspacing="0" cellpadding="2">';        
        pop_out += '<input type="hidden" name="pclass" value='+pclass+'>';
        pop_out += '<input type="hidden" name="key" value='+pid+'>';
        pop_out += '<tr><td class="smalltext" colspan="2"><b>delivery information</b></td></tr>';
        pop_out += '<tr><td class="smalltext" colspan="2"><img src="../images/payment/pixel_black.gif" border="0" alt="" width="100%" height="1"></td></tr>';
        pop_out += '<tr><td align="right" class="requiredinfo" colspan="2"><div style="color:#ff0000; text-align:right;">&nbsp;* required</div></td></tr>';		
        pop_out += '<tr height="40"><td class="smalltext" colspan="2"><div id="delivery_mode_note" style="border: 1px solid #ff0000; background-color: #ffffed; padding: 1px;">';
        pop_out+='Please enter your Contact info.';
        pop_out+='</div></td></tr>';
        pop_out += '<tr><td align="right" class="smalltext" width="100%" colspan="2"><textarea rows="8" style="border:solid 1px #666666; width:350px; background:#fff;" id="extra_info_trade_link"></textarea><span class="redindicator" style="color:red;">*</span></td></tr>';					        
        pop_out += '<tr><td class="smalltext" colspan="2"><div id="div_action_msg" style="color:red;"></div><td></tr>';
        pop_out += '<tr><td class="smalltext" colspan="2"><br><img src="../images/payment/pixel_black.gif" border="0" alt="" width="100%" height="1"></td></tr>';
        pop_out += '<tr><td></td><td><table border="0" cellspacing="0" cellpadding="2" align="center"><tr><td><a href="javascript:;" onclick="hideme();"><font color="#000"><u>cancel</u></font>&nbsp;&nbsp;</td><td><img src="../images/payment/submit.gif" style="border:none; cursor:pointer;" alt="" onclick="Card_checking();" /></td></tr></table></td></tr>';		
        pop_out += '</table></td></tr></table>';
        //pop_out += '</td></tr></table>';		        
        if (typeof(document.getElementById('theLayer')) != 'undefined' && document.getElementById('theLayer') != null)
	        document.getElementById('theLayer').innerHTML = pop_out;                
        }
        
}
function Card_checking(){
    var error_message = '';
    var char_name_obj = DOMCall('extra_info_trade_link');
    if (trim_str(char_name_obj.value) == '') {
				error_message = error_message + "* " + 'Please enter  your Contact info' + "<br>";
	}
	if (trim_str(error_message) != '') {
		var action_msn_obj = DOMCall('div_action_msg');
		if (action_msn_obj != null)	action_msn_obj.innerHTML = '<table border="0" width="100%" bordercolor="#A7A7A7" bgcolor="#BFC6C4" cellspacing="2" cellpadding="2"><tr><td class="main"><font color="red">'+error_message+'</font></td></tr></table>';
		return false;
	} else {
        var cbo=new CallBackObject();
        cbo.OnComplete=function(responseText, responseXML){	 	    
  	        if(responseText=="true"){		    
		        window.location.href='shopping.aspx';
	        }else{					
		        alert(responseText);
	        }
        };			
        var pamartes="action=save";
            pamartes+="&pclass="+DOMCall('pclass').value;
            pamartes+="&key="+DOMCall('key').value; 
            pamartes+="&product_links="+char_name_obj.value;             
        cbo.DoCallBackPost("../ajax/AjaxPay.aspx",pamartes);
    }
}