﻿/* 加载 指定的 url 的 ajax 信息到指定的dom中 */
function loadHTML(domID, url)
{
	url += ( url.indexOf('?')>0 ) ? '&' : '?';
	$.get(
		url + 'time=' + new Date().getTime(),
		function(result)
		{ setInnerHTML(document.getElementById(domID), result); }
	);
}


//分页条的显示
//开始页
var startPage = 0;
//结束页
var endPage = 0;
function ShowPageBar()
{

	//当前url
	var currentLocation = window.location.href;
	var currentPageInfo = currentLocation.replace('//','/').split('/');


	var xmlHTTP = createXMLHttpRequest();

	url = '/H/json/' + currentPageInfo[currentPageInfo[currentPageInfo.length-2]] + '_maxPage.html?time=' + new Date().getTime().toString().substring(0, 10);

	xmlHTTP.open('GET', url, false);
	xmlHTTP.setRequestHeader("Content-Type","text/xml;charset=UTF-8;");
	xmlHTTP.send(null);

	//得到当前json文件
	var maxPage = xmlHTTP.responseText;


	//url的主体部分例:

	var currentArea = '/' + currentPageInfo[currentPageInfo.length-2] + '/';

	currentPageInfo = currentPageInfo[currentPageInfo.length-1].split('-');

	//当前页号
	var currentPage = ( !currentPageInfo[0] ) ? 1 : currentPageInfo[0];
	startPage = ( !currentPageInfo[1] ) ? 1 : currentPageInfo[1];

	if (startPage == 1)
	{
		endPage = startPage + 9;
		if (endPage > maxPage)
			endPage = maxPage;
	}
	else
	{ endPage = startPage + 9; }
	TurnPage(currentPage, maxPage);

	document.write('<div style="width:100%; text-align:center;">');
	if(maxPage <= 1){ document.write('1');}
	else
	{
	    if(currentPage <= 0)
		    document.write('上一页&nbsp;');
	    else
	    	document.write('<a href="' + currentArea + (parseInt(currentPage)-1) +'-' + startPage +'">上一页</a>&nbsp;');

    	for(i=startPage;i<=endPage && i<=maxPage;i++)
	    {
		    if(i ==currentPage)
		    	document.write(i + '&nbsp;');
		    else
		    	document.write('<a href="' + currentArea + i +'-' + startPage +'">'+i+'</a>&nbsp;');
	    }
	    if(currentPage>=maxPage)
	    	document.write('下一页');
	    else
	    	document.write('<a href="' + currentArea +(parseInt(currentPage)+1) +'-' + startPage +'">下一页</a>');
    }
   document.write('</div>');
}
function TurnPage(currentPageIndex, maxPage)
{
    if (maxPage > 10)
    {
        if (currentPageIndex - startPage < 1)
        {
            startPage = startPage - 8;
            endPage = endPage - 8;
        }
        else
        {
            if (endPage - currentPageIndex < 1)
            {
                startPage = startPage + 8;
                endPage = endPage + 8;
            }
        }
    }
    if (startPage < 1)
    {
        endPage = endPage + (1 - startPage);
        startPage = 1;
    }
    if (endPage > maxPage)
    {
        startPage = startPage - (endPage - maxPage);
        endPage = maxPage;
    }
}


