﻿function ShowImage(tt,width,height,img)
{
    var element = GetM("imgDiv");
	element.style.display = 'block';
	element.style.top =getObjectTop(tt)+"px";
	element.style.left =(getObjectLeft(tt)+120)+"px";
	element.style.width=width+"px";
	element.style.height=height+"px";
	//var imgurl=img.replace("\'","'");
	if(img.indexOf("<a")==0){
	    element.innerHTML="<IMG SRC=\""+img+"\" width=\""+width+"\" height=\""+height+"\"  border=\"0\">";
	    }else{
	    if(IsSwf(img)){
	    element.innerHTML="<div style=\"position:relative; left:0; top:0; z-index:1; width:"+width+"; height:"+height+"\"><EMBED wmode=\"transparent\"  WIDTH="+width+"   HEIGHT="+height+"   src="+img+"  TYPE=\"application/x-shockwave-flash\"  PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwavFlash\"> </EMBED></div>";
	    }else{
	    //element.style.backgroundImage="url("+img+")";
    element.innerHTML="<img src=\""+img+"\" width=\""+width+"\" height=\""+height+"\" />";
	    }
	}
    
}

function ShowImage1(tt,width,height,img)
{
    var element = GetM("imgDiv");
	element.style.display = 'block';
	element.style.top =getObjectTop(tt)+"px";
	element.style.left =(getObjectLeft(tt)+120)+"px";
	element.style.width=width+"px";
	element.style.height=height+"px";
	if(img.indexOf("<a")==0){	
	    element.innerHTML=img;
	    }else{
	    if(IsSwf(img)){
	    element.innerHTML="<div style=\"position:relative; left:0; top:0; z-index:1; width:"+width+"; height:"+height+"\"><EMBED wmode=\"transparent\"  WIDTH="+width+"   HEIGHT="+height+"   src="+img+"  TYPE=\"application/x-shockwave-flash\"  PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwavFlash\"> </EMBED></div>";
	    }else{
	    //element.style.backgroundImage="url("+img+")";
    element.innerHTML=img;
	    }
	}
    
}

function GetM(id)
{
return document.getElementById(id);
}

function SetValidateCode()
{
    if(GetM("codeFrame")){
        GetM("codeFrame").innerHTML=" <iframe name=\"webCode\" src=\"MyWebCode.aspx\" frameborder=\"0\" width=\"78\" height=\"44\"                                    scrolling=\"no\"></iframe>                                <a href=\"MyWebCode.aspx\" target=\"webCode\" style=\"color:Red;\">看不清换一张</a><br />";
        }
}

function   getObjectLeft(el)  
  {  
      var   l=el.offsetLeft;  
      while(el=el.offsetParent)   l   +=   el.offsetLeft;  
      return   l;  
  }  
  function   getObjectTop(et)  
  {  
      var   t=et.offsetTop;  
      while(et=et.offsetParent)   t   +=   et.offsetTop;  
      return   t;  
  }   
  
 function YC()
 {
 GetM("imgDiv").style.display="none";
 }
function GetShowImage(imgUrl,textId)
{

var resultUrl="<script language=javascript src=\""+imgUrl+"&tag=_blank\"></script>";
//  var   xmlhttp=new   ActiveXObject("Msxml2.xmlhttp")  
//  xmlhttp.open("GET",imgUrl,false)  
//  xmlhttp.send()  
//  var   str   =   bytes2BSTR(xmlhttp.ResponseBody)  
//  alert(str)  
   //  alert(GetUrlCode(imgUrl));
//alert(GetUrlCode(imgUrl));

DianKe.YYmanage.GetCodeAjax(imgUrl.substring(imgUrl.lastIndexOf("id=")+3),"_blank","",function(result){
//GetM(textId).value=resultUrl+" 源码为:"+result.value; 
GetM(textId).value=result.value; 
});

//GetM(textId).value=resultUrl; 
}

function GetShowImage1(imgUrl,textId,id)
{

var resultUrl="<script language=javascript src=\""+imgUrl+"&tag=_blank\"></script>";
//  var   xmlhttp=new   ActiveXObject("Msxml2.xmlhttp")  
//  xmlhttp.open("GET",imgUrl,false)  
//  xmlhttp.send()  
//  var   str   =   bytes2BSTR(xmlhttp.ResponseBody)  
//  alert(str)  
   //  alert(GetUrlCode(imgUrl));
//alert(GetUrlCode(imgUrl));

DianKe.YYmanage.GetCodeAjax1(imgUrl,"_blank","",id,function(result){
//GetM(textId).value=resultUrl+" 源码为:"+result.value; 
GetM(textId).value=result.value; 
});

//GetM(textId).value=resultUrl; 
}







