function getCookie(name){
                var strCookie=document.cookie;
                var arrCookie=strCookie.split("; ");
                for(var i=0;i<arrCookie.length;i++){
                    var arr=arrCookie[i].split("=");
                    if(arr[0]==name)return arr[1];
                }
                return null;
            }


function showTextLayer(oResponse,width,height,left,top)
{
   
   
    var newDiv = document.createElement("div");
    newDiv.id = "newDiv";
    newDiv.style.position = "absolute";
    newDiv.style.zIndex = "99998";
    newDiv.style.width = width+"px";
    newDiv.style.height = height+"px";
   
   
     newDiv.style.top = (document.body.scrollTop + document.documentElement.scrollTop+(window.screen.availHeight-height)/2)+"px";
    //newDiv.style.top = ((window.screen.availHeight-height)/2)+"px";
    newDiv.style.left = (document.body.scrollLeft+(window.screen.availWidth-width)/2)+"px";//middle
   // newDiv.style.left = ((window.screen.availWidth-width)/2)+"px";//middle
   
    newDiv.style.background = "#ffffff";
    newDiv.style.border = "8px solid #D9F2FF";
    newDiv.style.padding = "0px";
    //newDiv.innerHTML=oResponse.responseText;
    document.body.appendChild(newDiv);
    var ifr = document.createElement("iframe");
    ifr.id="ifr";
    ifr.style.zIndex="10";
    ifr.style.width = width+"px";
    ifr.style.height = height+"px";
    ifr.style.top=newDiv.style.top;
    ifr.style.left=newDiv.style.left;
    ifr.style.position = "absolute";
    
    document.body.appendChild(ifr);
    
    
    
    
    
    // mask layer
    var newMask = document.createElement("maskdiv");
    newMask.id ="maskDiv";
    newMask.style.position = "absolute";
    newMask.style.zIndex = "99997";
    
    newMask.style.width = document.body.scrollWidth + "px";
    newMask.style.height = document.body.scrollHeight + "px";
 
    newMask.style.top = "0px";
    newMask.style.left = "0px";
    newMask.style.background = "#000";
    newMask.style.filter = "alpha(opacity=40)";
    newMask.style.opacity = "0.40";

    document.body.appendChild(newMask);	
   
    var contentDiv=document.createElement("div");
    contentDiv.align="center";
    contentDiv.id="fltContentDiv";
    //contentDiv.style.border="1px solid red";
    contentDiv.innerHTML=oResponse;
    newDiv.appendChild(contentDiv);
}


function showTextLayer2(oResponse,width,height,left,top)
{
   
   
    var newDiv = document.createElement("div");
    newDiv.id = "newDiv";
    newDiv.style.position = "absolute";
    newDiv.style.zIndex = "99998";
    newDiv.style.width = width+"px";
    newDiv.style.height = height+"px";
   
   
     //newDiv.style.top = (document.body.scrollTop + document.documentElement.scrollTop+(window.screen.availHeight-height)/2)+"px";
    newDiv.style.top = ((window.screen.availHeight-height)/2)+"px";
    //newDiv.style.left = (document.body.scrollLeft+(window.screen.availWidth-width)/2)+"px";//middle
    
    
    
     if(getCookie("cocode") != null&&getCookie("cocode")=="tencent"&&getCookie("tencent_iframe") != null&&getCookie("tencent_iframe")=="tencent")
       newDiv.style.left ="100px";//middle
      else
      newDiv.style.left = ((window.screen.availWidth-width)/2)+"px";//middle
   
    newDiv.style.background = "#ffffff";
    newDiv.style.border = "8px solid #D9F2FF";
    newDiv.style.padding = "0px";
    //newDiv.innerHTML=oResponse.responseText;
    document.body.appendChild(newDiv);
    var ifr = document.createElement("iframe");
    ifr.id="ifr";
    ifr.style.zIndex="10";
    ifr.style.width = width+"px";
    ifr.style.height = height+"px";
    ifr.style.top=newDiv.style.top;
    ifr.style.left=newDiv.style.left;
    ifr.style.position = "absolute";
    
    document.body.appendChild(ifr);
    
    
    
    
    
    // mask layer
    var newMask = document.createElement("maskdiv");
    newMask.id ="maskDiv";
    newMask.style.position = "absolute";
    newMask.style.zIndex = "99997";
    
    newMask.style.width = document.body.scrollWidth + "px";
    newMask.style.height = document.body.scrollHeight + "px";
 
    newMask.style.top = "0px";
    newMask.style.left = "0px";
    newMask.style.background = "#000";
    newMask.style.filter = "alpha(opacity=40)";
    newMask.style.opacity = "0.40";

    document.body.appendChild(newMask);	
   
    var contentDiv=document.createElement("div");
    contentDiv.align="center";
    contentDiv.id="fltContentDiv";
    //contentDiv.style.border="1px solid red";
    contentDiv.innerHTML=oResponse;
    newDiv.appendChild(contentDiv);
}




 //图片等比例缩放
