

	var iconOK = "<span class='iconOK'></span>";
	var iconNO = "<span class='iconNo'></span>";

String.prototype.trim = function(){var ptntrim = /(^\s*)|(\s*$)/g;return this.replace(ptntrim, "");}
function $() {var elements = new Array();for (var i = 0; i < arguments.length; i++) {var element = arguments[i];if (typeof element == 'string') element = document.getElementById(element);if (arguments.length == 1)return element;elements.push(element);}  return elements;}
//function createEl(t,i,l,x){var e = document.createElement(t); if (i) {e.id = i;} if (l) {e.style.paddingLeft = l +'px';} if (x) { e.appendChild(document.createTextNode(x)); } return e;}

function getEvent(){
	return event;
}

function CMS_send(url)
{
   try {
      var oBao = new ActiveXObject("Msxml2.XMLHTTP");
	   oBao.open("POST", url, false);
	   oBao.send();
	   returnValue = unescape(oBao.responseText);
   }
   catch(e) {
      return "error";
   }
}


//判断手机号码
String.prototype.isMobile = function() {  
  return (/^(?:13\d|15[389])-?\d{5}(\d{3}|\*{3})$/.test(this.trim()));  
}

String.prototype.isNumber = function(){
	return (/^[0-9]+$/.test(this.trim()));
}

//判断日期格式
isDate = function(date, fmt ) {
	if (fmt==null) fmt="yyyy-MM-dd";
	var yIndex = fmt.indexOf("yyyy");
	if(yIndex==-1) return false;
	var year = date.substring(yIndex,yIndex+4);
	var mIndex = fmt.indexOf("MM");
	if(mIndex==-1) return false;
	var month = date.substring(mIndex,mIndex+2);
	var dIndex = fmt.indexOf("dd");
	if(dIndex==-1) return false;
	var day = date.substring(dIndex,dIndex+2);
	if(!isNumber(year)||year>"2900" || year< "1900") return false;
	if(!isNumber(month)||month>"12" || month< "01") return false;
	if(day>getMaxDay(year,month) || day< "01") return false;
	return true;
}
 
function getMaxDay(year,month) {
if(month==4||month==6||month==9||month==11)
return "30";
if(month==2)
if(year%4==0&&year%100!=0 || year%400==0)
return "29";
else
return "28";
return "31";
}

//String.prototype.
checkNumber = function(){
	k = event.keyCode; 
	if((k<48 || k>57 )&&k!=8)
		return false;
}
checkFloat = function(){
	k = event.keyCode; 
	if(k!=48 && k!=49 && k!=50 && k!=51 && k!=52 & k!=53 && k!=54 &&k!=55 && k!=56 && k!=57 && k!=110 && k!=8)
		return false;
}

function showMenu(_menu,_width,_height){
	
	var _lefter = event.clientX;
	var _leftoff = event.offsetX;
	var _topper = event.clientY;
	var _topoff = event.offsetY;
	
	$(_menu).style.pixelTop = _topper - _topoff + 20;
	$(_menu).style.pixelLeft = _lefter - _leftoff - 2;
	$(_menu).style.pixelWidth = _width;
	$(_menu).style.pixelHeight = _height;
	$(_menu).style.position = 'absolute';
	$(_menu).style.display = 'block';
	
}



var oPopup = window.createPopup();

function showMenu1(menu, width, height){
	var lefter = event.clientX;
	var leftoff = event.offsetX;
	var topper = event.clientY;
	var topoff = event.offsetY;
	
	var oPopBody = oPopup.document.body;
	moveMe = 0
	elo=window.event.srcElement;

	if (menu == "tableMenu")	{
		moveMe = 0;
	}

	var HTMLContent = eval(menu).innerHTML
	oPopBody.innerHTML = '<link rel="stylesheet" href="images/style.css" type="text/css">'
	oPopBody.innerHTML += HTMLContent
	oPopup.show(lefter - leftoff - 5 - moveMe, topper - topoff + 20, width, height, document.body);
	
	return false;
}

function contextHilite(menu){
    menu.runtimeStyle.backgroundColor = "Highlight";
    if (menu.state){
        menu.runtimeStyle.color = "GrayText";
    } else {
        menu.runtimeStyle.color = "HighlightText";
    }
}

