﻿// ============ ajaxClass ( XMLHttp Object Pool and XMLHttp chunnel Pool ) ============

var Request = new function(){

this.pool = new Array();

this.getXMLHttp = function (chunnel)
{
	
   if(chunnel != null)
   {
      for (var a = 0; a < this.pool.length; a++)
      {
         if(this.pool[a]["chunnel"] == chunnel)
         {
	        if(this.pool[a]["obj"].readyState == 0 || this.pool[a]["obj"].readyState == 4)
            {
               return this.pool[a]["obj"];
            }
	        else 
	        {
               return "busy";
	        }
         }
      }
  
      this.pool[this.pool.length] = new Array();
      this.pool[this.pool.length - 1]["obj"] = this.createXMLHttp();
      this.pool[this.pool.length - 1]["chunnel"] = chunnel;
      return this.pool[this.pool.length - 1]["obj"];
   }
	
   for (var i = 0; i < this.pool.length; i++)
   {
      if(this.pool[i]["obj"].readyState == 0 || this.pool[i]["obj"].readyState == 4)
      {
         return this.pool[i]["obj"];
      }
   }
 
   this.pool[this.pool.length] = new Array();
   this.pool[this.pool.length - 1]["obj"] = this.createXMLHttp();
   this.pool[this.pool.length - 1]["chunnel"] = "";
   return this.pool[this.pool.length - 1]["obj"];

}


this.createXMLHttp = function ()
{
 
   if(window.XMLHttpRequest)
   {
      var xmlObj = new XMLHttpRequest();
   } 
   else 
   {
      var MSXML = ['Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
      for(var n = 0; n < MSXML.length; n++)
      {
         try
         {
            var xmlObj = new ActiveXObject(MSXML[n]);        
            break;
         }
         catch(e)
         {
         }
      }
   } 
 
   return xmlObj;

}


this.reSend = function (url,data,callback,extra,chunnel,isasync)
{
   var objXMLHttp = this.getXMLHttp(chunnel) ;
 
   if(typeof(objXMLHttp) != "object")
   {
      return false ;
   }

   if(isasync==null)
        isasync=true;
  
   if(data == "")
   {
      objXMLHttp.open('GET' , url, isasync);
	  objXMLHttp.setRequestHeader("If-Modified-Since", 0); // no cache
      objXMLHttp.send('');
   }
   else 
   { 
      objXMLHttp.open('POST' , url, isasync);
	  objXMLHttp.setRequestHeader("If-Modified-Since", 0); // no cache
      objXMLHttp.setRequestHeader("Content-Length",data.length); 
      objXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
      objXMLHttp.send(data);
   }
   if(isasync){
       if(typeof(callback) == "function" )
       {
          objXMLHttp.onreadystatechange = function ()
          {
             if(objXMLHttp.readyState == 4)
             {
                if(objXMLHttp.status == 200 || objXMLHttp.status == 304)
                {
                   if(extra != null)
			       {
			          callback(objXMLHttp,extra) ;
    			      
			       }
			       else
			       {
			          callback(objXMLHttp) ;
    			     
			       }
                }
    //            else
    //          {
    //             alert("Error loading page\n" + objXMLHttp.status + ":" + objXMLHttp.statusText);
    //          }
             }
          }
       }
    }else{
       if(typeof(callback) == "function" )
       {
                if(objXMLHttp.status == 200 || objXMLHttp.status == 304)
                {
                   if(extra != null)
			       {
			          callback(objXMLHttp,extra) ;
    			      
			       }
			       else
			       {
			          callback(objXMLHttp) ;
    			     
			       }
                }
    //            else
    //          {
    //             alert("Error loading page\n" + objXMLHttp.status + ":" + objXMLHttp.statusText);
    //          }
       }  
    }

}

}


/*
 * FlashObject embed
 * by Geoff Stearns (geoff@deconcept.com, http://www.deconcept.com/)
 *
 * v1.1.1 - 05-17-2005
 *
 * writes the embed code for a flash movie, includes plugin detection
 *
 * Usage:
 *
 *	myFlash = new FlashObject("path/to/swf.swf", "swfid", "width", "height", flashversion, "backgroundcolor");
 *	myFlash.write("objId");
 *
 * for best practices, see:
 *  http://blog.deconcept.com/2005/03/31/proper-flash-embedding-flashobject-best-practices/
 *
 */

var FlashObject = function(swf, id, w, h, ver, c) {
	this.swf = swf;
	this.id = id;
	this.width = w;
	this.height = h;
	this.version = ver;
	this.align = "middle";

	this.params = new Object();
	this.variables = new Object();

	this.redirect = "";
	this.sq = document.location.search.split("?")[1] || "";
	this.bypassTxt = "<p>Already have Macromedia Flash Player? <a href='?detectflash=false&"+ this.sq +"'>Click here if you have Flash Player "+ this.version +" installed</a>.</p>";
	
	if (c) this.color = this.addParam('bgcolor', c);
	this.addParam('quality', 'high'); // default to high
	this.doDetect = getQueryParamValue('detectflash');
}

var FOP = FlashObject.prototype;

FOP.addParam = function(name, value) { this.params[name] = value; }

FOP.getParams = function() { return this.params; }

FOP.getParam = function(name) { return this.params[name]; }

FOP.addVariable = function(name, value) { this.variables[name] = value; }

FOP.getVariable = function(name) { return this.variables[name]; }

FOP.getVariables = function() { return this.variables; }

FOP.getParamTags = function() {
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    return (paramTags == "") ? false:paramTags;
}

FOP.getHTML = function() {
    var flashHTML = "";
    if (navigator.plugins && navigator.mimeTypes.length) { // netscape plugin architecture
        flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
        for (var param in this.getParams()) {
            flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVariablePairs()) {
            flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
        }

		flashHTML += ' allowScriptAccess="sameDomain"';
        flashHTML += '></embed>';
    } else { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" name="' + this.id + '" align="' + this.align + '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';
		flashHTML += '<param name="allowScriptAccess" value="sameDomain" />'
        if (this.getParamTags()) {
            flashHTML += this.getParamTags();
        }
        if (this.getVariablePairs() != null) {
            flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
        }
        flashHTML += '</object>';
    }
    return flashHTML;	
}

FOP.getVariablePairs = function() {
    var variablePairs = new Array();
    for (var name in this.getVariables()) { 
    	variablePairs.push(name + "=" + escape(this.getVariable(name))); 
    }
    return (variablePairs.length > 0) ? variablePairs.join("&"):false;
}

FOP.write = function(elementId) {
	if(detectFlash(this.version) || this.doDetect=='false') {
		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}
	} else {
		if (this.redirect != "") {
			document.location.replace(this.redirect);
		} else if (this.altTxt) {
			if (elementId) {
				document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
			} else {
				document.write(this.altTxt +""+ this.bypassTxt);
			}
		}
	}		
}