function createXmlHttpRequest() 
{ 
try {return new XMLHttpRequest();} 
catch(e) 
{
return new ActiveXObject("Microsoft.XMLHTTP");} 
} 

function GetUrlCode(url)
{
var xmlHttp = createXmlHttpRequest();
xmlHttp.open("get", url,true); 
xmlHttp.send(); 
if(xmlHttp.readyState == 4 && xmlHttp.status == 200) 
{ 
str = xmlHttp.responseText;//str即为返回的html内容
return str;
}else{
return "";
}
}


function SetUserState(divID1,divID2,spanId)
{
DianKe.YYmanage.GetUname(function(reault){
var uname=reault.value;
if(uname=="")
{GetM(divID1).style.display = 'block';
}else{GetM(divID2).style.display = 'block';
GetM(spanId).innerText=uname;
GetM(spanId).textContent=uname;

}
});
}

//登陆弹出对话框，并使背景元素不可用
var div_width = 500;
var div_height = 400;
function showWindow(address){
if(address=="web")
{
    DianKe.YYmanage.GetUid(function(reault){
var uid=reault.value;
if(uid==0)
{alert("请您先登陆");
}else{document.getElementById("ctl00_ContentPlaceHolder1_txtURLCode").value="http://www.diankee.com/"+address+""+uid+".aspx";
        document.getElementById("ctl00_ContentPlaceHolder1_txtIframeCode").value="<iframe frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" border=\"0\" id=\"diankeefrm\" name=\"diankeefrm\" scrolling=\"no\" height=\"2432px\" width=\"100%\" src=\http://www.diankee.com/"+address+""+uid+".aspx ></iframe>";
        location.href="#"; 
        //alert((document.getElementById("popLayer").getElementsByTagName("textarea"))[1].value);
        width = div_width;
        height = div_height;
        var windowstr= document.getElementById("popLayer").innerHTML;
        document.getElementById("infoDiv").innerHTML=windowstr; 
        (document.getElementById("infoDiv").getElementsByTagName("textarea"))[1].value="http://www.diankee.com/"+address+""+uid+".aspx";
        (document.getElementById("infoDiv").getElementsByTagName("textarea"))[0].value="<iframe frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" border=\"0\" id=\"diankeefrm\" name=\"diankeefrm\" scrolling=\"no\" height=\"2432px\" width=\"100%\" src=\http://www.diankee.com/"+address+""+uid+".aspx ></iframe>";
        document.getElementById("infoDiv").style.left=((document.body.clientWidth-width)>0?(document.body.clientWidth-width):0)/2+"px"; 
        document.getElementById("infoDiv").style.top=200+"px"; 
        //document.getElementById("infoDiv").style.zIndex=10001;
        document.getElementById("infoDiv").style.width=width; 
        document.getElementById("infoDiv").style.height=height; 
        document.getElementById("infoDiv").style.border="3px solid #0099ff";
        document.getElementById("tranDiv").style.height=document.body.clientHeight+ "px"; 
        document.getElementById("tranDiv").style.width=document.body.clientWidth+ "px"; 
        document.getElementById("tranDiv").style.display=""; 
        document.getElementById("tranDivBack").style.display=""; 
}
});
}
else
{
    DianKe.YYmanage.GetUid(function(reault){
var uid=reault.value;
if(uid==0)
{alert("请您先登陆");
}else{document.getElementById("ctl00_ContentPlaceHolder1_txtURLCode").value="http://www.diankee.com/"+address+""+uid+"_2.aspx";
        document.getElementById("ctl00_ContentPlaceHolder1_txtIframeCode").value="<iframe frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" border=\"0\" id=\"diankeefrm\" name=\"diankeefrm\" scrolling=\"no\" height=\"2432px\" width=\"100%\" src=\http://www.diankee.com/"+address+""+uid+"_2.aspx ></iframe>";
        location.href="#"; 
        //alert((document.getElementById("popLayer").getElementsByTagName("textarea"))[1].value);
        width = div_width;
        height = div_height;
        var windowstr= document.getElementById("popLayer").innerHTML;
        document.getElementById("infoDiv").innerHTML=windowstr; 
        (document.getElementById("infoDiv").getElementsByTagName("textarea"))[1].value="http://www.diankee.com/"+address+""+uid+"_2.aspx";
        (document.getElementById("infoDiv").getElementsByTagName("textarea"))[0].value="<iframe frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" border=\"0\" id=\"diankeefrm\" name=\"diankeefrm\" scrolling=\"no\" height=\"2432px\" width=\"100%\" src=\http://www.diankee.com/"+address+""+uid+"_2.aspx ></iframe>";
        document.getElementById("infoDiv").style.left=((document.body.clientWidth-width)>0?(document.body.clientWidth-width):0)/2+"px"; 
        document.getElementById("infoDiv").style.top=200+"px"; 
        //document.getElementById("infoDiv").style.zIndex=10001;
        document.getElementById("infoDiv").style.width=width; 
        document.getElementById("infoDiv").style.height=height; 
        document.getElementById("infoDiv").style.border="3px solid #0099ff";
        document.getElementById("tranDiv").style.height=document.body.clientHeight+ "px"; 
        document.getElementById("tranDiv").style.width=document.body.clientWidth+ "px"; 
        document.getElementById("tranDiv").style.display=""; 
        document.getElementById("tranDivBack").style.display=""; 
}
});
} 
} 
function closeWindow(){ 
document.getElementById("tranDiv").style.display="none"; 
} 

