function link(basePath, code, navid, listid, id, page, openType){
	if(code == "homepage"){
		if(openType == "blank"){
			window.open(basePath + "net/website/homepage.action?navid=" + navid + "&listid=" + listid, "", "");
		}else{
			parent.window.location = basePath + "net/website/homepage.action?navid=" + navid + "&listid=" + listid;
		}
	}else if(code == "message"){
		if(openType == "blank"){
			window.open(basePath + "net/website/message.action?navid=" + navid + "&listid=" + listid + "&page=" + page, "", "");
		}else{
			parent.window.location = basePath + "net/website/message.action?navid=" + navid + "&listid=" + listid + "&page=" + page;
		}
	}else{
		if(openType == "blank"){
			window.open(basePath + "net/website/content.action?code=" + code + "&navid=" + navid + "&listid=" + listid + "&id=" + id + "&page=" + page,"","");
		}else{
			parent.window.location = basePath + "net/website/content.action?code=" + code + "&navid=" + navid + "&listid=" + listid + "&id=" + id + "&page=" + page;
		}
	}
}

function findProjectTop(basePath){
	var industry = $(".projectTop");
	if(industry.length > 0){
		for(var i = 0;i < industry.length;i++){
			industryId = industry[i].id.replace("projectTop_","");
			$.ajax({
				type:"post",
				url:"net/website/projectTop.action",
				data:"industryId=" + industryId,
				async:false,
				success:function(msg){
					var projectTop = eval(msg);
					if(projectTop != "" && projectTop.length > 0){
						for(var p = 0;p < projectTop.length;p++){
							$("#projectTop_" + industryId).append("<dd class=\"text-overflow blue\"><a href=\"javascript:link('" + basePath + "','projectList','6','" + projectTop[p].industry + "','" + projectTop[p].id + "','','');\" title=\"" + projectTop[p].name + "\">" + projectTop[p].name + "</a></dd>");
						}
					}
				}
			});
		}
	}
}

function findChildProject(){
	var parents = $(".childProject");
	if(parents.length > 0){
		for(var p = 0;p < parents.length;p++){
			var parentId = parents[p].id;
			$.ajax({
				type:"post",
				url:"net/website/childProject.action",
				data:"parentId=" + parentId.replace("childProject_",""),
				async:false,
				success:function(msg){
					var children = eval(msg);
					if(children != "" && children.length > 0){
						var html = "";
						for(var c = 0;c < children.length;c++){
							html = html + "<div class=\"clearer\">&nbsp;</div>";
							html = html + "<h3 class=\"text-overflow\"><span class=\"orage\">建设单位：</span><a>" + children[c].name + "</a></h3>";
							html = html + "<span class=\"orage\">工程内容：</span>" + children[c].introduce + "<br/><br/>";
						}
						$("#" + parentId).append(html);
					}else{
						$("#child_" + parentId.replace("childProject_","")).empty();
					}
				}
			});
		}
	}
}

function openChild(id){
	document.getElementById("childProject_" + id).style.display = "";
	document.getElementById("child_" + id).innerHTML = "<a href=\"javascript:closeChild(" + id + ");\">收起<<</a>";
}

function closeChild(id){
	document.getElementById("childProject_" + id).style.display = "none";
	document.getElementById("child_" + id).innerHTML = "<a href=\"javascript:openChild(" + id + ");\">展开>></a>";
}

function change(divWidth, divHeight){
	var image = $(".imageList");
	if(image.length > 0){
		for(var i = 0;i < image.length;i++){
			var width = image[i].width;
			var height = image[i].height;
			if(width > divWidth){
				var e = parseFloat(divWidth / width);
				width = divWidth;
				height = parseInt(height * e,10);
			}
			if(height > divHeight){
				var e = parseFloat(divHeight / height);
				height = divHeight;
				width = parseInt(width * e,10);
			}
			image[i].width = width;
			image[i].height = height;
		}
	}
}

function changeAll(divWidth, divHeight){
	var image = $("img");
	if(image.length > 0){
		for(var i = 0;i < image.length;i++){
			var width = image[i].width;
			var height = image[i].height;
			if(divWidth != 0 && width > divWidth){
				var e = parseFloat(divWidth / width);
				width = divWidth;
				height = parseInt(height * e,10);
			}
			if(divHeight != 0 && height > divHeight){
				var e = parseFloat(divHeight / height);
				height = divHeight;
				width = parseInt(width * e,10);
			}
			image[i].style.width = width;
			image[i].style.height = height;
		}
	}
}

