//default.js
function externalLinks()
{
    if (!document.getElementsByTagName) return;

    var anchors = document.getElementsByTagName("a");

    for (var i = 0; i < anchors.length; i++)
    {
        var anchor = anchors[i];

        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
        {
            anchor.target = "_blank";
        }
    }
}

window.onload = externalLinks;

function verifyOneCheckMinimum(formName, msg, prefix)
{
    n = "all";

    if (prefix)
    {
        n = prefix + n;
    }

    f = document.getElementById(formName);
    i = 0;
    j = 0;

    while (e = f.elements[i])
    {
        if (e.type == "checkbox" && e.id != n && e.checked)
        {
            if (!prefix || e.id.indexOf(prefix) != -1)
            {
                j++;
            }
        }

        i++;
    }

    result = (j > 0);

    if (!result && msg)
    {
        alert(msg);
    }

    return result;
}

function submitForm(formName, opValue, msg)
{
    if (msg)
    {
        if (!verifyOneCheckMinimum(formName))
        {
            alert(msg);
            return false;
        }
    }

    f = document.getElementById(formName);
    f.op.value = opValue;
    return true;
}

function toggleAllChecks(formName, prefix)
{
    n = "all";

    if (prefix)
    {
        n = prefix + n;
    }

    i = 0;
    e = document.getElementById(n);
    s = e.checked;
    f = document.getElementById(formName);

    while (e = f.elements[i])
    {
        if (e.type == "checkbox" && e.id != n)
        {
            if (!prefix || e.id.indexOf(prefix) != -1)
            {
                e.checked = s;
            }
        }

        i++;
    }
}

function confirmDlg(l, msg)
{
    if (confirm(msg))
    {
        if (typeof(l) == 'string')
        {
            document.location.href = l;
        }
        else
        {
            document.location.href = l.href;
        }
    }

    return false;
}

function popUp(l, n, f)
{
    if (!window.focus)
    {
        return true;
    }

    if (typeof(l) == 'string')
    {
        window.open(l, n, f);
    }
    else
    {
        window.open(l.href, n, f);
    }

    return false;
}

function goTo(l)
{
    window.location.href = l;
}

function goToIf(l, msg)
{
    if (confirm(msg))
    {
        window.location.href = l;
    }
}
//common.js
/**
 * opens a window with some help information
 *
 * @param helpurl The destination url
 * @return nothing
 */ 
