﻿function $(id) {
    return document.getElementById(id);
};

function getposOffset(what, offsettype) {
    var totaloffset = (offsettype == "left") ? what.offsetLeft : what.offsetTop;
    var parentEl = what.offsetParent;
    while (parentEl != null) {
        totaloffset = (offsettype == "left") ? totaloffset + parentEl.offsetLeft : totaloffset + parentEl.offsetTop;
        parentEl = parentEl.offsetParent;
    }
    return totaloffset;
}


//左菜单关于详细分类div 

var sortArray;
var sortId = -1;
//function showwindowExtra(obj, objdiv, addx, addy, ids) {  
//    if (sortArray[ids].length > 0) {
//        $("sortTitle").innerHTML = obj.childNodes[0].nodeValue;
//        $("sortTitle").href = obj;
//        $("sortTitle").target = "_blank"; 
//        if (sortArray[ids].length == 0) {
//            sortId = -1;
//            $("sortContentBox").style.display = "none";
//            $("sortTitle").className = "flxf_left2";
//        }
//        else {
//            sortId = ids;
//            $("sortTitle").className = "flxf_left";
//            $("sortContentBox").style.display = "inline";
//            $("sortContent" + sortId).style.display = "";
//        }
//        var x = getposOffset(obj, 'left');
//        var y = getposOffset(obj, 'top');
//        var div_obj = $(objdiv);
//        div_obj.style.left = (x + addx) + 'px';
//        div_obj.style.top = (y + addy) + 'px';
//        div_obj.style.display = "inline";
//        $("SortBoxShadowRight").style.height = ($("SortBoxRight").offsetHeight +2) + "px";
//    }
//}

function showwindowExtra(obj, objdiv, addx, addy, ids) {
    if (sortArray[ids].length > 0) {		 
       // $("sortTitle").innerHTML = obj.childNodes[0].nodeValue;
		  $("sortTitle_2").innerHTML = $(obj).childNodes[0].nodeValue;
		 // alert($("sortTitle").innerHTML);
		  
        $("sortTitle_2").href = $(obj);
		  
		 // alert($("sortTitle").innerHTML);
		  
        $("sortTitle_2").target = "_blank"; 
        if (sortArray[ids].length == 0) {
            sortId = -1;
            $("sortContentBox").style.display = "none";
            $("sortTitle_2").className = "flxf_left2";
        }
        else {
            sortId = ids;
            $("sortTitle_2").className = "flxf_left";
            $("sortContentBox").style.display = "inline";
            $("sortContent" + sortId).style.display = "";
        }
        var x = getposOffset($(obj), 'left');
		  
        var y = getposOffset($(obj), 'top');
        var div_obj = $(objdiv);
        div_obj.style.left = (x + addx) + 'px';
        div_obj.style.top = (y + addy) + 'px';
        div_obj.style.display = "inline";
        $("SortBoxShadowRight_2").style.height = ($("SortBoxRight").offsetHeight +2) + "px";
    }
}

function hidewindowExtra(objdiv, ids) {
    var div_obj = $(objdiv);
    var ul_obj = $("sortContent" + ids);
    if (div_obj) div_obj.style.display = "none";
    if (ul_obj) ul_obj.style.display = "none";
}

function showwindowExtra2() {
    if (sortId != -1) $("sortContent" + sortId).style.display = "";
    $('sortBox').style.display = 'inline';
}

function hidewindowExtra2() {
    if (sortId != -1) $("sortContent" + sortId).style.display = "none";
    $('sortBox').style.display = 'none';
}

function loadOver() {
    if (!isIE()) {
        $("SortBoxShadowRight_2").style.width = "173px";
    }
    else {
        $("SortBoxShadowLeft").style.height = "2px";
        $("SortBoxShadowLeft").style.position = "static";
    }
}


function initSortCreate() {
    var tempString = "";
    for (var i = 0; i < sortArray.length; i++) {
        tempString += "<ul id=\"sortContent" + i + "\" style=\"display:none\">";
        for (var j = 0; j < sortArray[i].length; j++) {
            tempString += "<li class='flxf_font'><a href=\"" + sortArray[i][j + 1] + "\" target='_blank'>" + sortArray[i][j] + "</a></li>";
            j++;
        }
        tempString += "</ul>";
    }
    document.write(tempString);
}

var start = ["<img src='images/icon_star_gray.gif'/>", "<img src='images/icon_star_harf.gif'/>", "<img src='images/icon_star_red.gif'/>"];
var starts = [2, 0, 0, 0, 0, 2, 1, 0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 1, 0, 0, 2, 2, 2, 0, 0, 2, 2, 2, 1, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2];
function getStarsHtml(o) {
    var s = [], i;
    for (i = 0; i < 5; i++) s.push(start[starts[(o - 1) * 10 + i]]);
    return s.join('');
}