function findCustom(){
	var industry = $(".customList");
	if(industry.length > 0){
		for(var i = 0;i < industry.length;i++){
			var id = industry[i].id;
			id = id.replace("customList_","");
			$.ajax({
				type:"post",
				url:"net/website/ajaxListCustom.action",
				data:"industry=" + id,
				async:false,
				success:function(msg){
					var custom = eval(msg);
					if(custom.length > 0){
						var html = "<span  class=\"large\">";
						for(var c = 0;c < custom.length;c++){
							if(c % 2 == 0){
								html = html + "<div>";
							}
							html = html + "<span class=\"large w270\">" + custom[c].name + "</span>";
							if(c % 2 == 1){
								html = html + "</div>";
							}
						}
						if(custom.length % 2 == 1){
							html = html + "</div>";
						}
						html = html + "</span>";
						$("#customList_" + id).append(html);
					}
				}
			});
		}
	}
}

function findMessage(page){
	$.ajax({
		type:"post",
		url:"net/website/ajaxListMessage.action",
		data:"page=" + page,
		async:false,
		success:function(msg){
			var message = eval(msg);
			if(message.length > 0){
				var html = "";
				for(var m = 0;m < message.length;m++){
					html = html + "<div class=\"comment\">";
					html = html + "<div class=\"comment-gravatar left\"><img alt=\"\" src=\"net/images/sample-gravatar.jpg\" height=\"32\" width=\"32\" /></div>";
					html = html + "<div class=\"comment-author left\">";
					html = html + message[m].name;
					html = html + "<div class=\"comment-date\"><a>" + message[m].editDate + "</a></div>";
					html = html + "</div>";
					html = html + "<div class=\"clearer\">&nbsp;</div>";
					html = html + "<div class=\"comment-body\">";
					html = html + "<p>" + message[m].content + "</p>";
					html = html + "</div>";
					html = html + "</div>";
				}
				$("#messageList").empty();
				$("#messageList").append(html);
			}
		}
	});
	pageMessage(page);
}

function pageMessage(page){
	$.ajax({
		type:"post",
		url:"net/website/ajaxCountMessage.action",
		async:false,
		success:function(msg){
			var message = eval("(" + msg + ")");
			var maxPage = message.maxPage;
			if(maxPage > 1){
				var html = "<div class=\"post-meta archive-pagination\">";
				html = html + "<div class=\"left prepage\"><a href=\"javascript:findMessage(1);\">&#171; 首页</a></div>";
				html = html + "<div class=\"left pagenum text-overflow\">";
				if(page > 10){
					for(var m = page - 1;m < maxPage;m++){
						if(m + 1 == page){
							html = html + "<a><font color=\"red\" size=\"4\">" + (m + 1) + "</font></a>";
						}else{
							html = html + "<a href=\"javascript:findMessage(" + (m + 1) + ");\"><font>" + (m + 1) + "</font></a>";
						}
					}
				}else{
					for(var m = 0;m < maxPage;m++){
						if(m + 1 == page){
							html = html + "<a><font color=\"red\">" + (m + 1) + "</font></a>";
						}else{
							html = html + "<a href=\"javascript:findMessage(" + (m + 1) + ");\"><font>" + (m + 1) + "</font></a>";
						}
					}
				}
				html = html + "</div>";
				html = html + "<div class=\"right nextpage\"><a href=\"javascript:findMessage(" + maxPage + ");\">末页 &#187;</a></div>";
				html = html + "<div class=\"clearer\">&nbsp;</div>";
				html = html + "</div>";
				$("#messagePage").empty();
				$("#messagePage").append(html);
			}
		}
	});
}

function addFavorite(sURL, sTitle) {
    try {
        window.external.addFavorite(sURL, sTitle);
    } catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        } catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}

function contextPrint(){
	bdhtml=window.document.getElementById("content_main").innerHTML;//获取当前页的html代码
	sprnstr="<!--startprint-->";//设置打印开始区域
	eprnstr="<!--endprint-->";//设置打印结束区域
	prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+17); //从开始代码向后取html
	prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
	window.document.getElementById("content_main").innerHTML=prnhtml;
	window.print();
	window.document.getElementById("content_main").innerHTML=bdhtml;
}

document.oncontextmenu = new Function("return false;");
document.onselectstart = new Function("return false;");

