var nid=0;

$(document).ready(function() {
            setIframeHeight();
        });
        
this.setIframeHeight = function()
{
    try {
	    obj = window.parent.document.getElementById('im1');	
	    oBody = obj.contentWindow.document.body;
	    var heights = oBody.scrollHeight+20;
	    if(heights < 600)
	    {
	        heights = 600;
	    }
	    $(window.parent.document.getElementById("im1")).height(heights);
    }
    catch(e) {};
}


this.SearchStar = function()
{
    var sid=$("select option:selected").val();
    location.href='BestStarSky.aspx?sid='+sid;
}

this.ShowDetail = function(FID)//FAQ
    {
        
        if(nid != FID)
        {
            $("#f"+nid+" #inserthtml").hide();
            nid = FID;
            $("#f"+FID+" #inserthtml").show();
        }
        else
        {
            if($("#f"+FID+" #inserthtml").css("display") == "none")
            {
                $("#f"+FID+" #inserthtml").show();
            }
            else
            {
                $("#f"+FID+" #inserthtml").hide();
            }
        }
        iframeResize();
    }
this.iframeResize = function()
    {		
		try {
			obj = window.parent.document.getElementById('im1');	
			oBody = obj.contentWindow.document.body;
			var heightb = oBody.scrollHeight;
			if(heightb < 600)
			{
			    heightb = 600
			}
			$(window.parent.document.getElementById("im1")).height(heightb);
		}
		catch(e) {};
    }
    
//解决回调函数中，this引用无效的问题
this.bind = function(instance, method)
{
    return function()
    {
	    method.apply(instance, arguments);
    }
}
this.SendVote = function()//用户投票
{
    var VID;
    if($("input[name='survey']:checked").size() == 0)
    {
        alert('您没有选择');
        return;
    }
    var RID = $("input[name='survey']:checked").val()
    var url = window.location.toString();
    url = url.toLowerCase();
    url = url.replace("#","");
    var paras = url.split("?");
    if(paras.length == 2)
    {
        VID = paras[1].split('&')[0].replace("id=","")
    }
    Request.sendPOST("../AjaxControl.aspx", "d="+new Date+"&n=3&vid="+VID+"&rid="+RID,
    this.bind(this, this.ReturnSend), null, null); 
}

this.SendchenVote = function(nvid,nrid)//魏晨广告投票
{
    Request.sendPOST("../AjaxControl.aspx", "d="+new Date+"&n=3&vid="+nvid+"&rid="+nrid,
    this.bind(this, this.ReturnCenSend), null, null); 
}

this.ReturnCenSend = function(req)//用户投票回调函数
{
    if(req.responseText == "login")
    {
        window.top.document.location='http://www.mystartown.com/wwwlogin.aspx?url='+escape(window.top.location)+'';
        return;
    }
    $("#votereturn").html(req.responseText);
}

this.ReturnSend = function(req)//用户投票回调函数
{
    if(req.responseText == "login")
    {
        window.top.document.location='http://www.mystartown.com/wwwlogin.aspx?url='+escape(window.top.location)+'';
        return;
    }
    $("#votereturn").html(req.responseText);
}

this.ShowQuestion = function(strTitle,strDtTime,strQuestion,strAnswer)
{
    $("#questionandanswer").show();
    $("#title").html(strTitle);
    $("#dttime").html(strDtTime);
    $("#question").html(unescape(strQuestion));
    $("#answer").html(strAnswer);
    iframeResize();
}

this.strlen = function()
{
    var str = $("#txbContent").val();
    var len = 0;
    for (var i = 0; i < str.length; i++) {
        if (str.charCodeAt(i) > 255) len += 2; else len ++;
    }
    if(len > 140)
    {
        alert('字数超出限制');
        $("#txbContent").val(str.substring(0,str.length-1));
        len = 140;
    }
    $("#txtlen").html(""+len+"/140");
    setTimeout("strlen()",100);
}

