/**
 * Javascript v1.2 for VeryCD.com
 *
 * Copyright 2005 VeryCD Team and xdanger<@http://www.xdanger.com/>
 * Some Rights Reserved
 *
 * $Id: main.js,v 1.13 2005/04/28 03:07:42 xdanger Exp $
 */

if (navigator.userAgent.indexOf("MSIE") > -1) {
    var is_IE = true;
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}
function getCookie(name) {
	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;
}
function setCookie(name, value) {
	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;
	document.cookie = name + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}
function suitPic() {
    var imgName = "post_img";
    var width   = 0;
    var height  = 0;
    var changed = 0;
    if (screen.width >= 1024) {
        var setwidth = 780;
    } else {
        var setwidth = 592;
    }
    var setheight = 2000;
    var post_img = document.getElementsByName(imgName);
    try {
        for (i = 0; i < post_img.length; i++) {
            width = post_img[i].width;
            height = post_img[i].height;
            changed = 0;
            if (post_img[i].width > setwidth) {
                n = post_img[i].width / setwidth
                post_img[i].width = setwidth;
                post_img[i].height = height / n
                changed = 1;
            }
            if (post_img[i].height > setheight) {
                n = post_img[i].height / setheight
                post_img[i].width = post_img[i].width / n
                post_img[i].height = setheight;
                changed = 1;
            }
            if (changed == 1) {
                post_img[i].insertAdjacentHTML("AfterEnd", "<div style=\"margin-top:4px;\">原图:<a href=\"" + post_img[i].src + "\">" + post_img[i].src + "</a> | " + width + "x" + height + "</div>");
            }
        }
        window.setTimeout("suitPic()", 100)
    }
    catch(e) {
        window.setTimeout("suitPic()", 100)
    }
}
suitPic();

/**
 * FreeIPB eMule下载时使用
 */
function checkAll(str,checked) {
    var a = document.getElementsByName(str);
    var n = a.length;

    for (var i = 0; i < n; i++) {
        a[i].checked = checked;
    }
    em_size(str);
}

function download(str, i, first) {
    var a = document.getElementsByName(str);
    var n = a.length;

    for (var i = i; i < n; i++) {
        if(a[i].checked) {
            window.location=a[i].value;
            if (first)
                timeout = 6000;
            else
                timeout = 500;
            i++;
            window.setTimeout("download('"+str+"', "+i+", 0)", timeout);
            break;
        }
    }

}

function copy(str) {
    var a = document.getElementsByName(str);
    var n = a.length;
    var ed2kcopy = document.getElementById("ed2kcopy_"+str)
    ed2kcopy.innerHTML = ""
    for (var i = 0; i < n; i++) {
        if(a[i].checked)
        {
            ed2kcopy.innerHTML += a[i].value;
            ed2kcopy.innerHTML += "<br />";
        }
    }
        var rng = document.body.createTextRange();
        rng.moveToElementText(ed2kcopy)
        rng.scrollIntoView();
        rng.select();
        rng.execCommand("Copy");
        rng.collapse(false);
}

function em_size(str) {
    var a = document.getElementsByName(str);
    var n = a.length;
    try {
        var input_checkall = document.getElementById("checkall_"+str);
        var size = 0;
        input_checkall.checked = true ;
        for (var i=0; i < n; i++) {
            if (a[i].checked) {
                var piecesArray = a[i].value.split( "|" );
                size += piecesArray[3]*1;
            } else {
                input_checkall.checked = false;
            }
        }
        test = document.getElementById("size_"+str);
        test.innerHTML = gen_size(size, 3, 1);
    } catch (e) {

    }
}

function gen_size(val, li, sepa ) {
    sep = Math.pow(10, sepa); //小数点后的位数
    li = Math.pow(10, li); //开始截断的长度
    retval  = val;
    unit    = 'Bytes';
    if (val >= li*1000000000) {
        val = Math.round( val / (1099511627776/sep) ) / sep;
        unit  = 'TB';
    } else if (val >= li*1000000) {
        val = Math.round( val / (1073741824/sep) ) / sep;
        unit  = 'GB';
    } else if (val >= li*1000) {
        val = Math.round( val / (1048576/sep) ) / sep;
        unit  = 'MB';
    } else if (val >= li) {
        val = Math.round( val / (1024/sep) ) / sep;
        unit  = 'KB';
    }
    return val + unit;
}

function doSearch(o) {
    if (o.q.value.length < 2) {
        alert("请至少输入2个关键词");
        return false;
    }
    o.method = "get";
    //o.action = "http://search.verycd.com/search";
    location.href = "http://search.verycd.com/search?q=" + o.q.value;
    return false;
}

function IsInstallSupMiniQQ(QQVersion) {
	if (navigator.userAgent.indexOf("MSIE") > -1) {
		try { //支持			
			var xmlhttp = new ActiveXObject("TimwpDll.TimwpCheck");
			var  n = xmlhttp.GetVersion();
			if (n < QQVersion) {
				location.href = 'http://is.qq.com/up_alarm.shtml';
				return false;
			}
		    return true;
		} catch(e) { //不支持
			location.href = 'http://is.qq.com/up_alarm.shtml';
			return false;
		}
		return false;
	} else {
		alert('这个……暂时仅支持IE啦\n鄙视腾讯的同时，麻烦您顺手开个IE加一下:$');
	}
}