function DrawImage(ImgD,FitWidth,FitHeight)
{ 
 var image=new Image();  
    image.src=ImgD.src;
    if(image.width>0 && image.height>0)
    { 
            if(image.width/image.height>= FitWidth/FitHeight)
            {  
            if(image.width>FitWidth)
            { 
             ImgD.width=FitWidth;
             ImgD.height=(image.height*FitWidth)/image.width;}
             else
             {
             ImgD.width=image.width;
             ImgD.height=image.height;
             }
             }
            else{
            if(image.height>FitHeight)
            {
            ImgD.height=FitHeight;
            ImgD.width=(image.width*FitHeight)/image.height;
            }
            else
            {
            ImgD.width=image.width;
            ImgD.height=image.height;
            }
            }
      }


}


function closeFloatPage()
{
  
    if($('newDiv')!=null&&$('maskDiv')!=null&&$('ifr')!=null)
    {
    document.body.removeChild($('newDiv'));
    document.body.removeChild($('maskDiv'));
    document.body.removeChild($('ifr'));
    }
}

function addVote(activityUserId)
{
if(getCookie("ut")==null)
showLoginDiv();
else
{ 
   var url="/cms/addVote.do";
   var para="frontActivityUserId="+activityUserId;
   var myAjax = new Ajax.Request(url, {method:"post", parameters:para, onComplete:addVoteFinish});
} 
}
function addVoteFinish(response)
{
var requestMsg=response.responseXML;
var root=requestMsg.documentElement;
var message=root.getElementsByTagName("showmessage");
showTextLayer(message[0].childNodes[0].nodeValue,459,110,0,0);
if(root.getAttribute("resultCode")=="0")
  {
	  var aUserId=root.getAttribute("frontActivityUserId");
	  var activityId=root.getAttribute("activityId");
	  var obj=document.getElementById("addVoteTdId");
	  if(obj!=null)
	  {
	  obj.innerHTML="<a href='javascript:applyGift("+activityId+","+aUserId+")'><img src='../../images/pic/mm/mm_gengxin4.jpg' width='88' height='24' /></a>";
	  }
	  var   menus=document.getElementsByTagName('span');  
	  if(menus!=null)
	    {   
	      for(var   i=0;i<menus.length;i++){
	          if(menus[i].id==aUserId+"_vote_numbers")
	          {
	         menus[i].innerHTML=root.getAttribute("currentVoteNumber");
	          }   
	      }   
	    }
    }
//document.getElementById(aUserId+"_vote_numbers").innerHTML=root.getAttribute("currentVoteNumber");
}


function applyGift(faid,fauid)
{
var url="/cms/applyGift.do";
var para="fauid="+fauid+"&faid="+faid;
var myAjax = new Ajax.Request(url, {method:"post", parameters:para, onComplete:applyGiftFinish});
}





function applyGiftFinish(response)
{

showTextLayer(response.responseText,460,200,0,0);
}

function giftDivClose()
{
 window.location=window.location
}

function queryTextFocus(obj)
{
if(obj.value=="请输入公司名称或昵称")
obj.value="";
}


function copyLink(txt) {
     if(window.clipboardData) {
             window.clipboardData.clearData();
             window.clipboardData.setData("Text", txt);
             alert("复制成功");
     } else if(navigator.userAgent.indexOf("Opera") != -1) {
          window.location = txt;
          alert("复制成功");
     } else if (window.netscape) {
          try {
               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
          } catch (e) {
               alert("你使用的Firefox浏览器,复制功能被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true',即可实现复制功能");
          }
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
          if (!clip)
               return;
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
          if (!trans)
               return;
          trans.addDataFlavor('text/unicode');
          var str = new Object();
          var len = new Object();
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
          var copytext = txt;
          str.data = copytext;
          trans.setTransferData("text/unicode",str,copytext.length*2);
          var clipid = Components.interfaces.nsIClipboard;
          if (!clip)
               return false;
          clip.setData(trans,null,clipid.kGlobalClipboard);
          alert("复制成功");
     }
}



function showCopyLink(url)
{
var outHtml='<table width="450" border="0" cellpadding="0" cellspacing="0" >';
 outHtml+='<tr>';
 outHtml+='<td width="32%" align="center" valign="top">';
 outHtml+='<table width="94%" border="0" cellspacing="0" cellpadding="0">';
 outHtml+='   <tr>';
 outHtml+='<td align="right" valign="top"><img src="/images/close.gif" alt="关闭" width="20px" height="20px"  onclick="closeFloatPage();" style="cursor:pointer;"/></td>';
 outHtml+='</tr>';
 outHtml+=' <tr>';
 outHtml+='       <td height="130" valign="middle">'
 outHtml+='           <table width="100%" border="0" cellspacing="0" cellpadding="0">'
 outHtml+='             <tr>'
 outHtml+='              <td  align="left">复制以下链接通过邮箱、MSN、QQ或论坛等方式发送给您的好友：'
 outHtml+='                </td>'
 outHtml+='    </tr>'
 outHtml+='             <tr>'
 outHtml+='              <td  align="left"><input type="text" name="myHomeLink" id="myHomeLink" readonly size="60" value="'+url+'"><input type="button" value="复制" style="cursor:pointer" onclick="javascipt:copyLink(document.getElementById(\'myHomeLink\').value);">'
 outHtml+='                </td>'
 outHtml+='    </tr>'
  outHtml+='             <tr>'
 outHtml+='              <td  align="center">如果点击复制没有用，请全选后"ctrl+c"复制此链接'
 outHtml+='                </td>'
 outHtml+='    </tr>'
 outHtml+=' </table>'
 outHtml+=' </td>'
 outHtml+='</tr>'
 outHtml+='    </table>'
 outHtml+=' </td>'
 outHtml+=' </tr>  '
 outHtml+='</table>'
 showTextLayer(outHtml,460,180,0,0);
}