function OnSearchKeyDown()
{
        var k=window.event.keyCode;
        if(k==13){document.getElementById('btnSearch').click();}
}
//对汉字的utf-8编码
function EncodeUtf8(s1)
{
var s = escape(s1);
var sa = s.split("%");
var retV ="";
if(sa[0] != "")retV = sa[0];
for(var i = 1; i < sa.length; i ++)
   if(sa[i].substring(0,1) == "u") retV += Hex2Utf8(Str2Hex(sa[i].substring(1,5)));else retV += "%" + sa[i];
return retV;
}
function Str2Hex(s)
{
var c = "";
var n;
var ss = "0123456789ABCDEF";
var digS = "";
for(var i = 0; i < s.length; i ++)
{
    c = s.charAt(i);
    n = ss.indexOf(c);
    digS += Dec2Dig(eval(n));
}
return digS;
}
function Dec2Dig(n1)
{
var s = "";
var n2 = 0;
for(var i = 0; i < 4; i++)
{
    n2 = Math.pow(2,3 - i);
    if(n1 >= n2)
    {
        s += '1';
        n1 = n1 - n2;
    }
    else
        s += '0';
}
return s;
}
function Dig2Dec(s)
{
var retV = 0;
if(s.length == 4)
{
    for(var i = 0; i < 4; i ++)
    {
        retV += eval(s.charAt(i)) * Math.pow(2, 3 - i);
    }
    return retV;
}
return -1;
} 
function Hex2Utf8(s)
{
var retS = "";
var tempS = "";
var ss = "";
if(s.length == 16)
{
    tempS = "1110" + s.substring(0, 4);
    tempS += "10" +  s.substring(4, 10); 
    tempS += "10" + s.substring(10,16); 
    var sss = "0123456789ABCDEF";
    for(var i = 0; i < 3; i ++)
    {
        retS += "%";
        ss = tempS.substring(i * 8, (eval(i)+1)*8);
        retS += sss.charAt(Dig2Dec(ss.substring(0,4)));
        retS += sss.charAt(Dig2Dec(ss.substring(4,8)));
    }
return retS;
}
return "";
}		
function OpenNewWindow()
{
	var txtSearch = document.getElementById("txtSearchInfo");
    txtSearch.focus();
    var strSearch = txtSearch.value.replace(/(^\s*)|(\s*$)/g, '');
    if(strSearch== ''|| strSearch == '请输入搜索关键词'){
        alert('请输入搜索关键词!');
        return;
    }
    window.open("/SearchKey.aspx?word=" + EncodeUtf8(strSearch));
}

function getStyleId(intSkin)
{
	if(intSkin == -1)
	 intSkin = getMyCookie('skin');
	return ( !intSkin ) ? 0 : intSkin;
}

function setInnerHTML(el, htmlCode) {
	var ua = navigator.userAgent.toLowerCase();
	if (ua.indexOf('msie') >= 0 && ua.indexOf('opera') < 0) {
		htmlCode = '<div style="display:none">for IE</div>' + htmlCode;
		htmlCode = htmlCode.replace(/<script([^>]*)>/gi, '<script$1 defer>');
		el.innerHTML = htmlCode;
		el.removeChild(el.firstChild);
	} else {
		var el_next = el.nextSibling;
		var el_parent = el.parentNode;
		el_parent.removeChild(el);
		el.innerHTML = htmlCode;
		if (el_next) { el_parent.insertBefore(el, el_next); }
		else { el_parent.appendChild(el); }
	}
}

function toBreakWord( obj, intLen ){
    var strContent=obj.innerHTML;
    var strTemp="";
    while(strContent.length>intLen){
        strTemp+=strContent.substr(0,intLen)+"";
        strContent=strContent.substr(intLen,strContent.length);
    }
    strTemp+= ""+strContent;
    obj.innerHTML=strTemp;
}

function openPopup(strFile, strWinName, intWidth, intHeight) {
    var intSreenWidth = 770;
    var intSreenHeight = 580;
    var intLeft = 0;
    var intTop = 0;
    if (self.screen) {
        intSreenWidth = screen.width - 12;
        intSreenHeight = screen.height - 70;
    } //endif
    if (intWidth != 0 && intHeight != 0) {
        intLeft = (intSreenWidth-intWidth)/2;
        intTop = (intSreenHeight-intHeight)/2;
    } else {
        intWidth = intSreenWidth;
        intHeight = intSreenHeight;
    } //endif
    objPopup = window.open(strFile, strWinName, 'top='+intTop+', left='+intLeft+', width='+intWidth+', height='+intHeight+', toolbar=no, directories=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes');
    objPopup.focus();
} //endfunc

