// JavaScript Document
//弹出层，让父框变暗
//_idToShow : 填充内容div的id
//talk_id ： 讲座数据id号
//cover_id ： 遮盖层div的id
function showTest( _idToShow , talk_id , cover_id ){
	//先清空原内容
	document.getElementById("htmC").innerHTML = ""; //'htmC'是内容显示div的id号
	//处理，层的问题
    var iWidth = document.documentElement.clientWidth;
	var iHeight = document.documentElement.clientHeight;
	//覆盖层
	var coverdiv = document.getElementById(cover_id);
	var isIE = (document.all) ? true : false;
	var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
	//IE6要通过window.attachEvent事件，来改变div大小。
	function _resize(){
		coverdiv.style.position = "absolute";
		coverdiv.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px";
		coverdiv.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px";
	}
	if( isIE6){
		var selectlist = document.getElementsByTagName("select");
		var  len = selectlist.length ;
		for( var k =0 ; k < len ; k ++){
			selectlist[k].style.visibility = "hidden";
		}
		window.attachEvent("onresize",_resize);
	}
	with(coverdiv.style){ 
		backgroundColor = "#000"; background ="#000";display = "block"; zIndex = 10; left = top = 0; position = "fixed"; width = height = "100%"; 
		isIE ? filter = "alpha(opacity:" + 30 + ")" : opacity = 30 / 100;
	}
	//弹出层
	var oShow = document.getElementById(_idToShow);
		oShow.style.display = 'block';
        oShow.style.left = (iWidth-oShow.offsetWidth)/2 - 50 +"px";
		//oShow.style.top = document.documentElement.scrollTop + (iHeight -oShow.offsetHeight)/2+"px";
		//oShow.style.top = "15%";
		oShow.style.top = document.documentElement.scrollTop + 40 + "px";
		
	var oClosebtn = document.createElement("span");
		oClosebtn.innerHTML = "×";
		oShow.appendChild(oClosebtn);
	//关闭方法
	function oClose(){
		oShow.style.display = 'none';
		with(coverdiv.style){display = "none";}
		oShow.removeChild(oClosebtn);
		if(isIE6){
			var selectlist = document.getElementsByTagName("select");
			for( var k =0 , len = selectlist.length ; k < len ; k ++){
				selectlist[k].style.visibility = "visible";
			}
		window.detachEvent("onresize",_resize);
		}
	}
	oClosebtn.onclick = oClose;
	coverdiv.onclick = oClose;
	//ESC键退出
    function getEvent(){
	    return window.event || arguments.callee.caller.arguments[0];
    }
	document.onkeyup = function(){
		var event = getEvent();
		if (event.keyCode == 27){
			oClose();
		}
	}
	//拖动效果
	var drag = new SimpleDrag(_idToShow,{op_handle:"titlebar"});
	
	//请求数据
	show_content1( talk_id , "htmC" ) ;
}

//ajax获得一则讲课详情
function show_content1( _id , _div){
	var t = _id ;
	jQuery.ajax({
		type: "post",
		cache: false,
		data: {campusTalk_id:t},
		url: "findCampusTalkAjaxCampusTalkAction.action",
		dataType:'html',   //接受数据格式   
		success: function(msg){	
			jQuery('#'+_div).html(msg);
		}
	});
}
//日历插件
function addDate( _id ){
	jQuery('#'+_id).datepicker({ 
		changeMonth: true,
		changeYear: true,
		monthNamesShort:['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		dateFormat: 'yy-mm-dd', 
		buttonImageOnly: true, 
		yearRange: '2000:2100',
		clearText:'清除',
		closeText:'关闭',
		prevText:'前一月',
		nextText:'后一月',
		currentText:'今天',
		monthNames:['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
	});
}

//根据指定的值，选中
//_value:  value
//_name: 页面中radio的name属性 or select的id属性
//_flag: r:radio , o:option
function lockSelect(_value , _name , _flag){ 
	if( _flag == 'r'){
		var radios = document.getElementsByName(_name);
		if( radios ){
			for( i = 0 ; i < radios.length; i++ ){
				if( radios[i].value == _value){
					radios[i].setAttribute("checked", "true");
				}
			}
		}
	}else if( _flag == 'o'){
		var select_x = my$(_name);
		if( select_x ){
			select_x = select_x.options ;
			for( i = 0 ; i < select_x.length; i++ ){
				if( select_x[i].value == _value){
					select_x[i].setAttribute("selected", "true");
				}
			}
		}
	}
}