/* ---- detection functions ---- */
function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.mimeTypes.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			var y = x.description;
   			flashversion = y.charAt(y.indexOf('.')-1);
		}
	} else {
		result = false;
	    for(var i = 15; i >= 3 && result != true; i--){
   			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
   			flashversion = i;
   		}
	}
	return flashversion;
}

function detectFlash(ver) {	return (getFlashVersion() >= ver) ? true:false; }

// get value of query string param
function getQueryParamValue(param) {
	var q = document.location.search || document.location.href.split("#")[1];
	if (q) {
		var detectIndex = q.indexOf(param +"=");
		var endIndex = (q.indexOf("&", detectIndex) > -1) ? q.indexOf("&", detectIndex) : q.length;
		if (q.length > 1 && detectIndex > -1) {
			return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
		} else {
			return "";
		}
	}
}

/* add Array.push if needed */
if(Array.prototype.push == null){
	Array.prototype.push = function(item) { this[this.length] = item; return this.length; }
}

// ============================== js prototype or for ie5.5 ↓ ===================================

// -- for ie 5 push
if(!Array.prototype.push) {
   Array.prototype.push = function (new_ele) {
        this[this.length] = new_ele;
        return this.length;
   }
}

// -- for ie 5 splice
if(!Array.prototype.splice) {
	Array.prototype.splice = function () {
		var start = arguments[0];
		var deleteCount = arguments[1];
		var len = arguments.length - 2;
		var returnValue = this.slice(start);
		for (var i = 0; i < len; i++) {
			this[start + i] = arguments[i + 2];
		}
		for (var i = 0; i < returnValue.length - deleteCount; i++) {
			this[start + len + i] = returnValue[deleteCount + i];
		}
		this.length = start + len + returnValue.length - deleteCount;
		returnValue.length = deleteCount;
		return returnValue;
	}
}