function contextDelite(menu){
    menu.runtimeStyle.backgroundColor = "";
    menu.runtimeStyle.color = "";
}







	function writeAlbumFrame(_albumid,_picUrl,_picDescription,_width,_height,_userid,_username,_readnum,_wWidth,_wHeight,_type,_pictureid,_description){
		if(!_width) var _width = 100;
		if(!_height) var _height = 100;
		if(!_userid) var _userid = "";
		if(!_username) var _username = "";
		if(!_readnum) var _readnum = "";
		if(!_wWidth) var _wWidth = 160;
		if(!_wHeight) var _wHeight = 190;
		var vHTML = '<div style="float:left;width:'+ _wWidth +'px;height:'+ _wHeight +'px;">';
		
		if(_type=='picture'){
			vHTML += '<table class="album" cellpadding=0 cellspacing=0 border=0>';
			vHTML += '	<tr class="top">';
			vHTML += '		<td style="border:1px solid #c0c0c0;background:#fff;padding:3px;"><a href="album.php?AlbumID='+ _albumid +'&PictureID='+ _pictureid +'"><img src="automini.php?src='+ _picUrl +'&size='+ _width +','+ _height +'" border="0" title="'+ _picDescription +'"></a></div></td>';
			vHTML += '	</tr>';
			vHTML += '	<tr style="word-wrap:break-word;">';
			vHTML += '		<td style="color:#707070" align="center"><nobr>';
			//if(_description!='')
				vHTML += '<div style="margin:2 0 2 0;"><a href="album.php?AlbumID='+ _albumid +'&PictureID='+ _pictureid +'"><style="width:'+ _width +'px;overflow:hidden;">'+_description.substr(0,10)+'</span></a>&nbsp;</div>';
			if(_readnum)
				vHTML += ' <div style="width:'+ _width +';overflow:hidden;">'+_readnum+'</div>';
			if(_picDescription!='')
				vHTML += '<div style="margin:2 0 2 0;">来自:<a href="album.php?AlbumID='+ _albumid +'"><b>'+_picDescription.substr(0,7)+'</span></a></div>';
			//if(_userid!='')
			//	vHTML += '<a href="user.php?UserID='+ _userid +'"><span style="width:'+ _width +'px;overflow:hidden;"><b>'+ _username +'</b></span></a>';
			vHTML += '		</nobr></td>';
			vHTML += '	</tr>';
			vHTML += '</table>';
			
		}
		else{
			vHTML += '<table class="album" cellpadding=0 cellspacing=0 border=0>';
			vHTML += '	<tr class="top">';
			vHTML += '		<td class="left"><a href="album.php?AlbumID='+ _albumid +'"><img src="automini.php?src='+ _picUrl +'&size='+ _width +','+ _height +'" border="0" title="'+ _picDescription +'"></a></div></td>';
			vHTML += '		<td class="right"></td>';
			vHTML += '	</tr>';
			vHTML += '	<tr class="bottom">';
			vHTML += '		<td class="left"></td>';
			vHTML += '		<td class="right"></td>';
			vHTML += '	</tr>';
			vHTML += '	<tr style="word-wrap:break-word;">';
			vHTML += '		<td colspan=2 style="color:#707070" align="center"><nobr>';
			if(_picDescription!='')
				vHTML += '<a href="album.php?AlbumID='+ _albumid +'"><style="width:'+ _width +'px;overflow:hidden;">'+_picDescription.substr(0,10)+'</span></a><br>';
			if(_userid!='')
				vHTML += '<a href="user.php?UserID='+ _userid +'"><span style="width:'+ _width +'px;overflow:hidden;"><b>'+ _username +'</b></span></a>';
			if(_readnum)
				vHTML += ' <br><span style="width:'+ _width +';overflow:hidden;">人气:'+_readnum+'</span>';
			vHTML += '		</nobr></td>';
			vHTML += '	</tr>';
			vHTML += '</table>';
		}
		vHTML += '</div>';
		//_parentObj.innerHTML = vHTML;
		return vHTML;
	}
	
	function writeAlbum(_arrAlbum,_type){
		if(_arrAlbum){
			if(_arrAlbum.length){
				for(i=0;i<_arrAlbum.length;i++){
					var _arr = _arrAlbum[i].split('|');
					var _userid = (_arr[5])?_arr[5]:'';
					var _username = (_arr[6])?_arr[6]:'';
					var _readnum = (_arr[7])?_arr[7]:'';
					var _wWidth = (_arr[8])?_arr[8]:'';
					var _wHeight = (_arr[9])?_arr[9]:'';
					var _pictureid = (_arr[10])?_arr[10]:'';
					var _description = (_arr[11])?_arr[11]:'';
					if(typeof(_type)=='undefinded') _type = 'album';
					document.write (writeAlbumFrame(_arr[0],_arr[1],_arr[2],_arr[3],_arr[4],_userid,_username,_readnum,_wWidth,_wHeight,_type,_pictureid,_description));
				}
			}
		}
	}
	
	
	function doSearch(){
		var searchTypeText = $('sTypeText').innerText;
		var searchType = $('sType').value.trim();
		var searchText = $('sText').value.trim();
		
		if(searchText=='') return;
		
		if(searchType=='tags')
			var _url="tags.php?tag="+ encodeURI(searchText);
		else
			var _url="search.php?searchType="+ searchType +"&searchText="+ encodeURI(searchText);
		location.href = _url;
	}
	
	function plusTextarea(_obj,_max){
		if(typeof(_max)=='undefined'){
			_max = 0;
		}
		if(_max==0 || parseInt(_obj.rows) < _max)
			_obj.rows = parseInt(_obj.rows) + 5;
	}
	function minusTextarea(_obj,_min){
		if(typeof(_min)=='undefined'){
			_min = 14;
		}
		if(parseInt(_obj.rows) > _min){
			_obj.rows = parseInt(_obj.rows) - 5;
		}
	}
	
	function openDialog(_url,_width,_height){
		return showModalDialog(_url,"","dialogWidth:"+ _width +"px;dialogHeight:"+ _height +"px;help:0;status:0;scroll:no");
	}
	
	
	
	
