// JavaScript Document
function getPS(node) {
    if (typeof(node) == "string") {
        node = document.getElementById(node);
    }
    var topValue = node.offsetTop;
    var leftValue = node.offsetLeft;
    var widthValue = node.offsetWidth;
    var heightValue = node.offsetHeight;
    while (node = node.offsetParent) {
        topValue += node.offsetTop;
        leftValue += node.offsetLeft;
    }
    if($.browser.msie){
        return {
            //left: leftValue+12,
            left: leftValue,
            top: topValue,
            width: widthValue,
            height: heightValue
        }
    } else if($.browser.mozilla){
        return {
            left: leftValue,
            top: topValue,
            width: widthValue,
            height: heightValue
        }
    } else {
        //topValue -= 23;
        return {
            left: leftValue,
            top: topValue,
            width: widthValue,
            height: heightValue
        }
    }
}

 

function showDetail(obj, cid) {
    companyid = cid;
    $(".company_detail").hide();
    //doShowDetail(obj, cid);
    setTimeout(function(){
        doShowDetail(obj, cid);
    },200);
}


function doShowDetail(obj,cid)
{
    //	alert(cid);
	
    $.ajax({
        type:'post',
        url:'jsoncompany.php',
        dataType: "json",//返回json格式的数据
        data:"cid="+cid,//可以直接加一个函数名。
        dataType:'json',
        //beforeSend:beforecall,
        success:function(data)
        {
            var companybandObj=document.getElementById("companyband");
            var tdJSON = getPS(obj);
            var companybandObj=getPS(companybandObj);
            $("#companyband li").find("div").addClass("lifilter");
            $(obj).find("div").removeClass("lifilter");
            $(".companyfile").hide();
  
            if (document.getElementById("companydband"+cid)) {
                $("#companyband li").find("div").addClass("lifilter");
                $(obj).find("div").removeClass("lifilter");
                $("#companydband" + cid).show();
            //$("#flashWallDetail" + cid).fadeIn(800);
            } else {
                var  htmlStr="";
                //判断top,left
  
                if ((tdJSON.left + tdJSON.width + 200) <= (companybandObj.left + companybandObj.width)) {
                    htmlStr += "<div class ='companyfile cleft' id='companydband" + cid + "' style='position:absolute;top:"+(tdJSON.top - 2)+"px;left:"+(tdJSON.left-2)+"px'>";
 
      
	  
                } else if ((tdJSON.left + tdJSON.width + 200) > (companybandObj.left + companybandObj.width)) {
                    if((companybandObj.width < tdJSON.width + 200) && ($.browser.version == "6.0" && $.browser.msie)){
                        htmlStr += "<div class ='companyfile cright' id='companydband" + cid + "' style='position:absolute;top:" + (tdJSON.top - 2) + "px;left:" + (tdJSON.left - 151) + "px;'>";
                    } else {
                        htmlStr += "<div class ='companyfile cright' id='companydband" + cid + "' style='position:absolute;top:" + (tdJSON.top - 2) + "px;left:" + (tdJSON.left - 2 - 200) + "px;'>";
                    }
  
  
                }
 
                if($.browser.msie){
                    htmlStr += "<div class='cflashwall_blank' style='height:" + (tdJSON.height-1)+"px;width:" + (tdJSON.width-1) + "px;'><a href=\"" + data.curl + "\" target=\"_blank\" onfocus=\"blur()\"><div style=\"cursor:pointer;height:" + (tdJSON.height-3)+"px;width:" + (tdJSON.width-3) + "px;\">&nbsp;</div></a></div>";
                } else {
                    htmlStr += "<div class='cflashwall_blank' style=' height:" + (tdJSON.height)+"px;width:" + (tdJSON.width-2) + "px;'><a href=\"" + data.curl + "\" target=\"_blank\" onfocus=\"blur()\"><div style=\"cursor:pointer;height:" + (tdJSON.height-3)+"px;width:" + (tdJSON.width-3) + "px;\">&nbsp;</div></a></div>";
                }

 
 
                htmlStr+="<ul class='bcul'><li class='bcli'><a href='qlm-com-info-"+cid+".htm' target='_blank'> "+data.name+"</a></li>";
                for(var i=0 ;i<data.job.length;i++)
                {
                    htmlStr+="<li>. <a href='qlm-job-info-"+data.job[i].jobrid+".htm' target='_blank'>"+data.job[i].jobname+"</a></li>";
                }
                htmlStr+="<li class='clear1'></li></ul></div>";
 
                $("#companyband").append(htmlStr);
   
                if($.browser.version == "6.0" && $.browser.msie ){
                    $(".companyfile").find("*").each(function(){
                        var bgIMG = $(this).css('background-image');
                        if(bgIMG.indexOf(".png")!=-1){
                            var iebg = bgIMG.split('url("')[1].split('")')[0];
                            $(this).css('background-image', 'none');
                            $(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
                        }
                    });
                }
               $("#companydband" + cid).fadeIn(500);
            }


        }


    });
 
}


 



function doShowDetail1(obj, cid) {
	
		
	
    if(flasWallLastCid != cid){
        return false;
    }
    $(".cflashwall_detailtable").hide();
    if (document.getElementById("flashWallDetail"+cid)) {
        $("#iflashtable li").find("div").addClass("cflashwall_tdfilter");
        $(obj).find("div").removeClass("cflashwall_tdfilter");
        $("#flashWallDetail" + cid).show();
    //$("#flashWallDetail" + cid).fadeIn(800);
    } else {
        var tableObj = document.getElementById("iflashtable");
        var tdJSON = getPS(obj);
        var tableJSON = getPS(tableObj);
        $("#iflashtable li").find("div").addClass("cflashwall_tdfilter");
        $(obj).find("div").removeClass("cflashwall_tdfilter");
        var jobCount = 0;
        var htmlStr = "";
        if ((tdJSON.left + tdJSON.width + 200) <= (tableJSON.left + tableJSON.width)) {
            htmlStr += "<table  class='cflashwall_detailtable' border=0 cellpadding=0 cellspacing=0 id='flashWallDetail" + cid + "' style='top:" + (tdJSON.top - 2) + "px;left:" + (tdJSON.left-2) + "px;'>";
            htmlStr += "<tr>";
            if($.browser.msie){
                htmlStr += "<td class='cflashwall_blank' style='border-left:3px solid #1896e2;border-top:3px solid #1896e2;border-bottom:3px solid #1896e2;height:" + (tdJSON.height-1)+"px;width:" + (tdJSON.width-1) + "px;'><a href=\"" + flashWallJson[cid].curl + "\" target=\"_blank\" onfocus=\"blur()\"><div style=\"cursor:pointer;height:" + (tdJSON.height-3)+"px;width:" + (tdJSON.width-3) + "px;\">&nbsp;</div></a></td>";
            } else {
                htmlStr += "<td class='cflashwall_blank' style='border-left:3px solid #1896e2;border-top:3px solid #1896e2;border-bottom:3px solid #1896e2;height:" + (tdJSON.height+3)+"px;width:" + (tdJSON.width-2) + "px;'><a href=\"" + flashWallJson[cid].curl + "\" target=\"_blank\" onfocus=\"blur()\"><div style=\"cursor:pointer;height:" + (tdJSON.height-3)+"px;width:" + (tdJSON.width-3) + "px;\">&nbsp;</div></a></td>";
            }
            htmlStr += "<td valign='top' class='cflashwall_company_and_job' nowrap style='border-right:3px solid #1896e2;border-top:3px solid #1896e2;border-bottom:3px solid #1896e2;'>";
            htmlStr += "<div class='cflashwall_company'><a href='" + flashWallJson[cid].curl + "' target='_blank' class='ccompany' onfocus=\"blur()\">" + flashWallJson[cid].cname + "</a></div>";
            for(var i = 0;i < flashWallJson[cid].job.length;i++){
                if($.trim(flashWallJson[cid].job[i].joburl) != "" && $.trim(flashWallJson[cid].job[i].jobname) != ""){
                    htmlStr += "<div class='cflashwall_job'>·<a href='" + flashWallJson[cid].job[i].joburl + "' target='_blank' class='cjob' onfocus=\"blur()\">" + flashWallJson[cid].job[i].jobname + "</a></div>";
                    jobCount++;
                }
            }
            if(jobCount == 0){
                htmlStr += "<div class='cflashwall_job'>·<a href='" + flashWallJson[cid].curl + "' target='_blank' class='cjob' onfocus=\"blur()\">查看招聘中的职位</a></div>";
            }
            htmlStr += "</td>";
            htmlStr += "<td class='cshadowright'>&nbsp;</td>";
            htmlStr += "</tr>";
            htmlStr += "<tr><td colspan=2 class='cshadowbottom'>&nbsp;</td><td class='cshadowrightbottom'>&nbsp;</td></tr>";
            htmlStr += "</table>";
        } else if ((tdJSON.left + tdJSON.width + 200) > (tableJSON.left + tableJSON.width)) {
            if((tableJSON.width < tdJSON.width + 200) && ($.browser.version == "6.0" && $.browser.msie)){
                htmlStr += "<table class='cflashwall_detailtable' border=0 cellpadding=0 cellspacing=0 id='flashWallDetail" + cid + "' style='top:" + (tdJSON.top - 2) + "px;left:" + (tdJSON.left - 199) + "px;'>";
            } else {
                htmlStr += "<table class='cflashwall_detailtable' border=0 cellpadding=0 cellspacing=0 id='flashWallDetail" + cid + "' style='top:" + (tdJSON.top - 2) + "px;left:" + (tdJSON.left - 2 - 200) + "px;'>";
            }
            htmlStr += "<tr>";
            htmlStr += "<td valign='top' class='cflashwall_company_and_job' nowrap style='border-left:3px solid #1896e2;border-top:3px solid #1896e2;border-bottom:3px solid #1896e2;'>";
            htmlStr += "<div class='cflashwall_company'><a href='" + flashWallJson[cid].curl + "' target='_blank' class='ccompany' onfocus=\"blur()\">" + flashWallJson[cid].cname + "</a></div>";
            for(var i = 0;i < flashWallJson[cid].job.length;i++){
                if($.trim(flashWallJson[cid].job[i].joburl) != "" && $.trim(flashWallJson[cid].job[i].jobname) != ""){
                    htmlStr += "<div class='cflashwall_job'>·<a href='" + flashWallJson[cid].job[i].joburl + "' target='_blank' class='cjob' onfocus=\"blur()\">" + flashWallJson[cid].job[i].jobname + "</a></div>";
                    jobCount++;
                }
            }
            if(jobCount == 0){
                htmlStr += "<div class='cflashwall_job'>·<a href='" + flashWallJson[cid].curl + "' target='_blank' class='cjob' onfocus=\"blur()\">查看招聘中的职位</a></div>";
            }
            htmlStr += "</td>";
            if($.browser.msie){
                htmlStr += "<td class='cflashwall_blank' style='border-right:3px solid #1896e2;border-top:3px solid #1896e2;border-bottom:3px solid #1896e2;height:" + (tdJSON.height-2)+"px;width:" + (tdJSON.width-2) + "px;'><a href=\"" + flashWallJson[cid].curl + "\" target=\"_blank\" onfocus=\"blur()\"><div style=\"cursor:pointer;height:" + (tdJSON.height-3)+"px;width:" + (tdJSON.width-3) + "px;\">&nbsp;</div></a></td>";
            } else {
                htmlStr += "<td class='cflashwall_blank' style='border-right:3px solid #1896e2;border-top:3px solid #1896e2;border-bottom:3px solid #1896e2;height:" + (tdJSON.height+3)+"px;width:" + (tdJSON.width-2) + "px;'><a href=\"" + flashWallJson[cid].curl + "\" target=\"_blank\" onfocus=\"blur()\"><div style=\"cursor:pointer;height:" + (tdJSON.height-3)+"px;width:" + (tdJSON.width-3) + "px;\">&nbsp;</div></a></td>";
            }
            htmlStr += "<td class='cshadowright'>&nbsp;</td>";
            htmlStr += "</tr>";
            htmlStr += "<tr><td colspan=2 class='cshadowbottom'>&nbsp;</td><td class='cshadowrightbottom'>&nbsp;</td></tr>";
            htmlStr += "</table>";
        }
        $("#new51pd").append(htmlStr);
        if($.browser.version == "6.0" && $.browser.msie ){
            $(".cflashwall_detailtable").find("*").each(function(){
                var bgIMG = $(this).css('background-image');
                if(bgIMG.indexOf(".png")!=-1){
                    var iebg = bgIMG.split('url("')[1].split('")')[0];
                    $(this).css('background-image', 'none');
                    $(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
                }
            });
        }
		
        $("#flashWallDetail" + cid).fadeIn(500);
    }
}

function hideDetail(evt,obj) {
    evt = (evt)?evt:window.event;
    var tableObj = document.getElementById("new51pd");
    //var tableObj = obj;
    var toElementObj;
    if($.browser.msie){
        toElementObj = evt.toElement;
    } else if($.browser.mozilla){
        toElementObj = evt.relatedTarget;
    } else {
        toElementObj = evt.relatedTarget;
    }
    if (!tableObj.contains(toElementObj)) {
        flasWallLastCid = "";
        $("#iflashtable li").find("div").removeClass("cflashwall_tdfilter");
        $(".cflashwall_detailtable").fadeOut(500);
    }
}

if(typeof(HTMLElement) != "undefined"){
    HTMLElement.prototype.contains = function(obj) {
        while(obj != null &&  typeof(obj.tagName) != "undefind"){
            if(obj == this)
                return true;
            obj = obj.parentNode;
        }
        return false;
    };
}