// -- for ie 5.5↓ encodeURI

if(typeof(encodeURI) == "undefined")
{
	function encodeURI(str) {
		var l = ['%00', '%01', '%02', '%03', '%04', '%05', '%06',
				 '%07', '%08', '%09', '%0A', '%0B', '%0C', '%0D',
				 '%0E', '%0F', '%10', '%11', '%12', '%13', '%14',
				 '%15', '%16', '%17', '%18', '%19', '%1A', '%1B',
				 '%1C', '%1D', '%1E', '%1F', '%20', '!', '%22',
				 '#', '$', '%25', '&', "'", '(', ')', '*', '+', ',',
				 '-', '.', '/', '0', '1', '2', '3', '4', '5', '6',
				 '7', '8', '9', ':', ';', '%3C', '=', '%3E', '?',
				 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
				 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
				 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '%5B', '%5C',
				 '%5D', '%5E', '_', '%60', 'a', 'b', 'c', 'd', 'e',
				 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
				 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
				 'z', '%7B', '%7C', '%7D', '~', '%7F'];
		var out, i, j, len, c, c2;
	
		out = [];
		len = str.length;
		for (i = 0, j = 0; i < len; i++) {
			c = str.charCodeAt(i);
			if (c <= 0x007F) {
				out[j++] = l[c];
				continue;
			}
			else if (c <= 0x7FF) {
				out[j++] = '%' + (0xC0 | ((c >>  6) & 0x1F)).toString(16).toUpperCase();
				out[j++] = '%' + (0x80 | (        c & 0x3F)).toString(16).toUpperCase();
				continue;
			}
			else if (c < 0xD800 || c > 0xDFFF) {
				out[j++] = '%' + (0xE0 | ((c >> 12) & 0x0F)).toString(16).toUpperCase();
				out[j++] = '%' + (0x80 | ((c >>  6) & 0x3F)).toString(16).toUpperCase();
				out[j++] = '%' + (0x80 |         (c & 0x3F)).toString(16).toUpperCase();
				continue;
			}
			else {
				if (++i < len) {
					c2 = str.charCodeAt(i);
					if (c <= 0xDBFF && 0xDC00 <= c2 && c2 <= 0xDFFF) {
						c = ((c & 0x03FF) << 10 | (c2 & 0x03FF)) + 0x010000;
						if (0x010000 <= c && c <= 0x10FFFF) {
							out[j++] = '%' + (0xF0 | ((c >>> 18) & 0x3F)).toString(16).toUpperCase();
							out[j++] = '%' + (0x80 | ((c >>> 12) & 0x3F)).toString(16).toUpperCase();
							out[j++] = '%' + (0x80 | ((c >>>  6) & 0x3F)).toString(16).toUpperCase();
							out[j++] = '%' + (0x80 |          (c & 0x3F)).toString(16).toUpperCase();
							continue;
						}
					}
				}
			}
		}
		return out.join('');
	}
}

