var Base={
	setCookie:function(sName, sValue){
		var date=new Date();
		date.setTime(date.getTime()+31536000000);
		document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString();
	},
    delCookie:function(sName){
        if(Base.getCookie(name)){
            document.cookie=sName+"="+((domain)?"; domain="+dm:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";
        }
    },
	getCookie:function(sName){
		var aCookie = document.cookie.split("; ");
		for (var i=0; i < aCookie.length; i++)
		{
			var aCrumb = aCookie[i].split("=");
			if (sName == aCrumb[0]) 
				return unescape(aCrumb[1]);
		}
		return "";
	},
    trimL:function(txt){
		return txt.replace(/^\s*/,"");
	},
    trimR:function(txt){
		return txt.replace(/\s*$/,"");
	},
    trim:function(txt){
		return this.trimL(this.trimR(txt));
	},
	/*check explorer type
	*/
	isIE6:function(){
		return navigator.userAgent.indexOf('MSIE')>0&&navigator.userAgent.indexOf('6')>0;
	},
	isIE:function(){
		return navigator.userAgent.indexOf('MSIE')>0;
	},
	isOpera:function(){
		return navigator.userAgent.indexOf('Opera')>-1;
	},
	isMoz:function(){
		return navigator.userAgent.indexOf('Mozilla/5.')>-1;
	}
};

/*
dom
*/
var Dom={
/*
node
*/
//$ -> getBy
    $id:function(nodeId){
    	if(typeof nodeId=='string'){
    		return document.getElementById(nodeId);
    	}else if(typeof nodeId=='object'){
    		return nodeId;
    	}else{
			return false;
		}
    },
	$idInNode:function(nodeId, pNode){// have not finish
		if(!pNode){
			return Dom.$id(nodeId);
		}else{
			return false;
		}
    },
    $tagInNode:function(tagName, pNode){
		if(!pNode){
			pNode=document;
		}
		reNodes=pNode.getElementsByTagName(tagName);
		if(reNodes&&reNodes.length){
			return reNodes;
		}else{
			return false;
		}
    },
//reXxxx -> use to return value
    $tagInNodeChild:function(tagName, pNode){
		if(!pNode){
			pNode=document;
		}
		var nodes=pNode.childNodes;
		if(!(nodes&&nodes.length)){return false;}
		var reNodes=[];
		for(var i=0; i<nodes.length; i++){
			var node=nodes[i];
			if(node.nodeName.toLowerCase()==tagName){
				reNodes[reNodes.length]=node;
			}
		}
		if(reNodes.length){
			return reNodes;
		}else{
			return false;
		}
    },
    $withClassInNodeChild:function(className, pNode){
		if(!pNode){
			pNode=document;
		}
		var nodes=pNode.childNodes;
		if(!(nodes&&nodes.length)){return false;}
		var reNodes=[];
		for(var i=0; i<nodes.length; i++){
			var node=nodes[i];
			if(node.className.toLowerCase()==className){
				reNodes[reNodes.length]=node;
			}
		}
		if(reNodes.length){
			return reNodes;
		}else{
			return false;
		}
    },
    /*$hasClassInNodeChild:function(className, pNode){},*/
    $tagWithClassInNode:function(tagName, className, pNode){
		var nodes=Dom.$tagInNode(tagName, pNode);
		var reNodes=[];
		for(var i=0; i<nodes.length; i++){
			var node=nodes[i];
			if(Dom.isClass(className, node)){
				reNodes[reNodes.length]=node;
			}
		}
		return reNodes;
	},
    $tagHasClassInNode:function(tagName, className, pNode){
		var nodes=Dom.$tagInNode(tagName, pNode);
		if(!nodes){return false;}
		var reNodes=[];
		for(var i=0; i<nodes.length; i++){
			var node=nodes[i];
			if(Dom.hasClass(className, node)){
				reNodes[reNodes.length]=node;
			}
		}
		if(reNodes.length){
			return reNodes;
		}else{
			return false;
		}
	},
    $tagHasClassInNodeChild:function(tagName, className, pNode){
		var nodes=Dom.$tagInNodeChild(tagName, pNode);
		if(!nodes){return false;}
		var reNodes=[];
		for(var i=0; i<nodes.length; i++){
			var node=nodes[i];
			if(Dom.hasClass(className, node)){
				reNodes[reNodes.length]=node;
			}
		}
		if(reNodes.length){
			return reNodes;
		}else{
			return false;
		}
	},
/*
class
*/
	isClass:function(className, node){
		if((!node)||(!className)){return null;}
		var reFlag=false;
		if(node.className==className){
			reFlag=true;
		}

		return reFlag;
	},
	hasClass:function(className, node){
		if((!node)||(!className)){return null;}
		if(node.className.indexOf(className)!=-1){// need to update
			return true;
		}
		return false;
	},
	addClass:function(className, node){
		if(Dom.hasClass(className, node)){return false;}
		var newClassName=node.className?node.className+' '+className:className;
		node.className=newClassName;
		return true;
	},
	removeClass:function(className, node){
		if(!(Dom.hasClass(className, node))){return true;}
		var nodeClassName=node.className;
		if(nodeClassName==className){
			nodeClassName="";
		}else{
			nodeClassName=Base.trim(nodeClassName.replace(className, ""));
		}
		node.className=nodeClassName;
	},
	replaceClass:function(className, newClassName, node){
		if(!(Dom.hasClass(className, node))){return false;}
		node.className=Base.trim(node.className.replace(className, NewClassName));
	},
	setClass:function(className, node){
		node.className=className;
	},
	clearClass:function(node){
		node.className="";
	}
};

var kEvent={
	addEvent: function(element, name, observer, useCapture) {
		try{
			if(element.addEventListener){
				element.addEventListener(name, observer, useCapture);
			}else if(element.attachEvent){
				element.attachEvent('on' + name, observer);
			}
		}catch(e){}
	}
};

var kStyle={
	blankImgSrc: "/library/image/dot/dot_blank.gif",
	fixPngBg: function(element){
		if(typeof element=='string'){element=Dom.$id(element);}
		if((!(element.currentStyle))||((navigator.appName.toLowerCase().indexOf('internet explorer'))==-1)){return;}
		var xSrc=element.currentStyle.backgroundImage;
		element.style.background="none";
		element.style.filter ="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod='scale', src='"+xSrc.substring(5, xSrc.length-2)+"')";
	},
	fixPngImg: function(element){
		if(typeof element=='string'){element=Dom.$id(element);}
		if((!(element.currentStyle))||((navigator.appName.toLowerCase().indexOf('internet explorer'))==-1)){return;}
		var xSrc=element.src;
		element.src=blankImgSrc;
		element.style.filter ="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod='scale', src='"+xSrc+"')";
	},
	getRealStyle: function(element){
		var reStyle;
		if (element.currentStyle){
			reStyle = element.currentStyle;
		}else if (window.getComputedStyle){
			reStyle = window.getComputedStyle(element, null);
		}else{
			reStyle = null;
		}
		return reStyle;
	},
	setAtt: (function(){
				if (Base.isIE()) {
					return (function(el, property, val) {
						switch (property) {
							case 'opacity':
								if (typeof el.style.filter == 'string' ) {
									el.style.filter = 'alpha(opacity=' + val * 100 + ')';
									if (!el.currentStyle || !el.currentStyle.hasLayout) {
										el.style.zoom = 1;
									}
								}
								break;
							default:
								el.style[property] = val;
						}
					});
				} else {
					return (function(el, property, val) {
						el.style[property] = val;
					});
				}
			})(),
	getAtt: (function(){
		var patterns = {
			HYPHEN: /(-[a-z])/i
		};
		var toCamel = function(property) {
			if ( !patterns.HYPHEN.test(property) ) {
				return property; // no hyphens
			}
			
			if (propertyCache[property]) { // already converted
				return propertyCache[property];
			}
			
			while( patterns.HYPHEN.exec(property) ) {
				property = property.replace(RegExp.$1,
						RegExp.$1.substr(1).toUpperCase());
			}
			
			propertyCache[property] = property;
			return property;
		};

		if (document.defaultView && document.defaultView.getComputedStyle) {
        	return (function(el, property) {
				var value = null;
				
				var computed = document.defaultView.getComputedStyle(el, '');
				if (computed) { // test computed before touching for safari
					value = computed[toCamel(property)];
				}
				
				return el.style[property] || value;
        	});
		} else if (document.documentElement.currentStyle && Base.isIE()) {// IE method
			return (function(el, property) {
				switch( toCamel(property) ) {
					case 'opacity' :// IE opacity uses filter
						var val = 100;
						try { // will error if no DXImageTransform
							val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;
						} catch(e) {
							try { // make sure its in the document
								val = el.filters('alpha').opacity;
							} catch(e) {}
						}
						return val / 100;
						break;
					default:
						// test currentStyle before touching
						var value = el.currentStyle ? el.currentStyle[property] : null;
					return ( el.style[property] || value );
				}
        	});
		} else { // default to inline only
			return (function(el, property) {return el.style[property];});
		}
	})()
	
};


var kAnimator={
	create:function(){
		
	},
	getPV:function(v1, v2, percent, Method){//取进度值
		var reV=(v2-v1)*Math.sin(Math.PI*percent/2)+v1;
		return reV;
	},
	FPS:30
};

Math.getDegree=function(radian){
	return radian*180/(Math.PI);
};
Math.getRadian=function(degree){
	return degree*(Math.PI)/180;
};

Date.prototype.getWeekBegin=function(){
	var tV01=this.getDay()-1;
	if(tV01==-1){tV01=6;}
	return (new Date(this.getTime()-tV01*86400000));
};
Date.prototype.getYMD=function(){
	var reV01=this.getFullYear()+","+(this.getMonth()+1)+","+this.getDate();
	return reV01;
};
Date.prototype.setYMD=function(sYMD){
	try{
		var d=sYMD.split(",");
		this.setFullYear(d[0], d[1]-1, d[2]);
		return this;
	}catch(e){return false;}
};




/*/ <![CDATA[
	//滚动横幅代码
	var scroll_speed=20;
	Dom.$id("ppsh_con_2").innerHTML=Dom.$id("ppsh_con_1").innerHTML;
	var ppsh_ow=Dom.$id("ppsh_con_1").offsetWidth;
	function scrollToLeft(){
		if(Dom.$id("ppsh_box").scrollLeft>=ppsh_ow){
			Dom.$id("ppsh_box").scrollLeft=0;
		}else{
			Dom.$id("ppsh_box").scrollLeft++;
		}
	}
	var timer_toLeft=setInterval("scrollToLeft()",scroll_speed);
	Dom.$id("ppsh_box").onmouseover=function() {clearInterval(timer_toLeft);}
	Dom.$id("ppsh_box").onmouseout=function() {timer_toLeft=setInterval("scrollToLeft()",scroll_speed);}
// ]]>*/
