function headvalidate()
{	
	
	if($("#head_choose").attr("checked") == true)
	{		
		var head_type = $("input[name='mediaHeadType']:checked").val();		
		if(head_type == "1")
		{
			if($("#headMediaName").val() == "")
			{
				return "请选择视频";	
			}
		}
		else if(head_type == "2")
		{
			if($("#headImgPath").val() == "")
			{
				return "请上传图片";	
			}
		}
		return true;			
	}
	else
	{
		return true;	
	}
}

function tailvalidate()
{
	if($("#tail_choose").attr("checked") == false && $("#head_choose").attr("checked") == false)
	{
		return "片头片尾至少选其一";	
	}
	
	if($("#tail_choose").attr("checked") == true)
	{
		var head_type = $("input[name='mediaTailType'][checked='checked']").val();

		if(head_type == "1")
		{
			if($("#tailMediaName").val() == "")
			{
				return "请选择视频";	
			}
		}
		else if(head_type == "2")
		{
			if($("#tailImgPath").val() == "")
			{
				return "请上传图片";	
			}
		}
		return true;			
	}
	else
	{
		return true;	
	}
}


/**
*	cat 分类 1片头  2片尾
*	type 类型 1video 2img
*/
function video_img(cat,type)
{
	if(cat == 1)//head 
	{
		if(type ==1)//show video
		{
			$("#mediaHeadType_v").show();
			$("#mediaHeadType_img").hide();				
		}
		else
		{
			$("#mediaHeadType_v").hide();
			$("#mediaHeadType_img").show();		
		}		
	}
	else if(cat == 2)
	{
		if(type ==1)//show video
		{
			$("#mediaTailType_v").show();
			$("#mediaTailType_img").hide();				
		}
		else
		{
			$("#mediaTailType_v").hide();
			$("#mediaTailType_img").show();		
		}		
	}
		
}


/**
* upload the img
*/
function uploadimg(id)
{
	var init_fname = $("#"+id).val();	
	
	window.top.art.dialog
	(
		{
			id:'uploadimg',iframe:"/admin/mediaInfo/headtail/uploadimg.jsp?fname="+init_fname+"", title:'上传图片', width:'700', height:'450', lock:true,window:'top' 
		},
		function(){
			var d = window.top.art.dialog({id:'uploadimg'}).data.iframe;
			var fname = d.document.getElementById('fname').value;			
			$("#"+id).val(fname);					
			return true;
			}, 
		function()
		{
			window.top.art.dialog({id:'uploadimg'}).close()
		}
	);void(0);	
}

/**
 * 选择视频
 */
function chooseDialog(type)
{	
	window.top.art.dialog
	(
		{
			id:'24fsf5',iframe:"/admin/live/visit/secondlive/mediaChoosePlugin.jsp", title:'选择媒体', width:'980', height:'520', lock:true 
		},
		function()
		{
			var d = window.top.art.dialog({id:'24fsf5'}).data.iframe.plugin_right_frame;
			var form = d.document.getElementById('dosubmit');
			form.click();

			var mediaId = d.document.getElementById('mediaId').value;
			var mediaName = d.document.getElementById('mediaName').value;
			var mediaTime = d.document.getElementById('mediaTime').value	;			
			var resolution = d.document.getElementById('resolution').value;			
			
			if(mediaId !=null && mediaId!="")
			{
				if(type ==1)//head
				{
					$("#headMediaId").val(mediaId);
					$("#headMediaName").val(mediaName);					
				}
				else if(type == 2)//tail
				{
					$("#tailMediaId").val(mediaId);
					$("#tailMediaName").val(mediaName);			
				}

				window.top.art.dialog({id:'24fsf5'}).close()
			}

			return false;
		}, 
		function()
		{
			window.top.art.dialog({id:'24fsf5'}).close()
		}
	);void(0);	
}


function choose(type,obj)
{	
	if(type == 1)
	{
		
		if($(obj).attr("checked") == true)
		{
			
			$("#head").val("true");	
		}
		else
		{
			$("#head").val("false");	
		}
	}
	else if(type == 2)
	{
		if($(obj).attr("checked") == true)
		{
			$("#tail").val("true");	
		}
		else
		{
			$("#tail").val("false");	
		}
	}
}