function RealAddPortal(FpanelID, QQVersion) {
	var boolFals = IsInstallSupMiniQQ(QQVersion);
	if(boolFals == true) {
		if(FpanelID == 17002) {
			var exe = "Tencent://AddPortal/?Menu=Yes&Exe=QQ&PanelID=" + FpanelID;
		} else {
			var exe = "Tencent://AddPortal/?Menu=Yes&PanelID=" + FpanelID;
		}
		location.href = exe;
	}
}

function storePageToKey365() {
    if (document.selection) {
        var sel = document.selection.createRange().text;
    }
    if (!sel) {
        var sel = '';
    }
    var url   = location.href;
    var title = document.title;
    void(window.open('http://www.365Key.com/storeIt.aspx?t='+escape(title)+'&u='+escape(url)+'&c='+escape(sel),'_blank','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'))
}

if (screen.width >= 1024) {
    document.write('<style type="text\/css">@import url(http:\/\/doc.verycd.com\/stylesheet\/global.1024.css);<\/style>');
}


// Google Adsense Config
google_ad_client    = "pub-3705515967346815";
google_ad_type      = "text_image";
google_color_link   = "000000";
google_color_url    = "000000";
google_color_text   = "333333";
if (location.pathname.indexOf("/2004/") != -1
 || location.pathname.indexOf("/2005/") != -1) {
    google_color_border = "FFCC00";
    google_color_bg     = "FFFFFF";
} else {
    google_color_border = "FFFFFF";
    google_color_bg     = "FFFFFF";
}

// Baidu Ads Config
var arrBaiduCproConfig=new Array();
arrBaiduCproConfig['uid'] = 19368;
arrBaiduCproConfig['n']   = 'verycdcpr';
arrBaiduCproConfig['rad'] = 1;
arrBaiduCproConfig['bd']  = '#ffffff';
arrBaiduCproConfig['bg']  = '#ffffff';
arrBaiduCproConfig['tt']  = '#000000';
arrBaiduCproConfig['ct']  = '#333333';
arrBaiduCproConfig['url'] = '#000000';
arrBaiduCproConfig['bdl'] = '#ffffff';
arrBaiduCproConfig['hn']  = 1;
arrBaiduCproConfig['ta']  = 'right';
arrBaiduCproConfig['tl']  = 'bottom';
arrBaiduCproConfig['bu']  = 1;

/**
 * Local Variables:
 * mode: css
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 */


recordCount_all = 19938
recordCount_movie = 4505
recordCount_movie_literature = 552
recordCount_movie_act = 744
recordCount_movie_comedy = 920
recordCount_movie_love = 520
recordCount_movie_fiction = 285
recordCount_movie_war = 181
recordCount_movie_dracula = 427
recordCount_movie_disaster = 26
recordCount_movie_ethic = 144
recordCount_movie_magic = 66
recordCount_movie_cliffhang = 164
recordCount_movie_music = 30
recordCount_movie_sowordsmen = 26
recordCount_movie_criminal = 298
recordCount_movie_newsreel = 122
recordCount_music = 7688
recordCount_music_china = 2318
recordCount_music_mv = 212
recordCount_music_concert = 301
recordCount_music_occident = 2751
recordCount_music_asia = 530
recordCount_music_ost = 666
recordCount_music_classic = 831
recordCount_music_other = 79
recordCount_game = 1315
recordCount_game_iso = 995
recordCount_game_hd = 217
recordCount_game_tv = 64
recordCount_game_other = 39
recordCount_software = 875
recordCount_software_os = 38
recordCount_software_app = 369
recordCount_software_net = 17
recordCount_software_sys = 34
recordCount_software_chat = 2
recordCount_software_media = 109
recordCount_software_img = 102
recordCount_software_ind = 148
recordCount_software_dev = 35
recordCount_software_sec = 21
recordCount_cartoon = 1894
recordCount_cartoon_tv = 862
recordCount_cartoon_ova = 152
recordCount_cartoon_theater = 317
recordCount_cartoon_book = 477
recordCount_cartoon_other = 86
recordCount_teleplay = 1399
recordCount_teleplay_mainland = 232
recordCount_teleplay_hk_tw = 477
recordCount_teleplay_asia = 280
recordCount_teleplay_occident = 410
recordCount_datum = 1940
recordCount_datum_management = 64
recordCount_datum_language = 186
recordCount_datum_computer = 389
recordCount_datum_magazine = 345
recordCount_datum_sports = 83
recordCount_datum_newsreel = 207
recordCount_datum_talking_book = 262
recordCount_datum_other = 404
recordCount_tv = 322
recordCount_tv_integration = 198
recordCount_tv_sports = 65
recordCount_tv_newsreel = 46
recordCount_tv_others = 13
recordCount_bbs_topic = 106335
eMuleCurrentVersion = "0.45b VeryCD Build 0214"