function setMyCookie(strCookieName, strCookieValue, intCookieExpireDay, strCookiePath, strCookieDomain, blnCookieSecure) {
    // Begin the cookie parameter string
    var strCookieString = strCookieName + "=" + strCookieValue
    // Add the expiration date, if it was specified
    if (intCookieExpireDay) {
        var expire_date = new Date()
        var ms_from_now = intCookieExpireDay * 24 * 60 * 60 * 1000
        expire_date.setTime(expire_date.getTime() + ms_from_now)
        var expire_string = expire_date.toGMTString()
        strCookieString += "; expires=" + expire_string
    } //endif
    // Add the path, if it was specified
    if (strCookiePath) {
        strCookieString += "; path=" + strCookiePath
    } //endif
    // Add the domain, if it was specified
    if (strCookieDomain) {
        strCookieString += "; domain=" + strCookieDomain
    } //endif
    // Add the secure boolean, if it's true
    if (blnCookieSecure) {
        strCookieString += "; true"
    } //endif
    // Set the cookie
    document.cookie = strCookieString
} //endfunc

function getMyCookie(strGetCookieName) {
    var strCookiePair
    var strCookieName
    var strCookieValue
    // Split all the cookies into an array
    var arrCookie = document.cookie.split("; ")
    // Run through the cookies
    for (var j = 0; j < arrCookie.length; j++) {
        // Split the cookie into a name/value pair
        strCookiePair = arrCookie[j].split("=")
        strCookieName = strCookiePair[0]
        strCookieValue = strCookiePair[1]
        // Compare the name with the name we want
        if (strCookieName == strGetCookieName) {
            // If this is the one, return the value
            return unescape(strCookieValue)
        } //endif
    } //endfor
    // If the cookie doesn't exist, return null
    return null
} //endfunc

function deleteMyCookie(strCookieName) {
    setMyCookie(strCookieName, "", -1000 * 60 * 60 * 24 * 5)
} //endfunc

function addEvent(elm, evType, fn, useCapture) {
    if (elm.addEventListener) {
        elm.addEventListener(evType, fn, useCapture);
        return true;
    } else if (elm.attachEvent) {
        var r = elm.attachEvent('on' + evType, fn);
        return r;
    } else {
        elm['on' + evType] = fn;
    } //endif
} //endfunc


function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        } //endfunc
    } //endif
} //endfunc

function setWinWidth() {
    var width = 1000;
    width = screen.availWidth;
    if (width < 1000) {
        window.moveTo(0, 0);
        window.resizeTo(1000, 700);
    } //endif
} //endfunc

/*
setTimeout ("frameKiller()", 3000);
function frameKiller()
{
    if (self.parent.frames.length != 0)
    if (self.parent.location != document.location) {
        self.parent.location=document.location;
    } //endif
} //endfunc
*/
//按钮切换
function OnRadioButtonClick(name,order)
    {
        if(order == 1)
        {
           document.all[name+"1"].checked = true;
           document.all[name+"2"].checked = false;
        }
        else
        {
           document.all[name+"1"].checked = false;
           document.all[name+"2"].checked = true;
        }
    }



// 返回 google 颜色信息