function help_window(helpurl)
{
	HelpWin = window.open( helpurl,'HelpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
}

/**
 * opens a window pointing to the list of resources so that we can easily add one to our current
 * article
 *
 * @param type
 * @return nothing
 */
function resource_list_window( type ) {
	// type == 1 => intro text
	// type == 2 => extended text
	HelpWin = window.open( '?op=resourceList&mode='+type,'ResourceListWindow','scrollbars=yes,resizable=yes,toolbar=no,height=600,width=450');

}

function userPictureSelectWindow()
{
	UserPicture = window.open( '?op=userPictureSelect', 'UserPictureSelect','scrollbars=yes,resizable=yes,toolbar=no,height=600,width=400');
}

/**
 * empties a drop-down list
 *
 * @param box The form object representing the drop-down list
 * @return nothing
 */
function emptyList( box )
{
	while ( box.options.length ) box.options[0] = null;
}

/**
 * fill a list with data
 *
 * @param box
 * @param numElems
 * @return nothing
 */
function fillList( box, numElems )
{
	for ( i = 1; i <= numElems; i++ ) {
		option = new Option( i, i );
		box.options[box.length] = option;
	}
	
	box.selectedIndex=0;
}

/**
 * @private 
 * @param box
 * @return nothing
 */
function changeList( box )
{
	daysMonth = days[box.options[box.selectedIndex].value-1];
	emptyList( box.form.postDay );
	fillList( box.form.postDay, daysMonth );
}

/**
 * Adds some text where the cursor is.
 *
 * Works in IE and Mozilla 1.3b+
 * In other browsers, it simply adds the text at the end of the current text
 */
function addText( input, insText ) 
{
	input.focus();
	if( input.createTextRange ) {
		parent.opener.document.selection.createRange().text += insText;
	} 
	else if( input.setSelectionRange ) {
		var len = input.selectionEnd;
		input.value = input.value.substr( 0, len ) + insText + input.value.substr( len );
		input.setSelectionRange(len+insText.length,len+insText.length);
	} 
	else { 
		input.value += insText; 
	}
}

/**
 * Used in the' user profile' screen where users can pick an image from their collection
 * and set it as their 'avatar'
 *
 * @param resId
 * @param url
 * @return nothing
 */
function returnResourceInformation(resId, url)
{
	// set the picture id
    parent.opener.document.userSettings.userPictureId.value = resId;
    // and reload the image path
    parent.opener.document.userSettings.userPicture.src = url;
}

/**
 * opens a window to see an screenshot from a template
 *
 * @param destination url
 */
function openScreenshotWindow( destUrl )
{
	ScreenshotWindow = window.open( destUrl, 'Screenshot','scrollbars=yes,resizable=yes,toolbar=no,height=600,width=800');
}

/**
 * opens the window where users can choose their own template. The destination url is hardcoded
 */
function openTemplateChooserWindow()
{
	TemplateSelectorWindow = window.open( '?op=blogTemplateChooser', 'TemplateChooser','scrollbars=yes,resizable=yes,toolbar=no,height=600,width=450');
}

/**
 * tells the parent window which template we chose
 */
function blogTemplateSelector( templateId )
{
	templateSelectList = parent.opener.document.blogSettings.blogTemplate;
	
	// loop throough the array with the different template sets and if we find the
	// one that the use just selected, then automatically select it and quit the loop
	for( i = 0; i < templateSelectList.options.length; i++ ) {
		if( templateSelectList.options[i].value == templateId ) {
			templateSelectList.selectedIndex = i;
			break;
		}
	}
	
	window.close();
}

/**
 * in the "newBlogUser" screen, shows and hides the 'notification area', a textbox
 * where users can type some text that will be included in an email sent to the user that is
 * going to be invited to the blog
 */
function toggleNotificationArea()
{
    var elem = document.getElementById('emailTextNotification');
    if( elem.style.display == 'none' )
      elem.style.display = '';
    else
      elem.style.display = 'none';
      
    return true;  
}

/**
 * the functions below are used in the "global settings" page, so that 
 * whole blocks of the html page can appear and disappear when needed
 */
// there is no current section selected
var currentSection='';
sections = ["general","summary","templates","urls","email","uploads","helpers","interfaces","security","bayesian","resources","search"];

function _toggle( sectionId )
{
 // get the dom object with such section
 element = document.getElementById( sectionId );
 
 currentStatus = element.style.display;
 window.alert('sectionId = '+sectionId+' - current status ='+currentStatus);
 
 // and toggle its visibility
 if( element.style.display == 'none' )
   element.style.display = 'block';
 else
   element.style.display = 'none';
  
 return true;
}

function toggleSection(sectionId)
{
 // if no section selected, do nothing
 if( sectionId == 'none' )
   return;

 toggleAll( false );
 
 // and toggle the new one
 _toggle(sectionId);

 // now we have a new current section
 currentSection = sectionId;
   
 return true;  
}

function toggleAll( enabled )
{
  if( enabled ) statusString = 'block';
  else statusString = 'none';
  
  for( i = 0; i < sections.length; i++ ) {
    element = document.getElementById( sections[i] );
    element.style.display = statusString;
  }
}

function getPostEditFormElements( formId )
{
	var formData = '';
	
	form = document.getElementById( formId );
	
	for(i = 0; i < form.elements.length; i++ ) {
		itemName = form.elements[i].name;
		itemValue = form.elements[i].value;
		
		if( itemName != "op" ) {
			// we don't want to send more than one "op" parameter... do we?
			if( itemName == "postCategories[]" ) {
				// we need to have a special case for this one because it's a list that
				// allows multiple selection... only using the "value" attribute will
				// return one of the items and we would like to have them all
				for (var j = 0; j < form.elements[i].options.length; j++) {
					if (form.elements[i].options[j].selected) 
						formData = formData + itemName + "=" + form.elements[i].options[j].value + "&";
				}
			}
			else if( itemName == "postText" && htmlAreaEnabled ) {
				formData = formData + itemName + "=" + encodeURIComponent(postTextEditor.getHTML()) + "&";
			}
			else if( itemName == "postExtendedText" && htmlAreaEnabled ) {
				formData = formData + itemName + "=" + encodeURIComponent(postExtendedTextEditor.getHTML()) + "&";
			}
			else {
				// for all other elements, normal handling
				formData = formData + itemName + "=" + encodeURIComponent(itemValue) + "&";		
			}
		}
    }	
    
    return formData;
}

/**
 * opens a new window where the post preview will be shown
 */
function previewNewPost()
{
	previewPost( "newPost" );
}

function previewUpdatedPost()
{
	previewPost( "editPost" );
}
	
function previewPost( formId )
{
	form = document.getElementById( formId );
	
	// we will only open this window if there is at least one category selected, otherwise it
	// will cause problems!
	if( submitNewPost( form )) {
		url = "?op=previewPost&" + getPostEditFormElements( formId );
		//window.alert(url);
		postPreview = window.open( url,'Preview','scrollbars=yes,resizable=yes,toolbar=no');
	}
	
	return true;
}

/*****
 *
 * functions for dealing with the "edit blog" screen
 *
 *****/

/**
 * generic function for moving elements from one list to another!
 */
function moveElement(srcList, dstList)
{
	
	// now find out which user we've selected from the first list
	indexId = srcList.selectedIndex;
	
	// if no element was selected, quit
	if( indexId == -1 )
		return false;
	
	optText = srcList.options[indexId].text;
	optId  = srcList.options[indexId].value;
	
	if( optId == -1 ) {
		// do nothing, this is our special marker!
		return;
	}
	
	// add the option to the opposite box
	newOpt = new Option( optText, optId );
	dstList.options[dstList.options.length] = newOpt;
	
	// and remove it from the current box
	srcList.options[indexId] = null;
	
	return true;
}

/**
 * moves one user from the list of avialable users to the list of users
 * that belong to this blog
 */
function removeUserFromBlog()
{
	// find the lists in the page
	siteUsersList = document.getElementById( "availableUsersList" );
	blogUsersList = document.getElementById( "blogUsersList" );
	
	moveElement( siteUsersList, blogUsersList );
}

/**
 * the same as above but the other way around...
 */
function addUserToBlog()
{
	// find the lists in the page
	siteUsersList = document.getElementById( "availableUsersList" );
	blogUsersList = document.getElementById( "blogUsersList" );
	
	moveElement( blogUsersList, siteUsersList );
}

/**
 * automatically selects all the elements of a list
 */
function listSelectAll(listId)
{
	list = document.getElementById( listId );
	for( i = 0; i < list.options.length; i++ ) {
		list.options[i].selected = true;
	}

	return true;
}

/**
 * then menu jump
 */
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//func.js

//功能：判断输入的参数串 str 是否为空
//返回值： 如果str是空字符则返回True ，否则返回False
function isEmpty(str) {
	blankStr =" ";  //包含英文空格和一个中文空格	
	var strLength = str.length;
	if(strLength==0) {  //str =="" （等于空字符串）		
		return true;
	}
	else {  //str 含有字符，还必须验证str是否全是空格字符
		var j=0;
		for (i=0;i<strLength;i++) {
			if(blankStr.indexOf(str.substring(i,i+1))>=0) {
				j++;
			}
		}
		if(j==strLength)  //输入了的字符全是空格
			return true;		
		else 
			return false;	
	}
}

//功能：判断输入的参数串 str 是否为整数
//返回值： 如果str是整数，则返回True ，否则返回 False
function isInt(str) {
	var theMask = "0123456789";
	var strLength=str.length;
	if (strLength==0)
		return false;
    for(var i=0;i<str.length;i++) {
    	if(theMask.indexOf(str.substring(i,i+1))==-1) { //发现str中含有非数字符号
		    return false;
	    }
    }
    return true;
}

//功能：判断输入的参数串 str 是否为实数 （检测不是很严格）
//返回值： 如果str是实数，则返回True ，否则返回 False
function isReal(str) {
	var theMask = "0123456789.";
	var strLength=str.length;
	if (strLength==0)
		return false;
    for(var i=0;i<str.length;i++) {
    	if(theMask.indexOf(str.substring(i,i+1))==-1) {
		    return false;
	    }
    }
    return true;
}

//功能： 判断参数 str 是否为合法的标识符。可用来判断是否含有中文字符，如果含有中问则返回值为 False
//返回值： 如果str是合法的英文标识符则返回True ，否则返回 False （例如含有中文字符时）
function isEnglishString(str) {
  var theMask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
    for(var i=0;i<str.length;i++) {
    	if(theMask.indexOf(str.substring(i,i+1))==-1) {
		    return false; //一旦发现非法的字符则返回False
		    break;
	    }
    }
    return true;
 }

//功能： 判断参数 str 是否为合法的日期格式（规定格式如: 2002-11-24）
//返回值： 如果日期 str 是合法则返回True ，否则返回 False 
function isDate(str)  {
  var the1st =str.indexOf('-');
  var the2st =str.lastIndexOf('-');
  if(the1st==the2st) {alert("日期格式不正确！应该为：年-月-日 \n  例如：2001-12-11");return false;}
  else {
     var y=str.substring(0,the1st);
     var m=str.substring(the1st+1,the2st);
     var d=str.substring(the2st+1,str.length);
     var maxdays=31;
     if((isInt(y)==false)||(isInt(m)==false)||(isInt(d)==false)) {alert("日期格式不正确！应该为：年-月-日 \n 例如：2001-11-24"); return false;}
     else if(y.length<4) {alert("年份不正确！\n\n日期格式为：年-月-日   \n 例如：2002-11-24");return false;}
     else if((m<0)||(m>12)) {alert("月份不正确！\n\n日期格式为：年-月-日 \n 例如：2002-12-11");return false;}
     else if(m==4||m==6||m==9||m==11)  maxdays=30;
          else if(m==2) {
              if(y%4>0) maxdays=28;
              else if(y%100==0&&y%400>0) maxdays=28;
              else maxdays=29;
              }
          else maxdays=31;
     if(d>maxdays) {alert("该月份天数不正确！\n\n日期格式为：年-月-日 \n 例如：2002-11-24");return false;}
     else {return true;}
  }
 }
//功能：在输入时候检测是否存在非法字符，如果存在则提醒用户，并删除最后输入字符
//用法：在input的onKeyup事件中调用inputMask(this,format)
//      其中format为'int','real','posInt','posReal'
//      如果为了严格检查，还可以在onChange事件中检查多一次
//Init:2002-08-08
//Modify:2002-08-10
function inputMask(obj,format) {
	var posRealMask =  "0123456789.";
	var posIntMask = "0123456789";
	var realMask =  "0123456789.-";
	var intMask = "0123456789-";

	var objLength = obj.value.length;
	if (objLength==0)
		return false;
	else if (format == "posInt" || format == "posint") {
		if (posIntMask.indexOf(obj.value.charAt(objLength-1))==-1) {
//			alert("该输入框只能输入正整数");
			obj.value=obj.value.substring(0,objLength-1);
			inputMask(obj,'posInt'); //递归查找是否存在非法字符
			return false;
		}
		return true;
	}//end if int
	else if (format == "posReal" || format == "posreal") {
		if (obj.value.charAt(objLength-1)==".") {  
		//如果出现小数点，则往前查询是否存在另外的小数点，确保不会有重复
			for(var i=0;i<objLength-1;i++) {
				if (obj.value.charAt(i)==".") {
//					alert("小数点不能出现两次");
					obj.value=obj.value.substring(0,objLength-1);
					return false;
				}
			}
		}
		if(posRealMask.indexOf(obj.value.charAt(objLength-1))==-1) {
//			alert("该输入框只能输入正实数");
			obj.value=obj.value.substring(0,objLength-1);
			inputMask(obj,'posReal'); //递归查找是否存在非法字符
			return false;
		}
		return true;
	}  //end if posReal
	else if (format == "int" || format == "Int") {
		if (obj.value.charAt(objLength-1)=="-" && objLength>1) {
		//确保负号不在第一位后出现
//			alert("负号不能在此处出现");
			obj.value=obj.value.substring(0,objLength-1);
			inputMask(obj,'int'); //递归查找是否有重复的负号
			return false;
		}
		if(intMask.indexOf(obj.value.charAt(objLength-1))==-1) {
//			alert("该输入框只能输入正负整数");
			obj.value=obj.value.substring(0,objLength-1);
			inputMask(obj,'int'); //递归查找是否存在非法字符
			return false;
		}
		return true;
	}//end if int
	else if (format == "real" || format == "Real") {
		if (obj.value.charAt(objLength-1)==".") {  
		//如果出现小数点，则往前查询是否存在另外的小数点，确保不会有重复
			for(var i=0;i<objLength-1;i++) {
				if (obj.value.charAt(i)==".") {
//					alert("小数点不能出现两次");
					obj.value=obj.value.substring(0,objLength-1);
					return false;
				}
			}
		}
		if (obj.value.charAt(objLength-1)=="-" && objLength>1) {
		//确保负号不在第一位后出现
//			alert("负号不能在此处出现");
			obj.value=obj.value.substring(0,objLength-1);
			inputMask(obj,'real'); //递归查找是否有重复的负号
			return false;
		}
		if(realMask.indexOf(obj.value.charAt(objLength-1))==-1) {
//			alert("该输入框只能输入正负实数");
			obj.value=obj.value.substring(0,objLength-1);
			inputMask(obj,'real'); //递归查找是否存在非法字符
			return false;
		}
		return true;
	}  //end if real
}//end Function inputMast(obj,format)

//功能检查输入的EMAIL是否正确
function isemail (s)
{
        // Writen by david, we can delete the before code
        if (s.length > 100)
        {
                window.alert("email地址长度不能超过100位!");
                return false;
        }

//         var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"
         var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"
		 var re = new RegExp(regu);
         if (s.search(re) != -1) {
               return true;
         } else {
               window.alert ("请输入有效合法的E-mail地址 ！")
               return false;
         }

}

//-----------------
function cancelaction(b,tmsg){
   if(b){
       event.returnValue=false;
       alert(tmsg);
   }
}

function checkedCheckbox(form_name,box_name)
{
	var j=0;
	for(i=0;i<form_name.elements .length;i++){
			var e=form_name.elements[i];
			if((e.name==box_name)&&(e.checked==true)) {
					j++;                        
			}
	}
	if (j==0){
		return false;
	}
	return true;
}

function ResizeImage(obj, MaxW, MaxH)
{
	//check it;
	if(typeof(obj)!="object" || isNaN(MaxW) || isNaN(MaxH))
		return null;
	//run;
	var intWidth=obj.width;
	var intHeight=obj.height;
	//alert(intWidth);
	//get cal;
	if(intWidth>MaxW || intHeight>MaxH)
	{
		var a=MaxW/intWidth;
		var b=MaxH/intHeight;
		if(b<a)
			a=b;
		intWidth*=a;
		intHeight*=a;
		obj.width=intWidth;
		obj.height=intHeight;
	}
	else if(intWidth==0 && intHeight==0)
	{
		obj.width=MaxW;
	}
	obj=null;
	intWidth=null;
	intHeight=null;
	return null;	
}

function isWhiteWpace (s)
{
  var whitespace = " \t\n\r";
  var i;
  for (i = 0; i < s.length; i++){   
     var c = s.charAt(i);
     if (whitespace.indexOf(c) >= 0) {
		  return true;
	  }
   }
   return false;
}

//=============处理图象==================
function checkimages(imgsize){
	if(imgsize==undefined){
		imgsize=550;
	}
	var i;
	var topic=document.getElementById("viewtopic")
	//alert(topic);
	if (topic){
		var topicimages=topic.getElementsByTagName("img");
			if(topicimages){
				var iarray=topicimages;
				for(i in iarray){
					//alert(iarray[i].width);
					if(iarray[i].width>imgsize){
						
						var intwidth=iarray[i].width;
						var a=imgsize/intwidth;
						var intheight=iarray[i].height;
						intheight*=a;
						iarray[i].width=imgsize;
						iarray[i].height=intheight;
						
					}
					if(iarray[i].style!=null){
						if(iarray[i].style.width!=null || iarray[i].style.height!=null){
							
							if(parseInt(iarray[i].style.width)>imgsize){
							var intwidth=iarray[i].style.width;
							var a=imgsize/intwidth;
							var intheight=iarray[i].style.height;
							intheight*=a;
							iarray[i].style.width=imgsize+"px";
							iarray[i].style.height=intheight+"px";
							}
						}
					}
				}
			}
		
	}
}

//imgad.js

<!--

var iWritedCount= 0;
var aDoc,i
try 
{
	if(strLineData.length==0){
		strLineData="";
	}	
}
catch(e)
{
	var strLineData="";
}
aDoc = strLineData.split("|*|");//数据分隔符

aWritedImg = new Array(aDoc.length);
for(i=0; i<aWritedImg.length; i++ ){
	
	aWritedImg[i]=0;
}
function WriteImg()
{
	
	var i,z;
	do{
		i = parseInt( Math.random( )*(aDoc.length-1) );
	}while( aWritedImg[ i ] > 0 && iWritedCount<aDoc.length-1);
	
	if( iWritedCount >= aDoc.length-1 )
	{
		return;
	}
	aWritedImg[ i ] ++;
	iWritedCount ++;
	switch( GetFileExt( aDoc[i] ) )
	{
		
		case ".swf":
			
			document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width=778 height=90>' + 
 							'<PARAM NAME=movie VALUE="' + path + GetFileSrc(aDoc[i]) + '"> <PARAM NAME=quality VALUE=high><param name=wmode value=opaque>' + 
 							'<EMBED src="' + path + GetFileSrc(aDoc[i]) + '" quality=high TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width=778 height=90></EMBED></OBJECT>');
			break;
			
		case ".gif":
		case ".jpg":
			document.write('<a href="'+GetFileUrl(aDoc[i])+'" target="_blank"><img src="' + path + GetFileSrc(aDoc[i]) + '" border=0></a>');

			break;
			
		default:
			break;
	}
	
}
function GetFileExt( str )
{
	var i = str.lastIndexOf(".");
	if( i != -1 )
		return str.substr(i).toLowerCase( );
	else
		return "";
}
function GetFileUrl( str )
{
	var s = str.indexOf("|@|");
	if( s != -1 )
		return str.substr(0,s);
	else
		return "";
}
function GetFileSrc( str )
{
	var g = str.lastIndexOf("|@|");
	if( g != -1 )
		return str.substr(g+3);
	else
		return "";
}
function showTags(objC)
{
	var objField=document.getElementById("tagfield");
	var colField=objField.getElementsByTagName("TR");
	for(i=0;i<colField.length;i++)
	{
		if(colField[i].style.display=="none")
			colField[i].style.display="";
	}
	objC.innerHTML="";
	return false;
}

