﻿/* * * *
 *	通用AJAX交互程序包
 *
 *	Date : 2008年1月22日
 *	说明 : 该程序包基于JQUERY框架1.1版本，请在使用该程序前包含该框架 
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

//var aqualife_host = "http://www.aqualife.org.cn";
var aqualife_host = "http://"+location.host+"/";

 function getLoginTemp(tempName, Id){
	base_getTemp(tempName, Id) ;
 }

 /**
  *	GET TEMPLATE [BASE FUNCTION]
  * 
  * * */
  function base_getTemp(tempName, Id) {
	
	var Url = "http://www.lasooo.com/test/index.php?module=user&file=api&action=login" ;
	//var Url = "http://www.lasooo.com/test/index.php?module=tempapi&file=tempapi" ;
	var Action = "temp="+tempName ;
	
	Data = {type:"POST",
			dataType:"html",
			url:Url,
			beforeSend:function(beferAddUser){
				$("#"+Id).html("Waiting Please  ......").show("normal") ;
			},
			complete:function(result,state){parseResult(result,state,Id)},
			data:Action } ;
	$.ajax(Data) ;

  }
  
 /**
  *	GET TEMPLATE [BASE FUNCTION]
  * 
  * * */
  function parseResult( result,state, Id ) {
	if ( 'success' == state ){
		$("#"+Id).html(result.responseText) ;
	}else{
		$("#"+Id).html("Request failure!") ;
	}

  }
  
  function admin_showEvent(Id){
    var Url = aqualife_host+"/admin/chatManagement/showEvent.php?mth="+Math.random();
	
	Data = {type:"get",
			dataType:"html",
			url:Url,
			beforeSend:function(beferAddUser){
				$("#"+Id).html("Waiting Please  ......").show("normal") ;
			},
			complete:function(result,state){parseResult(result,state,Id)}} ;
	$.ajax(Data);
  }
  
// admin webevent
function admin_sendMessage(Id,msg,mid){
    
    var Url = aqualife_host+"/admin/chatManagement/sendMessage.php?msg="+msg.replace("&","|amp;|")+"&mid="+mid+"&mth="+Math.random();
	
	    Data = {type:"get",
	    		dataType:"html",
	    		url:Url,
	    		beforeSend:function(beferAddUser){
	    			$("#"+Id).html("Waiting Please  ......").show("normal") ;
	    		},
	    		complete:function(result,state){parseResult(result,state,Id)}} ;
	    $.ajax(Data) ;
}
  
  // webevent
function sendMessage(Id,msg,mid){
    
    var Url = aqualife_host+"/en/resources/webevent/sendMessage.php?msg="+msg.replace("&","|amp;|")+"&mid="+mid+"&mth="+Math.random();
	
    Data = {type:"get",
			dataType:"html",
			url:Url,
			beforeSend:function(beferAddUser){
				$("#"+Id).html("Waiting Please  ......").show("normal") ;
			},
			complete:function(result,state){parseResult(result,state,Id)}} ;
    $.ajax(Data) ;
}

  // webevent
function webevent_checkonline(Id,msg,mid){
    
    var Url = aqualife_host+"/en/resources/webevent/checkonline.php?msg="+msg.replace("&","|amp;|")+"&mid="+mid+"&mth="+Math.random();
	
    Data = {type:"get",
			dataType:"html",
			url:Url,
			beforeSend:function(beferAddUser){
				$("#"+Id).html("Waiting Please  ......").show("normal") ;
			},
			complete:function(result,state){parseResult(result,state,Id)}} ;
    $.ajax(Data) ;
}

    // get top and left navigation
  function get_navigation(Id) {
	
	var Url = aqualife_host+"/my_navigation.php" ;
	
	Data = {type:"get",
			dataType:"html",
			url:Url,
			beforeSend:function(beferAddUser){
				$("#"+Id).html("Waiting Please  ......").show("normal") ;
			},
			complete:function(result,state){parseResult(result,state,Id)}} ;
	$.ajax(Data) ;

  }
  
  //function faqMethod(Id,keywords,keywords_cn,act){
    //var Url = aqualife_host+"/admin/CMS/FAQ/faqFunction.php?keywords="+keywords+"&keywords_cn="+keywords_cn+"&action="+act+"&mth="+Math.random();
  function faqMethod(Id,keywords,act){
    var Url = aqualife_host+"/admin/CMS/FAQ/faqFunction.php?keywords="+keywords+"&action="+act+"&mth="+Math.random();
	Data = {type:"get",
			dataType:"html",
			url:Url,
			beforeSend:function(beferAddUser){
				$("#"+Id).html("Waiting Please  ......").show("normal") ;
			},
			complete:function(result,state){parseResult(result,state,Id)}} ;
	$.ajax(Data) ;
  }
  
  function faqSearch(Id,lng,keywords,cid){
    var Url = aqualife_host+"/"+lng+"/resources/faq/faqsearch.php?keywords="+keywords+"&cid="+cid+"&mth="+Math.random();
	Data = {type:"get",
			dataType:"html",
			url:Url,
			beforeSend:function(beferAddUser){
				$("#"+Id).html("Waiting Please  ......").show("normal") ;
			},
			complete:function(result,state){parseResult(result,state,Id)}} ;
	$.ajax(Data) ;
  }
  
  function faqSearch_cn(Id,keywords,cid){
    var Url = aqualife_host+"/cn/resources/faq/faqsearch.php?keywords="+keywords+"&cid="+cid+"&mth="+Math.random();
	Data = {type:"get",
			dataType:"html",
			url:Url,
			beforeSend:function(beferAddUser){
				$("#"+Id).html("Waiting Please  ......").show("normal") ;
			},
			complete:function(result,state){parseResult(result,state,Id)}} ;
	$.ajax(Data) ;
  }
  
  // get forgotten password
  function getPWBack(Id,e_name,e_mail) {
	var Url = aqualife_host+"/en/about/get_passwordBackByEmail.php?ename="+e_name+"&email="+e_mail+"&tmp="+Math.random() ;
	
	Data = {type:"get",
			dataType:"html",
			url:Url,
			beforeSend:function(beferAddUser){
				$("#"+Id).html("Waiting Please  ......").show("normal") ;
			},
			complete:function(result,state){parseResult(result,state,Id)}} ;
	$.ajax(Data) ;

  }
  
  function get_quiz_result(Id,q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,q14,mid){
    var Url = aqualife_host+"/en/content/quiz/check_answer.php?module_id="+mid
            +"&1="+q1
            +"&2="+q2
            +"&3="+q3
            +"&4="+q4
            +"&5="+q5
            +"&6="+q6
            +"&7="+q7
            +"&8="+q8
            +"&9="+q9
            +"&10="+q10
            +"&11="+q11
            +"&12="+q12
            +"&13="+q13
            +"&14="+q14;
	
	Data = {type:"get",
			dataType:"html",
			url:Url,
			beforeSend:function(beferAddUser){
				$("#"+Id).html("Waiting Please  ......").show("normal") ;
			},
			complete:function(result,state){parseResult(result,state,Id)}} ;
	$.ajax(Data) ;
  }
  
  //---  Execute part  ---//
  $(document).ready(function(){
	  
	  //---  load login template  ---
	  //getLoginTemp("login", "test");
	  
  });