var ScrollImageObj=new Function()
{
this.imageUrl;
this.nickName;
this.clickUrl;
this.company;
this.activityUserId;
this.activityId;
} 

function scrollImage()
{
if(currentIndex<=imageArray.length-1)
{
var obj=imageArray[currentIndex];
if(obj.nickName.length>7)
obj.nickName=obj.nickName.substring(0,7)+"...";
if(obj.company.length>7)
obj.company=obj.company.substring(0,4)+"...";
document.getElementById("scrollImageDiv1").innerHTML="昵称："+"<a href='"+obj.clickUrl+"'>"+obj.nickName+"</a><br>公司名称："+obj.company;
document.getElementById("scrollImageDiv2").innerHTML="<p><table width='300'><tr><td height='348' width='100%' align='center'><div align='center'><a href='"+obj.clickUrl+"'><img src='"+obj.imageUrl+"' onLoad='DrawImage(this,300,348)' align='center'></a></div></td></tr></table></p>";
curActivityId=obj.activityId;
curActivityUserId=obj.activityUserId;
currentIndex++;
}
else
currentIndex=0;

}

//进入主页
function joinDetail()
{
if(curActivityId!=null)
window.location="/cms/showActivityUserHome.do?faid="+curActivityId+"&fauid="+curActivityUserId;
}

function queryFormSubmit()
{

if(document.getElementById("searchValue").value=="请输入公司名称或昵称")
  document.getElementById("searchValue").value="";
document.getElementById('queryForm').submit();

}


 //发送验证EMAIL邮件
  function sendActivateEmail()
  {
	var url="/invite/sendActivateEmailAction.do";
	var para="";
	var myAjax = new Ajax.Request(url, {method:"post", parameters:para, onComplete:sendActivateEmailFinish});
  }
  
  function sendActivateEmailFinish(response)
  {
  if(response.responseText=="0")
  {
  alert("你的邮箱地址为空,请先完善你的用户信息!");
  }
  else
  alert("验证邮件已发送到您的注册邮箱 "+response.responseText+" 中,请查收!");
  }
  
  
  function showLoginDiv()
  {
  var outHtml='<table width="450" border="0" cellpadding="0" cellspacing="0" class="border_blue mt20">'
  outHtml+='<tr>'
  outHtml+='<td width="32%" align="center" valign="top">'
   outHtml+='<table width="94%" border="0" cellspacing="0" cellpadding="0">'
    outHtml+='<tr>'
    outHtml+='<td align="right"><img src="/images/close.gif" alt="关闭" width="20px" height="20px"  onclick="closeFloatPage();" style="cursor:pointer;"/></td>'
     outHtml+=' </tr>'
      outHtml+=' <tr>'
      outHtml+='<td class="list_25">'
 outHtml+='<table width="100%" border="0" cellspacing="0" cellpadding="0">'
 outHtml+='<tr>'
  outHtml+='<td  align="center"><div align="center" class="STYLE10" style="line-height:40px">很抱歉！您还没有登录/注册1号店！</div>'
  outHtml+='</td>'
  outHtml+='</tr>'
   outHtml+='<tr> '
   outHtml+='<td align="center">请先登入/注册1号店才能投票！</td>'  
  outHtml+='</tr>'
   outHtml+='<tr> '
   if(getCookie("cocode") != null&&getCookie("cocode")=="tencent"&&getCookie("tencent_iframe") != null&&getCookie("tencent_iframe")=="tencent")
   {
   outHtml+='<td align="center"><a target="_parent" href="/tencent/send.do?returnUrl=http%3A%2F%2Fwww.yihaodian.com%2Ftencent%2Fgateway.do%3FreturnUrl='+encodeURIComponent("http://021.qq.com/market_online.html")+'">马上去登陆/注册，GO!</a></td>';
   }
   else
   outHtml+='<td align="center"><a href="/passport/login_input.do?returnUrl='+encodeURIComponent(window.location)+'">马上去登陆/注册，GO!</a></td>';  
   outHtml+=' </tr>'
 outHtml+=' </table>'
  outHtml+='</td>'
  outHtml+='</tr>'
  outHtml+='</table>'
   outHtml+='   </td>'
  outHtml+='    </tr>'  
 outHtml+='</table>'
  showTextLayer(outHtml,460,180,0,0);
  }


