function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function showadv(){
if (document.aspnetForm.advshow.checked == true) {
	document.getElementById("adv").style.display = "block";
	//document.getElementById("advance").innerHTML="关闭高级用户设置选项";
}else{
	document.getElementById("adv").style.display = "none";
	//document.getElementById("advance").innerHTML="显示高级用户设置选项";
}
}

//

function DrawImage(ImgD){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
	//imgwidth=image.width;
	//imgheight=image.height;
	//ImgD.height=image.height; 
	//ImgD.width=image.width; 
	flag=true; 
	if(image.width>=90 && image.height<=90){ 
		ImgD.width=90; 
		ImgD.height=(image.height*150)/image.width; 
	}  
	if(image.width<=90 && image.height>=90){ 
		ImgD.height=90; 
		ImgD.width=(image.width*150)/image.height; 
	}  
	if(image.width>=90 && image.height>=90){ 
		if(image.width>=image.height){
			ImgD.width=90; 
			ImgD.height=(image.height*90)/image.width; 
			}
		else{
			ImgD.height=90; 
			ImgD.width=(image.width*90)/image.height; 
		}
	}
} 
} 

function DrawImage2(ImgD){ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
	//imgwidth=image.width;
	//imgheight=image.height;
	//ImgD.height=image.height; 
	//ImgD.width=image.width; 
	flag=true; 
	if(image.width>=45 && image.height<=45){ 
		ImgD.width=45; 
		ImgD.height=(image.height*45)/image.width; 
	}  
	if(image.width<=45 && image.height>=45){ 
		ImgD.height=45; 
		ImgD.width=(image.width*45)/image.height; 
	}  
	if(image.width>=45 && image.height>=45){ 
		if(image.width>=image.height){
			ImgD.width=45; 
			ImgD.height=(image.height*45)/image.width; 
			}
		else{
			ImgD.height=45; 
			ImgD.width=(image.width*45)/image.height; 
		}
	}
} 
} 


function ShowUserDetails(i){

    if (i == "1") {
            trDetails.style.visibility = "visible";
            trDetails.style.display = 'block';
        }
        else
        {
            trDetails.style.visibility = "hidden";
            trDetails.style.display = 'none';
        }
}

function doQuestion(question){
    myQuestion = document.getElementById('myQue');

    if (question == "MY85_Q_9999") {
            myQuestion.style.visibility = "visible";
            myQuestion.style.display = 'block';
        }
        else
        {
            myQuestion.style.visibility = "hidden";
            myQuestion.style.display = 'none';
        }
}

function showsubmenu(sid)
{
whichEl = eval("submenu" + sid);
subimg = document.getElementById("subimg" + sid);
//simg = eval("subimg" + sid);
if (whichEl.style.display == "none")
{
eval("submenu" + sid + ".style.display=\"\";");
eval("subimg.src=\"../images/minus.gif\";");
}
else
{
eval("submenu" + sid + ".style.display=\"none\";");
eval("subimg.src=\"../images/plus.gif\";");
}
}

/***Index.aspx****/

var tbCommend = "";
function showcommend(tabid)
{
	if(tabid=="1")
	{
		tbCommend = "1";
		tab1.className = "styletab1";
		tab2.className = "styletab2";
		subtab1.className = "divshow";
		subtab2.className = "divhidden";
	}
	else
	{
		tbCommend = "2";
		tab1.className = "styletab2";
		tab2.className = "styletab1";
		subtab1.className = "divhidden";
		subtab2.className = "divshow";
	}
	//doBizCategory();
}

function refreshVcode()
{
    var rid=Math.round(Math.random()*1000000);
    var url = "/home/CheckCode.aspx?code="+rid;
    $("vcodeImg").src = url;
}

//切换图片
function switchImage(imgName, imgSrc) 

{

  if (document.images)

  {

    if (imgSrc != "none")

    {

      document.images[imgName].src = imgSrc;

    }

  }

}

function reloadCodePic(objectid)
{
    var ip = "<%= strIP %>";
    var obj = document.getElementById(objectid);
    obj.src = "../Home/CheckCode.aspx?IP="+ ip +"&DateTime="+generateMixed(3);
}

var chars = ['0','1','2','3','4','5','6','7','8','9'];

