﻿//添加ajax消息框
$(document).ready(function(){
	$("#wrap").prepend("<div id=\"ajax-msg\" width=\""+$(window).width()+"px\"></div>")
	$(".indexbulletin tr:odd").css("background","#EFEFEF");
	$(".viewimg").each(function(){
		if($(this).width()>400){$(this).width(400);$(this).click(function(){window.open(this.src)})}
		if($(this).height()>500){$(this).height(500);$(this).click(function(){window.open(this.src)})}
	});
	$(".menuimg").toggle(function(){
		id=$(this).parent().attr("id")
		if(id!=null){
			$("#sub"+id).hide()
		}
	},
	function(){
		id=$(this).parent().attr("id")
		if(id!=null){
			$("#sub"+id).show()
		}
	}
	);
	$(".indexsp .item-content ul li img").each(function(){
		if($(this).width()>160){
			$(this).width(160)
		}
	});
})
$(document).ajaxError(function(request, settings){
  SetAjaxMsg("加载远程文件出错!")
});
$(document).ajaxStart(function(){
  SetAjaxMsg("正在加载，请稍候!")
});
$(document).ajaxComplete(function(){
  SetAjaxMsg("");
});
function SetAjaxMsg(msg){
  $("#ajax-msg").html(msg)
}

function GetFileComplete(FileExt,filepath,inputid){
	$("#"+inputid).val(filepath);
	$(".tickbox").remove();
	FileExt=FileExt.toLowerCase();
	if(/jpg|jpeg|gif|bmp|png/.test(FileExt)){
		$("#attvalue").html('<img src="'+filepath+'" width="150px"/>')
		}
	else{
		$("#attvalue").html('<a href="'+filepath+'" target="_blank">"'+filepath+'"</a>')
		}
	}
	
function submitjointype(){
	var username=$("input[@name='username']").val();
	var userjob=$("input[@name='userjob']").val();
	var userphone=$("input[@name='userphone']").val();
	var userfax=$("input[@name='userfax']").val();
	var usermobile=$("input[@name='usermobile']").val();
	var useremail=$("input[@name='useremail']").val();
	var usercname=$("input[@name='usercname']").val();
	var jointype="";
	var tArr=new Array(false,false,false,false);
	$("input:checkbox[@name='jointype']").each(function(i){
        if($(this).attr("checked")){
        		tArr[i]=true;
            jointype+=$(this).val()+",";
        }
    });
   if (username==null || username==""){
   		alert("请输入您的姓名。");
   		$("input[@name='username']").focus();
   	}
   else if (userjob==null || userjob==""){
   		alert("请输入您的职位。");
   		$("input[@name='userjob']").focus();
   	}
   else if (userphone==null || userphone==""){
   		alert("请输入您的固定联系电话。");
   		$("input[@name='userphone']").focus();
   	}
   else if (userfax==null || userfax==""){
   		alert("请输入您的传真号码。");
   		$("input[@name='userfax']").focus();
   	}
   else if (usermobile==null || usermobile==""){
   		alert("请输入您的手机号码。");
   		$("input[@name='username']").focus();
   	}
   else if (useremail==null || useremail==""){
   		alert("请输入您的Emial地址。");
   		$("input[@name='useremail']").focus();
   	}
   else if (usercname==null || usercname==""){
   		alert("请输入您的公司名称。");
   		$("input[@name='usercname']").focus();
   	}
   else if(jointype=="" || jointype==","){
   		alert("请至少选择一个参会方式。");
   	}
   else if(tArr[0] && tArr[1]){
   		alert("\"嘉宾参会\" 与 \"贵宾参会\" 中只能任选一个。");
   	}
   else{
		$.ajax({
			   type:"post",
			   url:"ajaxServer/jointype.asp",
			   data:"username="+username+"&userjob="+userjob+"&userphone="+userphone+"&userfax="+userfax+"&usermobile="+usermobile+"&useremail="+useremail+"&usercname="+usercname+"&jointype="+jointype+"&r="+Math.random(),
			   dataType:"text",
			   success:function(msg){
					alert(msg);
				   }
			   });
   	}
	}