// -- for ie 5.5↓ encodeURIComponent
if(typeof(encodeURIComponent) == "undefined") 
{
	function encodeURIComponent(str) {
		var l = ['%00', '%01', '%02', '%03', '%04', '%05', '%06',
				 '%07', '%08', '%09', '%0A', '%0B', '%0C', '%0D',
				 '%0E', '%0F', '%10', '%11', '%12', '%13', '%14',
				 '%15', '%16', '%17', '%18', '%19', '%1A', '%1B',
				 '%1C', '%1D', '%1E', '%1F', '%20', '!', '%22',
				 '%23', '%24', '%25', '%26', "'", '(', ')', '*', '%2B', '%2C',
				 '-', '.', '%2F', '0', '1', '2', '3', '4', '5', '6',
				 '7', '8', '9', '%3A', '%3B', '%3C', '%3D', '%3E', '%3F',
				 '%40', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
				 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
				 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '%5B', '%5C',
				 '%5D', '%5E', '_', '%60', 'a', 'b', 'c', 'd', 'e',
				 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
				 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
				 'z', '%7B', '%7C', '%7D', '~', '%7F'];
		var out, i, j, len, c;
	
		out = [];
		len = str.length;
		for(i = 0, j = 0; i < len; i++) {
			c = str.charCodeAt(i);
			if (c <= 0x007F) {
				out[j++] = l[c];
				continue;
			}
			else if (c <= 0x7FF) {
				out[j++] = '%' + (0xC0 | ((c >>  6) & 0x1F)).toString(16).toUpperCase();
				out[j++] = '%' + (0x80 | (        c & 0x3F)).toString(16).toUpperCase();
				continue;
			}
			else if (c < 0xD800 || c > 0xDFFF) {
				out[j++] = '%' + (0xE0 | ((c >> 12) & 0x0F)).toString(16).toUpperCase();
				out[j++] = '%' + (0x80 | ((c >>  6) & 0x3F)).toString(16).toUpperCase();
				out[j++] = '%' + (0x80 |         (c & 0x3F)).toString(16).toUpperCase();
				continue;
			}
			else {
				if (++i < len) {
					c2 = str.charCodeAt(i);
					if (c <= 0xDBFF && 0xDC00 <= c2 && c2 <= 0xDFFF) {
						c = ((c & 0x03FF) << 10 | (c2 & 0x03FF)) + 0x010000;
						if (0x010000 <= c && c <= 0x10FFFF) {
							out[j++] = '%' + (0xF0 | ((c >>> 18) & 0x3F)).toString(16).toUpperCase();
							out[j++] = '%' + (0x80 | ((c >>> 12) & 0x3F)).toString(16).toUpperCase();
							out[j++] = '%' + (0x80 | ((c >>>  6) & 0x3F)).toString(16).toUpperCase();
							out[j++] = '%' + (0x80 |          (c & 0x3F)).toString(16).toUpperCase();
							continue;
						}
					}
				}
			}
		}
		return out.join('');
	}
}

// ============================== string html ubb ===================================

// -- ubb bb => img
function uncodeUbb(str){
    str = str.replace(/\[BB(\d+)\]/gi, '<img alt="" src="http://r.c-sma.com/imges/qqface/BB$1.gif" />');
	return str ;
}

// -- limit ubb num
function limitUbb(str){
  var ubbNum = 3 ;
  for(var i=0 ; i < ubbNum ; i++){
     str = str.replace(/\[BB(\d+)\]/i, '<BB$1>');
  }  
  str = str.replace(/\[BB(\d+)\]/ig, '') ; 
  for(var i=0 ; i < ubbNum ; i++){
     str = str.replace(/<BB(\d+)>/i, '[BB$1]');
  }  
  return str ;
}