function ShowMPImages(ImgArr,subsname,mode,value,baseurl)
{
	var alttext;
	var result="";
	var baseurl=baseurl;
	var i=0;
	var space=0;
	var z=10;
	var imgPath=new Array("1.gif","2.gif","3.gif","4.gif");
	
	//
	if (mode=='M')	{	var Path_img=baseurl+'imgs/money';var alttext=subsname+'的积分为：'+value;}
	if(mode=='P')	{  var Path_img=baseurl+'imgs/popular';var alttext=subsname+'的受欢迎程度为：'+value;}
	result='<a title="'+alttext+'"><div style="position:absolute; width:100px; height:20px; z-index:1; ">';
	
	for(i=4;i>0;i--)
	{
		for(var j=0;j<ImgArr[i];j++)
		{
			space+=6;
			var a=i-1;
			result+='<div style="position:absolute; width:20px; height:20px; z-index:'+z+
					'; left:'+space+'px; "><img src='+Path_img+imgPath[a]+' alt="'+alttext+'" border=0></div></a>';
			z--;
		}
	}
	result+='</div>';
	document.write(result);	
}	
//我的门户菜单

	var curMenu=null;
	var curMenuItem=null;
	var lastMenu=null;
	var menupair=new Object();
	var remenupair=new Object();
	var menuon=false;
	
	//config options;
	
	var curMenuStyle="memucur";
	var curMenuItemStyle="highlight";
	var menuHighLightStyle="highlight";
	var menuDefaultStyle="";
	var menuItemsActiveStyle="active";
	
	menupair["link"]="linkMenu";
	menupair["express"]="expressMenu";
	menupair["myphoto"]="myphotoMenu";
	menupair["myblog"]="myblogMenu";
	menupair["mycontact"]="mycontactMenu";
	menupair["profile"]="profileMenu";
	menupair["mymailbox"]="mymailboxMenu";
	menupair["myrss"]="myrssMenu";
	
	//end config
	
	for(var i in menupair)
	{
		remenupair[menupair[i]]=i;
	}
	
	function setCurMenu()
	{
		if(!menuon && lastMenu!=null && lastMenu!=curMenu)
		{
			document.getElementById(lastMenu).className="";
			showMenu(curMenu);
		}
	}
	
	function setMenuInit(aId,aItemId)
	{
		if(typeof(aId)!="string" || typeof(aItemId)!="string")
			return;
		//init global;
		var oMenuBar=document.getElementById("menubar");
		var oMenuItems=document.getElementById("menuitems");
		oMenuBar.onmouseover=function()
		{
			menuon=true;
		}
		oMenuBar.onmouseout=function()
		{
			menuon=false;
			setTimeout("setCurMenu()",500);
		}
		oMenuItems.onmouseover=function()
		{
			menuon=true;
			if(lastMenu!=curMenu)
				document.getElementById(lastMenu).className=menuHighLightStyle;
		}
		oMenuItems.onmouseout=function()
		{
			menuon=false;
			setTimeout("setCurMenu()",500);
		}
		curMenu=aId;
		lastMenu=aId;
		curMenuItem=aItemId;
		var oMenu=document.getElementById(curMenu);
		var oMenuItem=document.getElementById(aItemId);
		oMenu.className=curMenuStyle;
		oMenuItem.className=curMenuItemStyle;
		showMenu(curMenu);
		for(var i in menupair)
		{
			var oT=document.getElementById(i);
			var oTm=document.getElementById(menupair[i]);
			oT.onmouseover=function()
			{
				showMenu(this.id);
			}
			oTm.onmouseover=function()
			{
				if(remenupair[this.id]!=curMenu)
					document.getElementById(remenupair[this.id]).className=menuHighLightStyle;
				menuon=true;
			}
			oTm.onmouseout=function()
			{
				if(remenupair[this.id]!=curMenu)
					document.getElementById(remenupair[this.id]).className=menuDefaultStyle;
			}
		}
	}
	
	//show a items;
	
	function showMenu(aId)
	{
		if(typeof(aId)!="string")
			return;
		if(lastMenu!=null)
		{
			oMenu=document.getElementById(menupair[lastMenu]);
			oMenu.className=menuDefaultStyle;
		}
		lastMenu=aId;
		targetMenu=document.getElementById(menupair[aId]);
		targetMenu.className=menuItemsActiveStyle;
	}