function uexit()
{
DianKe.YYmanage.Exit();
window.location.href='/index.html';
}

function closeWindow1(){ 
document.getElementById("tranDiv1").style.display="none"; 
} 

var div_width1 = 500;
var div_height1 = 200;
function showWindow1(address,zhi)
{
    DianKe.YYmanage.GetUid(function(reault)
    {
        var uid=reault.value;
        if(uid==0)
        {
            alert("请您先登陆");
        }
        else
        {
            //document.getElementById("ctl00_ContentPlaceHolder1_txtURLCode").value="http://www.diankee.com/"+address+""+uid+".aspx";
            document.getElementById("ctl00_ContentPlaceHolder1_txtIframeCode1").value="<iframe frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" border=\"0\" id=\"diankeefrm\" name=\"diankeefrm\" scrolling=\"no\" height=\"2432px\" width=\"100%\" src=\http://www.diankee.com/channel/"+address+"_"+uid+"_"+zhi+".aspx ></iframe>";
            location.href="#"; 
            //alert(document.getElementById("ctl00_ContentPlaceHolder1_txtIframeCode1").value);
            //return;
            //alert((document.getElementById("popLayer").getElementsByTagName("textarea"))[1].value);
            width = div_width1;
            height = div_height1;
            var windowstr= document.getElementById("popLayer1").innerHTML;
            document.getElementById("infoDiv1").innerHTML=windowstr; 
            //(document.getElementById("infoDiv1").getElementsByTagName("textarea"))[1].value="http://www.diankee.com/"+address+""+uid+".aspx";
            (document.getElementById("infoDiv1").getElementsByTagName("textarea"))[0].value="<iframe frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" border=\"0\" id=\"diankeefrm\" name=\"diankeefrm\" scrolling=\"no\" height=\"2432px\" width=\"100%\" src=\http://www.diankee.com/channel/"+address+"_"+uid+"_"+zhi+".aspx ></iframe>";
            document.getElementById("infoDiv1").style.left=((document.body.clientWidth-width)>0?(document.body.clientWidth-width):0)/2+"px"; 
            document.getElementById("infoDiv1").style.top=200+"px"; 
            //document.getElementById("infoDiv").style.zIndex=10001;
            document.getElementById("infoDiv1").style.width=width; 
            document.getElementById("infoDiv1").style.height=height; 
            document.getElementById("infoDiv1").style.border="3px solid #0099ff";
            document.getElementById("tranDiv1").style.height=document.body.clientHeight+ "px"; 
            document.getElementById("tranDiv1").style.width=document.body.clientWidth+ "px"; 
            document.getElementById("tranDiv1").style.display=""; 
            document.getElementById("tranDivBack1").style.display=""; 
        }
    });
}