// -- en htmlSpecialchars 
function enhtmlchars(str) {
	str = str.replace(/</g , '&lt;').replace(/>/g , '&gt;') ;
	str = str.replace(/"/g , '&quot;').replace(/'/g , '&#039;') ;
	str = str.replace(/ /g , '&nbsp;') ;
	return str ;
}

// -- de htmlSpecialchars 
function dehtmlchars(str) {
	str = str.replace(/&lt;/g , '<').replace(/&gt;/g , '>') ;
	str = str.replace(/&quot;/g , '"').replace(/&#039;/g , "'") ;
	str = str.replace(/&nbsp;/g , ' ') ;
	return str ;
}

function htmlToUbb(str ,ext){
	var arr = ext.split(',') ; 
	if(in_array('all' , arr))
		return str.replace(/</g , "[").replace(/>/g , "]") ;
	else {
		for(var i=0 ; i < arr.length; i++) {
			if(arr[i] == 'img')
				str = str.replace(/<img[^>]+src=['"][^>]*bb(\d+)\.gif[^>]*>/ig , "[BB$1]") ;
			else {
				var a = arr[i] ;
				str = str.replace(new RegExp('<' + a + '[^>]*>([^<]*)<\\/' + a + '>' , 'ig'), '[' + a + ']$1[/' + a + ']') ;
			}
		}
	}
	str = str.replace(/<br[^>]*>/ig , browser.msie ? "\n" : '') ;
	return str ;
}

function clearHtml(str , ext) {
	var arr = ext.split(',') ;
	for(var i=0; i < arr.length ; i++) {
		var a = arr[i]
		if(a == 'aimg')
			str = str.replace(/<a[^>]*><img[^>]+><\/a>/ig  , "") ;
		else
			str = str.replace(new RegExp('<' + a + '[^>]*>[\\s\\S]*<\\/' + a + '>' , 'ig')  , "") ;
	}
	return str ;
}

function stripHtml(str , ext) {
	var arr = ext.split(',') ;
	if(in_array('all' , arr))
		return str.replace(/<\/?[^>]+>/gi, '');
	else {
		for(var i=0 ; i < arr.length ; i++) {
			var a = arr[i] ;
			str = str.replace(new RegExp('(<' + a + '[^>]*>)|(<\\/' + a + '>)' , 'ig') ,"") ;
		}
	}
	return str ;
}

// ============================== num  ===================================

// -- get rand
function getRand(n1, n2) {
	var equNum = Math.abs(n1 - n2) + 1;
	var lowNum = Math.min(n1 , n2) ;
	return n1 + Math.floor(equNum*Math.random()) ;
}


// ============================== browser navigator ===================================

var browser = new Object(); 
function getBrowser() {
	var b = navigator.userAgent.toLowerCase();
	browser = { 
		safari: /webkit/.test(b),
		opera: /opera/.test(b),
		ie6: /msie 6/.test(b) && !/opera/.test(b),
		ie7: /msie 7/.test(b) && !/opera/.test(b),
		msie: /msie/.test(b) && !/opera/.test(b),
		mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
	};
}
getBrowser() ;

// ============================== element ===================================

// --- by className
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];		
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}	
	}
	return (arrReturnElements)
}

// --- by AttributeValue
function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}

// --- add class
function addClassName(oElm, strClassName){
	var strCurrentClass = oElm.className;
	if(!new RegExp(strClassName, "i").test(strCurrentClass)){
		oElm.className = strCurrentClass + ((strCurrentClass.length > 0)? " " : "") + strClassName;
	}
}

// --- remove calss
function removeClassName(oElm, strClassName){
	var oClassToRemove = new RegExp(('(^|\\s)' + strClassName + "($|\\s)"), "i");
	oElm.className = oElm.className.replace(oClassToRemove, "").replace(/^\s*|\s*$/g, "");
}

// --- renturn input value 
function sketch(objId){
	return document.getElementById(objId).value;
}

// ============================== style ===================================

// --- ai ---
function setStyle (element, style) { 
	for (var name in style) {
		if(name != 'opacity')
			element.style[name] = style[name] ;
		else
			setOpacity(element , parseInt(style[name])) ;
	}
}

// --- ai ---
function getStyle (element, style) {
	var value = null ; 
	
	if(style != 'opacity')
		value = element.style[style] ;
	else
		value = getOpacity(element) ;
		
	return value == 'auto' ? null : value ;
}

function setOpacity(element,num) {
	num = (num > 1) ?  num : num*100 ;
	if(browser.msie)
		element.filters.alpha.opacity = num ;
	else if(browser.mozilla)
		element.style.opacity = num/100 ;
}