function getGoogleColorBg( intSkinID, seat )
{
	var strColor = '';
	switch (intSkinID)
	{
		case '0':
			strColor = ( 'base' == seat ) ? "CFCFCF" :
								( 'deep' == seat ) ? "535353" : "EFEFEF";
			break;
		case '1':
			strColor = ( 'base' == seat ) ? "D3C5C3" :
								( 'deep' == seat ) ? "36271B" : "F7E9DB";
			break;
		case '2':
			strColor = ( 'base' == seat ) ? "DBCDCC" :
								( 'deep' == seat ) ? "344E81" : "F9F5F4";
			break;
		case '3':
			strColor = ( 'base' == seat ) ? "D2C7BC" :
								( 'deep' == seat ) ? "36271B" : "F1EDF3";
			break;
		case '4':
			strColor = ( 'base' == seat ) ? "9AA4B5" :
								( 'deep' == seat ) ? "274E8D" : "D3D0D0";
			break;
		case '5':
			strColor = ( 'base' == seat ) ? "D2B494" :
								( 'deep' == seat ) ? "4D3329" : "F5F5EC";
			break;
		case '6':
			strColor = ( 'base' == seat ) ? "93B9A6" :
								( 'deep' == seat ) ? "405945" : "D8E7DC";
			break;
		case '7':
			strColor = ( 'base' == seat ) ? "D38CAE" :
								( 'deep' == seat ) ? "691919" : "FAD5E2";
			break;
		case '8':
			strColor = ( 'base' == seat ) ? "E4CB98" :
								( 'deep' == seat ) ? "685218" : "F7F4DD";
			break;
		case '9':
			strColor = ( 'base' == seat ) ? "D2AA8A" :
								( 'deep' == seat ) ? "8A4F1F" : "FBF2DE";
			break;
		case '10':
			strColor = ( 'base' == seat ) ? "9BC3DA" :
								( 'deep' == seat ) ? "335583" : "EAF1F0";
			break;
		case '11':
			strColor = ( 'base' == seat ) ? "CCD2D8" :
								( 'deep' == seat ) ? "3D4346" : "E6EBF4";
			break;
		case '12':
			strColor = ( 'base' == seat ) ? "88A578" :
								( 'deep' == seat ) ? "35534B" : "E7F3F5";
			break;
		case '13':
			strColor = ( 'base' == seat ) ? "96ACC2" :
								( 'deep' == seat ) ? "4E6771" : "DFECFF";
			break;
		case '14':
			strColor = ( 'base' == seat ) ? "99A592" :
								( 'deep' == seat ) ? "505F48" : "F6EED5";
			break;
		case '15':
			strColor = ( 'base' == seat ) ? "000000" :
								( 'deep' == seat ) ? "535353" : "646464";
			break;
		default:
			strColor = ( 'base' == seat ) ? "CFCFCF" :
								( 'deep' == seat ) ? "535353" : "EFEFEF";
			break;
	}
	return strColor;
}

function getGoogleColorText( intSkinID, seat )
{
	var strColor = '';
	switch (intSkinID)
	{
		case '0':
			strColor = ( 'base' == seat ) ? "EFEFEF" :
						( 'deep' == seat ) ? "EFEFEF" : "333333";
			break;
		case '1':
			strColor = ( 'base' == seat ) ? "F7E9DB" :
						( 'deep' == seat ) ? "F7E9DB" : "26170B";
			break;
		case '2':
			strColor = ( 'base' == seat ) ? "F9F5F4" :
						( 'deep' == seat ) ? "F9F5F4" : "142E61";
			break;
		case '3':
			strColor = ( 'base' == seat ) ? "F7E9DB" :
						( 'deep' == seat ) ? "F7E9DB" : "26170B";
			break;
		case '4':
			strColor = ( 'base' == seat ) ? "D3D0D0" :
						( 'deep' == seat ) ? "D3D0D0" : "07316D";
			break;
		case '5':
			strColor = ( 'base' == seat ) ? "F5F5EC" :
						( 'deep' == seat ) ? "F5F5EC" : "2D1309";
			break;
		case '6':
			strColor = ( 'base' == seat ) ? "D8E7DC" :
						( 'deep' == seat ) ? "D8E7DC" : "203925";
			break;
		case '7':
			strColor = ( 'base' == seat ) ? "333333" :
						( 'deep' == seat ) ? "F7E9DB" : "590909";
			break;
		case '8':
			strColor = ( 'base' == seat ) ? "F7F4DD" :
						( 'deep' == seat ) ? "F7F4DD" : "584208";
			break;
		case '9':
			strColor = ( 'base' == seat ) ? "352C2A" :
						( 'deep' == seat ) ? "352C2A" : "352C2A";
			break;
		case '10':
			strColor = ( 'base' == seat ) ? "EAF1F0" :
						( 'deep' == seat ) ? "EAF1F0" : "234573";
			break;
		case '11':
			strColor = ( 'base' == seat ) ? "E6EBF4" :
						( 'deep' == seat ) ? "E6EBF4" : "231B24";
			break;
		case '12':
			strColor = ( 'base' == seat ) ? "E7F3F5" :
						( 'deep' == seat ) ? "E7F3F5" : "15332B";
			break;
		case '13':
			strColor = ( 'base' == seat ) ? "494E65" :
						( 'deep' == seat ) ? "DFECFF" : "494E65";
			break;
		case '14':
			strColor = ( 'base' == seat ) ? "523116" :
						( 'deep' == seat ) ? "F6EED5" : "523116";
			break;
		case '15':
			strColor = ( 'base' == seat ) ? "F6F6EE" :
						( 'deep' == seat ) ? "F6F6EE" : "F6F6EE";
			break;
		default:
			strColor = ( 'base' == seat ) ? "EFEFEF" :
						( 'deep' == seat ) ? "EFEFEF" : "333333";
			break;
	}
	return strColor;
}