////验证
//var spanShow = {};
//$(document).ready(function(){
//		spanShow.REMIND_MSG = {txtUserName:"字母开头，可以使用数字、字母及下划线",txtEmail:"输入正确邮箱，帮助找回密码",txtPwdFrst:"密码只能是6-20个字母、数字及下划线",txtPwdConfirm:"输入同样的密码",txtRealName:"真实姓名必须是汉字",txtUserQQ:"QQ［4-20］个数字",txtUserMSN:"MSN",txtUserTel:"电话",txtTitle:"发贴标题",dropTags:"选择分类",dropVillage:"具体位置",txtsignature:"个性签名应在20字符以内"};
//		spanShow.ERROR_MSG = {txtUserName:"有误!字母开头，可以使用数字、字母及下划线",txtEmail:"邮箱格式不正确，请仔细检查",txtPwdFrst:"密码只能是6-20个字母、数字及下划线",txtPwdConfirm:"两次输入密码不一致",txtRealName:"真实姓名输入有误",txtUserQQ:"QQ输入有误",txtUserMSN:"MSN输入有误",txtUserTel:"电话输入有误",txtTitle:"发贴标题不能为空！",dropTags:"选择分类",dropVillage:"请先选择村",txtsignature:"个性签名不得大于20个字符"};
//		spanShow.REG_MSG = {txtUserName:/^[a-zA-Z]{1}\w+$/,txtEmail:/^([a-zA-Z0-9_-]|[.])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/,txtPwdFrst:/\w{6,20}$/,txtPwdConfirm:/\w{6,20}$/,txtRealName:/[\u4E00-\u9FA5]{2,10}/,txtUserQQ:/^(\w){4,20}$/,txtUserMSN:/^([a-zA-Z0-9_-]|[.])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/,txtUserTel:/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/,txtTitle:/^.{1,}$/,dropTags:/^[1-9][0-9]*$/,dropVillage:/^[1-9][0-9]*$/,txtsignature:/^.{0,20}$/};
//		
//		spanShow.erroring = function(obj){		
//		$("#"+GetIdBySeviceId(obj)+0).css("display","block");
//		$("#"+GetIdBySeviceId(obj)+"1").removeClass("yy1").addClass("yy2");
//		$("#"+GetIdBySeviceId(obj)+"1_1").removeClass("yy1_1").addClass("yy2_2").html(spanShow.ERROR_MSG[GetIdBySeviceId(obj)]);
//		
//		};
//		spanShow.remaining = function(obj){
//		$("#"+GetIdBySeviceId(obj)+0).css("display","block");
//		$("#"+GetIdBySeviceId(obj)+"1").removeClass("yy2").addClass("yy1");
//		$("#"+GetIdBySeviceId(obj)+"1_1").removeClass("yy2_2").addClass("yy1_1").html(spanShow.REMIND_MSG[GetIdBySeviceId(obj)]);			
//		
//		};
//		spanShow.pass = function(obj){		
//		$("#"+GetIdBySeviceId(obj)+"1").removeClass("yy2").removeClass("yy1");
//		$("#"+GetIdBySeviceId(obj)+"1_1").removeClass("yy2_2").removeClass("yy1_1");
//		$("#"+GetIdBySeviceId(obj)+"1_1").html('<img src="Images/ok.bmp" class="img_align" />');		
//		};
//		spanShow.check = function(name,value){		    
//		    //标题不能为空的
//		    if(name=="ctl00$ContentPlaceHolder1$PostsAdd1$txtTitle" && value.replace(/(^\s*)|(\s*$)/g, "")=="")
//		    {
//		    	spanShow.erroring(name);
//		    }
//		    else if(value.replace(/(^\s*)|(\s*$)/g, "") == '') {
//		    //默认不提示。
//			$("#"+GetIdBySeviceId(name)+0).css("display","none");
//			}else{
//			
//			if(name =='ctl00$ContentPlaceHolder1$txtPwdConfirm'){
//			    //二遍密码
//				if($("#ctl00_ContentPlaceHolder1_txtPwdFrst").val()==value){
//					spanShow.pass(name);
//				}else{
//					spanShow.erroring(name);
//				}
//			}else{			    
//				if(spanShow.REG_MSG[GetIdBySeviceId(name)] != undefined){
//					if(spanShow.REG_MSG[GetIdBySeviceId(name)].test(value)){
//					//用户名是否存在
//					    if(name=='ctl00$ContentPlaceHolder1$txtUserName'){
//					   userExists(name,value);	        
//					    }else{					    
//					    spanShow.pass(name);
//					    }
//					}else{
//						spanShow.erroring(name);
//					}
//				}
//			}
//		  }			
//		};
//		
//	
//		//次要注册
//		spanShow.register1=function(){		
//			var spanId = ["ctl00$ContentPlaceHolder1$txtEmail","ctl00$ContentPlaceHolder1$txtRealName","ctl00$ContentPlaceHolder1$txtUserQQ","ctl00$ContentPlaceHolder1$txtUserMSN","ctl00$ContentPlaceHolder1$txtUserTel"];//,"ctl00$ContentPlaceHolder1$txtEmail"
//			var inputId = ["ctl00_ContentPlaceHolder1_txtEmail","ctl00_ContentPlaceHolder1_txtRealName","ctl00_ContentPlaceHolder1_txtUserQQ","ctl00_ContentPlaceHolder1_txtUserMSN","ctl00_ContentPlaceHolder1_txtUserTel"];//,"ctl00_ContentPlaceHolder1_txtEmail"
//			for(var i=0; i<spanId.length; i++){
//			if($("#"+inputId[i]).val()!=""){
//				    if(!spanShow.REG_MSG[GetIdBySeviceId(spanId[i])].test($("#"+inputId[i]).val())){
//					    spanShow.erroring(spanId[i]);
//					    $("#"+inputId[i]).focus();
//					    return false;
//				    }
//			   }	
//			}
//		};
//		//主要注册
//		spanShow.register = function(){
//			var spanId = ["ctl00$ContentPlaceHolder1$txtUserName","ctl00$ContentPlaceHolder1$txtPwdFrst","ctl00$ContentPlaceHolder1$txtPwdConfirm"];//,"ctl00$ContentPlaceHolder1$txtEmail"
//			var inputId = ["ctl00_ContentPlaceHolder1_txtUserName","ctl00_ContentPlaceHolder1_txtPwdFrst","ctl00_ContentPlaceHolder1_txtPwdConfirm"];//,"ctl00_ContentPlaceHolder1_txtEmail"
//			for(var i=0; i<spanId.length; i++){
//				if(!spanShow.REG_MSG[GetIdBySeviceId(spanId[i])].test($("#"+inputId[i]).val())){
//					spanShow.erroring(spanId[i]);
//					$("#"+inputId[i]).focus();
//					return false;
//				}
//				 userExists(spanId[0],$("#"+inputId[0]).val());
//				if(spanShow.erroryy==1){return false;}
//			}
//			if($("#ctl00$ContentPlaceHolder1$txtPwdFrst").val() != $("#ctl00$ContentPlaceHolder1$txtPwdConfirm").val()){
//				spanShow.erroring("ctl00$ContentPlaceHolder1$txtPwdConfirm");
//				$("#ctl00$ContentPlaceHolder1$txtPwdConfirm").focus();
//				return false;
//			}
//			return true;
//		};
//	
//		
//		$(".yy").focus(function(){
//			 $(this).removeClass("yyf").addClass("yyf");
//			spanShow.remaining($(this).attr("name"));
//		});
//		$(".yy").blur(function(){
//		 	$(this).toggleClass("yyf");
//			spanShow.check($(this).attr("name"),$(this).val());
//		});	
//		$(".yy_userInfo").click(function(){
//		  $("#up"+$(this).attr("name")).css("display","block");
//		});	
//		
//  });