//我的门户菜单

//评分下拉框
function ShowHPSelect(usepopular,startpopular,increase)
{
	var b;
	var selecthtml="";
	
	if (usepopular>=startpopular){
		var c=usepopular-startpopular;
		b=Math.floor(c/increase)+1;
		selecthtml+='<SELECT name=hit_point>';
		for(i=b;i>=-b;i--) {
			selecthtml+='<option value='+i;
			if (0==i) selecthtml+=' selected';
			if (i<0) selecthtml+='>'+Math.abs(i)+'个鸡蛋</option>';
			if (i==0) selecthtml+='>不评分</option>';
			if (i>0) selecthtml+='>'+i+'朵鲜花</option>';
		}
		selecthtml+=' </SELECT>';
	}
	document.write(selecthtml);
}	
	

//功能检查输入的是否链接地址正确
function isUrl (strurl)
{
        // Writen by david, we can delete the before code
        if (strurl.length > 200)
        {
                window.alert("地址长度不能超过200位!");
                return false;
        }
//         var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"
       //  var regu = "((http)://)?(((([d]+.)+){3}[d]+(/[w./]+)?)|([a-z]w*((.w+)+){2,})([/][w.~]*)*)";
		 var regu = /^http:\/\/[\w\-]+\.[\w\-]+\.\S+\.htm$/ig;
         if (regu.test(strurl)) {
               return true;
         } else {
               window.alert ("请输入有效合法的链接地址 ！")
               return false;
         }

}
function playmusic()
{
	//alert("dddddddddddd");autostart="true"
	if (navigator.userAgent.indexOf("MSIE") != -1){
		thissound=document.getElementById("page_music");
		thissound.play();
	}		
}	

