window._open=window.open;
window.open=function(sURL,sName,sFeatures,bReplace){
	if(sName==undefined){sName="_blank"};
	if(sFeatures==undefined){sFeatures=""};
	if(bReplace==undefined){bReplace=false};
	var win=window._open(sURL,sName,sFeatures,bReplace);
	if(!win){
		alert('你的浏览器装有截弹出窗口的猎手，请关闭在使用本系统');
		return false;
	}
	return false;
}
function menuGroup(classname,num,i,title){
	$(".main_menu dl dt").removeClass('start_top');
	$(".main_menu dl dt").addClass('start_bottom');
	$(".main_menu dl dd").removeClass('active');
	$(".main_menu dl dd").addClass('other');
	$(".main_menu dl dd").removeClass('active_top_left');
	$(".main_menu dl dd").removeClass('active_end');
	if(i==1){
		$(".main_menu dl dt").removeClass('start_bottom');
		$(".main_menu dl dt").addClass('start_top');
		$("#main_menu_"+i).addClass('active');
	}
	if(i==num){
		$("#main_menu_"+i).addClass('active_end');
		$("#main_menu_"+(i-1)).addClass('active_top_left');
	}
	if(i!=1||i!=num){
		$("#main_menu_"+i).addClass('active');
		$("#main_menu_"+(i-1)).addClass('active_top_left');
	}
	$(".left_menu ul").css("display","none");
	$("."+classname).css("display","block");
	$("."+classname+" ul").css("display","block");
	$(".main_menu_title_left").html(title);
	$(".left").css("width","180px");
	$(".main_menu_title_left").css("display","block");
}
function base_name(pFilePath){
	var temp_win = pFilePath.lastIndexOf("\\");
	var temp_unix = pFilePath.lastIndexOf("/");
	if (temp_win>0)
	{
		temp = temp_win;
	}
	else if (temp_unix>0)
	{
		temp = temp_unix;
	}
	else
	{
		temp = -1;
	}
	file_name = pFilePath.substr(temp+1);
	return(file_name);
}

$(document).ready(function(){
	//创建缩略图预览
	$("body").append("<div style='position:absolute; display:none;' id='preview_thumb'></div>");
	$(".text").click(
	function(){
		$(".text_hover").removeClass('text_hover');
		$(this).addClass('text');
		$(this).addClass('text_hover');
	}
	);
	$(".submit").mousedown(
	function(){
		$(this).removeClass('submit');
		$(this).addClass('submit_click');
	}
	);
	$(".submit").mouseup(
	function(){
		$(this).addClass('submit');
		$(this).removeClass('submit_click');
	}
	);
	$(".button").mousedown(
	function(){
		$(this).removeClass('button');
		$(this).addClass('button_click');
	}
	);
	$(".button").mouseup(
	function(){
		$(this).addClass('button');
		$(this).removeClass('button_click');
	}
	);
	$(".checkbox").click(
	function(){
		isChecked(this.checked);
	}
	);
	$(".acl").click(
	function(){
		select_target(this.id);
	}
	);
	$(".main_menu_title_right").click(
	function (){
		if($(".left").css("width")=="180px"){
			$(".left").css("width","10px");
			$(".main_menu_title_left").css("display","none");
		}
		else{
			$(".left").css("width","180px");
			$(".main_menu_title_left").css("display","block");
		}
	}
	);
	$("#off").mouseover(
	function(){
		$("#off").removeClass("main_menu_title_right");
		$("#off").addClass("main_menu_title_right_hover");
	}
	);
	$("#off").mouseout(
	function(){
		$("#off").addClass("main_menu_title_right");
		$("#off").removeClass("main_menu_title_right_hover");
	}
	);
	$("#toggle").click(
	function(){
		var type	=	$(this).attr('checked');
		if(!type){
			type=false;
		}
		$("input[@name='select[]']").each(function(){
			$(this).attr('checked',type);
		});
		$("input[@name='select_id[]']").each(function(){
			$(this).attr('checked',type);
		});
	});
	$(".adminoption dd").click(
	function(){
		var tabid	=	$(this).children().attr("href");
		if(tabid!=undefined){
			$(".tab").css("display","none");
			$(tabid).css("display","inline");
			$(".adminoption dd").removeClass("active");
			$(this).addClass("active");
			return false;
		}
		else{
			return false;
		}
	}
	);
	$(".tab").css("display","none");
	$("#tab1").css("display","inline");
	$(".preview").mouseover(
			function (e){
				var thumbpath	=	$(this).attr('thumb');
				if(!document.getElementById('preview_div')){
					$('body').append("<div id='preview_div' style='position:absolute'></div>");
				}
				$("#preview_div").html("<img src='"+thumbpath+"'>");
				var divoffset	=	15;
				var Mouse = function(es){
					  mouse = new MouseEvent(es);
					  leftpos = mouse.x + divoffset;
					  toppos = mouse.y + divoffset;
					}
				//获取鼠标坐标函数
				var MouseEvent = function(es) {
					 this.x = es.pageX;
					 this.y = es.pageY;
				}
				Mouse(e);
				var winWidth	=	$(window).width();
				var winHeight	=	$(window).height();
				var divWidth	=	$("#preview_div").width();
				var divheight	=	$("#preview_div").height();
				if(winWidth-divWidth<leftpos){
					leftpos	=	leftpos-divWidth-divoffset;
				}
				if(winHeight-divheight<toppos){
					toppos	=	toppos-divheight-divoffset;
				}
				$("#preview_div").css({left:leftpos,top:toppos,display:'block'});
			}
	);

	$(".preview").mouseout(
			function (e){
				$("#preview_div").css({display:'none'});
			}
	);
});
function main_frame_src(url){
	$("iframe").attr("src",url);
}