function getGoogleColorUrl( intSkinID, seat )
{
	var strColor = '';
	switch (intSkinID)
	{
		case '0':
			strColor = ( 'base' == seat ) ? "333333" :
						( 'deep' == seat ) ? "333333" : "333333";
			break;
		case '1':
			strColor = ( 'base' == seat ) ? "26170B" :
						( 'deep' == seat ) ? "26170B" : "26170B";
			break;
		case '2':
			strColor = ( 'base' == seat ) ? "142E61" :
						( 'deep' == seat ) ? "142E61" : "142E61";
			break;
		case '3':
			strColor = ( 'base' == seat ) ? "26170B" :
						( 'deep' == seat ) ? "26170B" : "26170B";
			break;
		case '4':
			strColor = ( 'base' == seat ) ? "07316D" :
						( 'deep' == seat ) ? "07316D" : "07316D";
			break;
		case '5':
			strColor = ( 'base' == seat ) ? "2D1309" :
						( 'deep' == seat ) ? "2D1309" : "2D1309";
			break;
		case '6':
			strColor = ( 'base' == seat ) ? "203925" :
						( 'deep' == seat ) ? "203925" : "203925";
			break;
		case '7':
			strColor = ( 'base' == seat ) ? "333333" :
						( 'deep' == seat ) ? "590909" : "590909";
			break;
		case '8':
			strColor = ( 'base' == seat ) ? "584208" :
						( 'deep' == seat ) ? "584208" : "584208";
			break;
		case '9':
			strColor = ( 'base' == seat ) ? "352C2A" :
						( 'deep' == seat ) ? "352C2A" : "352C2A";
			break;
		case '10':
			strColor = ( 'base' == seat ) ? "234573" :
						( 'deep' == seat ) ? "234573" : "234573";
			break;
		case '11':
			strColor = ( 'base' == seat ) ? "231B24" :
						( 'deep' == seat ) ? "231B24" : "231B24";
			break;
		case '12':
			strColor = ( 'base' == seat ) ? "15332B" :
						( 'deep' == seat ) ? "15332B" : "15332B";
			break;
		case '13':
			strColor = ( 'base' == seat ) ? "494E65" :
						( 'deep' == seat ) ? "494E65" : "494E65";
			break;
		case '14':
			strColor = ( 'base' == seat ) ? "523116" :
						( 'deep' == seat ) ? "523116" : "523116";
			break;
		case '15':
			strColor = ( 'base' == seat ) ? "FF0000" :
						( 'deep' == seat ) ? "FF0000" : "F6F6EE";
			break;
		default:
			strColor = ( 'base' == seat ) ? "333333" :
						( 'deep' == seat ) ? "333333" : "333333";
			break;
	}
	return strColor;
}