function generateMixed(n) {
    var res = "";
    for(var i = 0; i < n ; i ++) {
        var id = Math.ceil(Math.random()*10);
        res += chars[id];
    }
    return res;
} 


function CheckSpace(CheckValue)
{
	var ValueLength = CheckValue.length;
	var TempValue = "";
	
	for(var i = 0; i < ValueLength; i++)
	{
	    TempValue = TempValue + " ";
	}
	
	if(TempValue == CheckValue)
	{
	    return false;
	}
	else
	{
	    return true;
	}
}

function JSTrim(strValue)
{
    if(strValue == "" || CheckSpace(strValue) == false)
    {
        strValue = "";
        return strValue;
    }
    
    while(strValue.charAt(0) == " ")
    {   
        strValue=strValue.substring(1,strValue.length)
    }
    while(strValue.charAt(strValue.length-1) == " ")   
    {   
        strValue=strValue.substring(0,strValue.length-1)
    } 
        
    return strValue;
}

String.prototype.Trim = function() 
{ 
    return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.LTrim = function() 
{ 
    return this.replace(/(^\s*)/g, ""); 
} 

String.prototype.RTrim = function() 
{ 
    return this.replace(/(\s*$)/g, ""); 
} 

String.prototype.AllTrim = function() 
{ 
    return this.replace(/\s/g, ""); 
}

var tempMD = false;
var tempOX,tempOY;
var MoveObj = null;

document.onmousedown = function(ev)
{
    var ev = ev || window.event;
    var objId = ev.srcElement.id;
    if (objId == "floattitle")
    {
        tempMD = true;
        MoveObj = document.getElementById("floatparent");
        tempOX = MoveObj.offsetLeft - ev.clientX;
        tempOY = MoveObj.offsetTop - ev.clientY;
    }
}

document.onmouseup= function()
{
	tempMD=false;
}

document.onmousemove= function(ev)
{
	var ev = ev || window.event;
 	if(tempMD)
 	{
 	    if (MoveObj != null)
 	    {
     	    MoveObj.style.left= (ev.clientX + tempOX)+"px";
     	    MoveObj.style.top= (ev.clientY + tempOY)+"px";
     	}
 	}
}

var FloatParentObj;
var AlphaNum = 0;
var FloatDivTimeout;
var FloatParentIsOpen = false;

function CloseFloatDiv()
{
    if (FloatParentObj == null)
    {
        FloatParentObj = document.getElementById("floatparent");
        if (FloatParentObj == null)
            return;
    }
    AlphaNum = 100;
    FloatParentIsOpen = false;
    FloatDivEffect();
}

function ShowFloatDiv()
{
    if (FloatParentObj == null)
    {
        FloatParentObj = document.getElementById("floatparent");
        if (FloatParentObj == null)
            return false;
    }
    FloatParentObj.style.display = "block";
    AlphaNum = 0;
    FloatParentIsOpen = true;
    FloatDivEffect();
}

function FloatDivEffect()
{
    if (!FloatParentIsOpen)
    {
        AlphaNum -= 20;
        if (AlphaNum < 0)
        {
            clearTimeout(FloatDivTimeout);
            FloatParentObj.style.display = "none";
            AlphaNum = 0;
            return;
        }
        FloatParentObj.style.filter = "Alpha(Opacity=" + AlphaNum + ")";//for ie
        FloatParentObj.style.opacity = AlphaNum/100;//for FF
    }
    else
    {
        AlphaNum += 20;
        if (AlphaNum > 100)
        {
            clearTimeout(FloatDivTimeout);
            AlphaNum = 100;
            return;
        }
        FloatParentObj.style.filter = "Alpha(Opacity=" + AlphaNum + ")";//for ie
        FloatParentObj.style.opacity = AlphaNum/100;//for FF
    }
    
    FloatDivTimeout = setTimeout(FloatDivEffect,50);
}



function CheckDelete(objAll,ConfirmInfo,AlertInfo)
{
	var inputs = document.getElementsByTagName("input");
	var IsChecked = false;
	for(var i = 0; i < inputs.length; i++)
	{
		if(inputs[i].type == "checkbox")
		{
			if(inputs[i].checked && inputs[i].id != objAll)
			{
				IsChecked = true;
				break;
			}
		}
	}
	if(IsChecked)
	{
		return true;
	}
	else
	{
		alert(AlertInfo);
		return false;
	}
}