function getOpacity(element) {
	if(browser.msie)
		return element.filters.alpha.opacity ;
	else if(browser.mozilla) { 
		if (document.defaultView && document.defaultView.getComputedStyle) { 
			var css = document.defaultView.getComputedStyle(element, null);
			value = css ? css.getPropertyValue('opacity') : null;
			return value*100 ;
		}
	}		
}

function displaySelect(type) {
	var selArr = document.body.getElementsByTagName('select') ;
	var selValue = type ? 'visible' : 'hidden' ;
	for(var i=0 ; i < selArr.length ; i++) {
		selArr[i].style.visibility = selValue ;
	}
}


// ============================== event ===================================

// -- add event 

function a_addEvent(oElm , strEvent , fuc) {
	strEvent = strEvent.replace(/^on/i , '') ;
	if(browser.msie)
		oElm.attachEvent('on' + strEvent , fuc) ;
	else 
		oElm.addEventListener(strEvent , fuc , false) ;
}

// -- remove event 
function a_removeEvent(oElm , strEvent , fuc) {
	strEvent = strEvent.replace(/^on/i , '') ;
	if(browser.msie)
		oElm.detachEvent('on' + strEvent , fuc) ;
	else 
		oElm.removeEventListener(strEvent , fuc , false) ;
}

// -- return event value
function returnEventValue (type , evt) {
	var ret ; 
	switch(type) {
		case 'srcElement' : 
			ret = evt.srcElement ? evt.srcElement : evt.target ;
			break ;
		case 'clientX' :
			ret = evt.clientX ? evt.clientX : evt.pageX ;
			break ;
		case 'clientY' :
			ret = evt.clientY ? evt.clientY : evt.pageY ;
			break ;
		case 'keyCode' :
			ret = evt.keyCode ? evt.keyCode : evt.which ;
			break ;
	}
	return ret ;	
}

// -- stop event down
// v -> 默认动作 || b -> 事件传递 
function stopEvent(evt , type){
	if (evt.preventDefault) {
		if(type == 'v' || type == null) evt.preventDefault();
		if(type == 'b' || type == null) evt.stopPropagation();
	}
	else{
		if(type == 'v' || type == null) evt.returnValue = false;
		if(type == 'b' || type == null) evt.cancelBubble = true;     
	}
}



// ============================== cookie ===================================

function getExpTime(time,type){
    var expTime = new Date();
	switch(type) {
		case 'year' :
			expTime.setFullYear(expTime.getFullYear() + time );
			break ;
		case 'month' :
			expTime.setMonth( expTime.getMonth() + time );
			break;
		case 'day' :
			expTime.setDate( expTime.getDate() + time );
			break;
		case 'hour' :
			expTime.setHours( expTime.getHours() + time );
			break;
	}
    return expTime.toGMTString();
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return decodeURIComponent(document.cookie.substring(offset, endstr));
}

function getCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen){
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return "";
}

function setCookie(name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + encodeURIComponent(value) +
	((expires) ? "; expires=" + expires : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}


function delCookie(name){
	var guoqu = new Date();
	expiresTime = guoqu.setTime(guoqu.getTime() - 100);
	setCookie(name,'',expiresTime,'/','.c-sma.com') ;
}


// ------ 加入收藏 ------

function bookmark(){
	var title = document.title
	var url = document.location.href
	if (browser.mozilla) 
		window.sidebar.addPanel(title, url,"");
	else if(browser.opera){
		var mbm = document.createElement('a');
		mbm.setAttribute('rel','sidebar');
		mbm.setAttribute('href',url);
		mbm.setAttribute('title',title);
		mbm.click();
	}
	else if(browser.msie) 
		window.external.AddFavorite( url, title);
}

//=========================== 设置文章内容字体大小 ==============================
	function SetFontSize(font_size,target)
	{
		//设置指定指定区域的字体大小，并自动设置行间距
		var _box = document.getElementById(target);
		if(_box)
		{
			_box.style.fontSize = font_size+"px";
			_box.style.lineHeight = (font_size * 1.5)+"px";
		}
	}