function getGoogleColorLink( intSkinID, seat )
{
	var strColor = '';
	switch (intSkinID)
	{
		case '0':
			strColor = ( 'base' == seat ) ? "333333" :
						( 'deep' == seat ) ? "333333" : "ff0000";
			break;
		case '1':
			strColor = ( 'base' == seat ) ? "F7E9DB" :
						( 'deep' == seat ) ? "F7E9DB" : "ff0000";
			break;
		case '2':
			strColor = ( 'base' == seat ) ? "F9F5F4" :
						( 'deep' == seat ) ? "F9F5F4" : "ff0000";
			break;
		case '3':
			strColor = ( 'base' == seat ) ? "F7E9DB" :
						( 'deep' == seat ) ? "F7E9DB" : "ff0000";
			break;
		case '4':
			strColor = ( 'base' == seat ) ? "D3D0D0" :
						( 'deep' == seat ) ? "D3D0D0" : "ff0000";
			break;
		case '5':
			strColor = ( 'base' == seat ) ? "F5F5EC" :
						( 'deep' == seat ) ? "F5F5EC" : "ff0000";
			break;
		case '6':
			strColor = ( 'base' == seat ) ? "D8E7DC" :
						( 'deep' == seat ) ? "D8E7DC" : "ff0000";
			break;
		case '7':
			strColor = ( 'base' == seat ) ? "333333" :
						( 'deep' == seat ) ? "F7E9DB" : "ff0000";
			break;
		case '8':
			strColor = ( 'base' == seat ) ? "F7F4DD" :
						( 'deep' == seat ) ? "F7F4DD" : "ff0000";
			break;
		case '9':
			strColor = ( 'base' == seat ) ? "352C2A" :
						( 'deep' == seat ) ? "FBF2DE" : "ff0000";
			break;
		case '10':
			strColor = ( 'base' == seat ) ? "EAF1F0" :
						( 'deep' == seat ) ? "EAF1F0" : "ff0000";
			break;
		case '11':
			strColor = ( 'base' == seat ) ? "E6EBF4" :
						( 'deep' == seat ) ? "E6EBF4" : "ff0000";
			break;
		case '12':
			strColor = ( 'base' == seat ) ? "E7F3F5" :
						( 'deep' == seat ) ? "E7F3F5" : "ff0000";
			break;
		case '13':
			strColor = ( 'base' == seat ) ? "494E65" :
						( 'deep' == seat ) ? "DFECFF" : "ff0000";
			break;
		case '14':
			strColor = ( 'base' == seat ) ? "523116" :
						( 'deep' == seat ) ? "F6EED5" : "ff0000";
			break;
		case '15':
			strColor = ( 'base' == seat ) ? "F6F6EE" :
						( 'deep' == seat ) ? "F6F6EE" : "ffffff";
			break;
		default:
			strColor = ( 'base' == seat ) ? "333333" :
						( 'deep' == seat ) ? "333333" : "ff0000";
			break;
	}
	return strColor;
}

function getGoogleColorBorder( intSkinID, seat )
{
	var strColor = '';
	switch (intSkinID)
	{
		case '0':
			strColor = ( 'base' == seat ) ? "EFEFEF" :
						( 'deep' == seat ) ? "ffffff" : "EFEFEF";
			break;
		default:
			strColor = ( 'base' == seat ) ? "FFFFFF" :
						( 'deep' == seat ) ? "ffffff" : "ffffff";
			break;
	}
	return strColor;
}

function tickClock(domId) {
	
var Dom = document.getElementById(domId);
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today = new Date();
month=today.getMonth()+1;
strDay=today.getDate();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
day=today.getDay();
switch(day)
{
	case 1:daystr="星期一";break;
	case 2:daystr="星期二";break;
	case 3:daystr="星期三";break;
	case 4:daystr="星期四";break;
	case 5:daystr="星期五";break;
	case 6:daystr="星期六";break;
	case 0:daystr="星期日";break;
}
if (intHours == 0) {
	hours = "12:";
	xfile = "午夜";
} else if (intHours < 12) {
	hours = intHours+":";
	xfile = "上午";
} else if (intHours == 12) {
	hours = "12:";
	xfile = "正午";
} else {
	intHours = intHours - 12
	hours = intHours + ":";
	xfile = "下午";
}
if (intMinutes < 10) { minutes = "0"+intMinutes+":"; }
else { minutes = intMinutes+":"; }
if (intSeconds < 10) { seconds = "0"+intSeconds+" "; }
else { seconds = intSeconds+" "; }
timeString = month + "月" + strDay + "日&nbsp;" + daystr + "&nbsp;" + xfile + hours + minutes + seconds;
Dom.innerHTML=timeString;
window.setTimeout("tickClock('"+domId+"');", 1000);
}