function stopmusic()
{
	if (navigator.userAgent.indexOf("MSIE") != -1){
		thissound=document.getElementById("page_music");
		thissound.stop();
	}
}
//找出控件地址
function getControlsTop(e){
	var t=e.offsetTop;
	while(e=e.offsetParent){
		t+=e.offsetTop;
	}
	return(t);
}
function getControlsLeft(e){
	var l=e.offsetLeft;
	while(e=e.offsetParent){
		l+=e.offsetLeft;
	}
	return(l);
}

function myAddBookmark(title,url)
{
    if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))//Gecko
    {
        window.sidebar.addPanel(title,url,"");
    }
    else//IE
    {
        window.external.AddFavorite(url,title);
    }
}
//-->

function selectAll()
{
    var arrElements = document.getElementsByTagName('input');
    for(var i = 0;i < arrElements.length;i++)
    {
        if(arrElements[i].type == 'checkbox' && arrElements[i].id.indexOf(arguments[0]) != -1)
        {
            arrElements[i].checked = true;
        }
    }
}

function cancleAll()
{
    var arrElements = document.getElementsByTagName('input');
    for(var i = 0;i < arrElements.length;i++)
    {
        if(arrElements[i].type == 'checkbox' && arrElements[i].id.indexOf(arguments[0]) != -1)
        {
            arrElements[i].checked = false;
        }
    }
}

function CheckDateTime(str)  
{   
    var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;   
    var r = str.match(reg);   
	//alert(r);
    if(r==null)return false;   
    r[2]=r[2]-1;   
    var d= new Date(r[1],r[2],r[3],r[4],r[5],r[6]);   
	//alert(d);
    if(d.getFullYear()!=r[1])return false;   
    if(d.getMonth()!=r[2])return false;   
    if(d.getDate()!=r[3])return false;   
    if(d.getHours()!=r[4])return false;   
    if(d.getMinutes()!=r[5])return false;   
    if(d.getSeconds()!=r[6])return false;   
    return true;   
}   