/* 
操作cookie
*/


function copy(text)
{
    var browserName=navigator.userAgent.toLowerCase();
    if(/msie/i.test(browserName) && !/opera/.test(browserName))
    {
        window.clipboardData.setData("Text",GetM(text).value);
        alert("复制成功，请粘贴到你的QQ/MSN上推荐给你的好友");
    }
    else
    {
        alert("您的浏览器不支持复制功能，请手动复制！");
    }
}

function copy1(text)
{
    if(window.clipboardDate)
    {
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", GetM(text).value);
    }
    else if(navigator.userAgent.indexOf("Opera") != -1)
    {
        window.location=GetM(text).value;
    }
    else if(window.netscape)
    {
        try
        {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        }
        catch(e)
        {
            alert("被浏览器拒绝！\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 = GetM(text).value;
        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 IsSwf(imgUrl)
{
var postfix = imgUrl.substring(imgUrl.lastIndexOf(".")+1,imgUrl.length).toLowerCase();
if(postfix=="swf"){return true;}else{return false;}
}

function toLogin()
{
alert("请先注册或登录!");
window.location.href="/login/userlogin.aspx";
}



function GetCookieVal(offset)
//获得Cookie解码后的值
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function SetCookie(name, value)
//设定Cookie值
{
var expdate = new Date();
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
+((secure == true) ? "; secure" : "");
}
function DelCookie(name)
//删除Cookie
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}
function GetCookie(name)
//获得Cookie的原始值
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return GetCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}