var addrowdirect = 1;
function addrow(obj, type) {
	var table = obj.parentNode.parentNode.parentNode.parentNode;
	if(!addrowdirect) {
		var row = table.insertRow(obj.parentNode.parentNode.parentNode.rowIndex);
	} else {
		var row = table.insertRow(obj.parentNode.parentNode.parentNode.rowIndex + 1);
	}
	var typedata = rowtypedata[type];
	for(var i = 0; i <= typedata.length - 1; i++) {
		var cell = row.insertCell(i);
		cell.colSpan = typedata[i][0];
		var tmp = typedata[i][1];
		if(typedata[i][2]) {
			cell.className = typedata[i][2];
		}
		tmp = tmp.replace(/\{(\d+)\}/g, function($1, $2) {return addrow.arguments[parseInt($2) + 1];});
		cell.innerHTML = tmp;
	}
	addrowdirect = 0;
}
function slider_menu(id,thisobj){
	if($("#"+id).css('display')=='none'){
		var type="block";
		$("#"+thisobj).addClass('menu_title');
		$("#"+thisobj).removeClass('menu_title2');
	}
	else{
		var type="none";
		$("#"+thisobj).removeClass('menu_title');
		$("#"+thisobj).addClass('menu_title2');
	}
	$("#"+id).css('display',type);
}
function submitform(action,is_validator){
	$("form").attr("action",action);
	if(is_validator){
		if(!Validator.Validate(document.getElementById("adminform"),4)){
			return false;
		}
	}
	$("form:first").submit();
}

function select_control(action,please_control){
	var n=0;
	$("input:checked").each(function(){
		if($(this).attr('id')!='toggle'&&$(this).attr('type')=='checkbox'){
			n++;
		}
	});
	if(n==0){
		alert('请选择需要操作的项！');
		return false;
	}
	else{
		if(confirm(please_control)){
			submitform(action);
		}
	}
}

function select_search(action){
	submitform(action);
}

function isChecked(isitchecked){
	if (isitchecked == true){
		document.adminform.boxchecked.value++;
	}
	else {
		document.adminform.boxchecked.value--;
	}
}

function select_target(str){
	var objs = document.getElementsByTagName("input");
	var checktype	=	document.getElementById(str).checked;
	var targetId;
	var b="administrator";
	for(var i=0;i<objs.length; i++) {
		targetId=objs[i].id;

		if(targetId.indexOf(str)>=0){
			document.getElementById(targetId).checked	=	checktype;
		}
	}
}
function button_location(url,targ){
	if(!targ){
		targ=true;
	}
	if(targ){
		window.location=url;
	}
	else{
		if(confirm("确认是否执行此操")){
			window.location=url;
		}
	}
}
function Dialog(url,name,w,h)
{
	return showModalDialog(url, name, 'dialogWidth:'+w+'px; dialogHeight:'+h+'px; help: no; scroll: yes; status: yes; resizable:yes');
}
function IeTrueBody(){
    return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}