<?php
include_once "tadtools_header.php";

//取得jquery路徑，$mode="google"、"xoops"、"default","link","none"
//$theme=ui-lightness , base
if(!function_exists('get_jquery')){
  function get_jquery($ui=false,$mode="local",$theme='base'){
    $xoopsModuleConfig=TadToolsXoopsModuleConfig();
    //die("jquery_mode:{$xoopsModuleConfig['jquery_mode']}");

    switch($xoopsModuleConfig['jquery_mode']){
      case "none":
      $jquery_path="";
      break;

      case "local":
      $jqueryui_path="";
      if($ui){
        /*
        $jqueryui_path="
        if(typeof jQuery.ui == 'undefined'){
        document.write(\"<link href='".TADTOOLS_URL."/jquery/themes/{$theme}/jquery.ui.all.css' rel='stylesheet' type='text/css'><script src='".TADTOOLS_URL."/jquery/ui/jquery-ui.js'><\/script>\");
        }";
        */
        $jqueryui_path="
        <link href='".TADTOOLS_URL."/jquery/themes/{$theme}/jquery.ui.all.css' rel='stylesheet' type='text/css'><script src='".TADTOOLS_URL."/jquery/ui/jquery-ui.js'></script>";
      }

      $jquery_path="
      <script type='text/javascript'>
        if(typeof jQuery == 'undefined') {
        document.write(\"<script type='text/javascript' src='".TADTOOLS_URL."/jquery/jquery.js'><\/script>\");
        }
      </script>
      $jqueryui_path
      ";

      break;


      case "google":
      default:
      $google_api_key=get_google_api_key();

      $jquery_ui=$ui_css="";
      if($ui){
        $jquery_ui="google.load('jqueryui', '1.8.16');";
        $ui_css="<link href='".TADTOOLS_URL."/jquery/themes/{$theme}/jquery.ui.all.css' rel='stylesheet' type='text/css'/>";
      }
      $jquery_path="
      <script type='text/javascript' src='http://www.google.com/jsapi?key={$google_api_key}'></script>
      
      <script type='text/javascript'>
      	google.load('jquery', '1.6.4');
      	$jquery_ui
      </script>

      $ui_css";
      break;
    }

    return $jquery_path;
  }
}


?>