function ClickLineTR(obj,_other){
	var i=0;
	if(typeof(_other)=='undefined') _other = '';
	//alert(obj.parentNode.tagName);
	var tb = obj.parentNode.getElementsByTagName('TR');
	for(i=1;i<tb.length;i++){
		if(_other!='' && tb[i].className!=_other)
			tb[i].className = '';
	}
	obj.className = 'trSlt';
}

function ClickLine(obj){

	checkbox = obj.parentNode.getElementsByTagName('input');
	for(j=0;j<checkbox.length;j++){
		if ( checkbox[j] && checkbox[j].type == 'checkbox' && !checkbox[j].disabled ) {
			if ( checkbox[j].checked == false ) {
				checkbox[j].checked = true;
				obj.parentNode.className="trSlt";
			}
			else{
				//checkbox[j].checked = false;
				//obj.parentNode.className="";
			}	
		//	alert(obj.parentNode.tagName);
		//	alert(obj.parentNode.className);
		}
	}
	
}



//关于checkbox选择
ie = document.all?1:0
function SALL(CB,form){
	if(CB.checked){
		for (var i=0;i<form.elements.length;i++){
			var e = form.elements[i];
			if(e.type=='checkbox'&&!e.disabled&&e!=CB){
				e.checked=true;
				hL(e);
			}
		}
	}
	else{
		for (var i=0;i<form.elements.length;i++){
	        var e = form.elements[i];
			if(e.type=='checkbox'&&!e.disabled&&e!=CB){
				e.checked = false;
				dL(e);
			}
		}
	}
}
function SA(form){
//全选
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if(e.type=='checkbox'){
			e.checked=true;
			hL(e);
		}
	}
}
function SAA(form){
//反向选择
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if(e.type=='checkbox'){
			if (e.checked){
				e.checked = false;
				dL(e);
			}
			else{
				e.checked = true;
				hL(e);
			}
		}
	}
}
function CSA(form){
//取消选择
	for (var i=0;i<form.elements.length;i++){
        var e = form.elements[i];
		if(e.type=='checkbox'){
			e.checked = false;
			dL(e);
		}
	}
}
function SCAc(CB,form){
//选择单个Checkbox
	if (CB.checked) 
		hL(CB);
	else 
		dL(CB);	
}
function SCAr(CB,form){
//选择单个Radio
	for (var i=0;i<form.elements.length;i++){
        var e = form.elements[i];
		dL(e);
	}
	if (CB.checked) 
		hL(CB);
	//else 
	//	dL(CB);	
}
function hL(E){
	if (ie)	{
		while (E.tagName!='TR') 
			E=E.parentElement;	
	}
	else{
		while (E.tagName!='TR')
			E=E.parentNode;
	}
	E.className = 'trSlt';
}
function dL(E){
	if (ie)	{
		while (E.tagName!='TR') 
			E=E.parentElement;	
	}
	else{ 
		while (E.tagName!='TR') 
			E=E.parentNode;
	}
	E.className = '';
}
