<?php
/**
 * @version        Somao_Search X1.0 9:23 2012-1-1 Somao $
 * @package        Somao_Search.Site
 * @copyright      Copyright (c) 2009 - 2012, Somao, Inc.
 * @license        http://www.somao123.com/
 * @link           http://www.somao.cc/
**/
?>
var arrCSS=[<?php
	   $dir="templates";
       $dp = opendir($dir);
	   $aryRaw = array();
       while ($file = readdir($dp)) { 
	   $arrPath = explode ( ".",$file );
       $strPath = array_pop( $arrPath );
	   
               if ($file!='.' && $file!='..') {
				   $i++ ;
                   array_push( $aryRaw , $file);
                   $path = $dir ."/". $file;
                   if (is_dir($path)) {
  ?>
  ["<img src='/templates/<?php echo $file;?>/bg.jpg' width='160' height='80' class='themes' alt='ËÑÃ¨Æ¤·ô'>","/templates/<?php echo $file;?>/css.css"],
  <?php
             }
          }  
       }
    closedir($dp);
  ?>""];
function readCookie(name) { 
	var search; 
	search = name + "="; 
	offset = document.cookie.indexOf(search); 
	if (offset != -1) { 
		offset += search.length; 
		end = document.cookie.indexOf(";", offset); 
		if (end == -1){
			end = document.cookie.length;
		}
		return unescape(document.cookie.substring(offset, end)); 
	}else{
		return "";
	}
}
function writeCSS(){
  for(var i=1;i<arrCSS.length;i++){
    document.write('<link title="'+arrCSS[i][1]+'" href="'+arrCSS[i][1]+'" rel="stylesheet" disabled="true" type="text/css" />');
  }
    setStyleSheet(readCookie("stylesheet"));
}

function setStyleSheet(strCSS){
  var objs=document.getElementsByTagName("link");
  var intFound=0;
  for(var i=0;i<objs.length;i++){
    if(objs[i].type.indexOf("css")>-1&&objs[i].title){
      objs[i].disabled = true;
      if(objs[i].title==strCSS) intFound=i;
    }
  }
  objs[intFound].disabled = false;
}
writeCSS();