window.onload = function(){
	//교통속보 Ajax 시작--------
	$("#incident").click(function(){
		$("#incidentView").hide();
		$("#incidentView2").show();
		var A = $("#initialChar").val();
		var B = $("#updown").val();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=incident&initialChar="+A+"&updown="+B+"&mode=incidentView",
			success : incident
		});
	});
	function incident(msg){
		$("#incidentView2").html(msg);
	}
	
	$("#incident2").click(function(){
		$("#incidentView").hide();
		$("#incidentView2").show();
		var A = $("#initialChar").val();
		var B = $("#updown2").val();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=incident&initialChar="+A+"&updown="+B+"&mode=incidentView",
			success : incident
		});
	});
	
	
	$("#initialChar").change(function(){
		$("#incidentArea1").hide();
		$("#incidentArea2").show();
		$("#incidentArea3").hide();
		$("#incidentArea4").show();
		var A = $("#initialChar").val();
		var B = $("#updown").val();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=incident&initialChar="+A+"&updown="+B+"&mode=incidentArea",
			success : incidentArea
		});
	});
	function incidentArea(msg){
		$("#incidentArea2").html(msg);
	}
	
	
	//교통 속보 Ajax 끝 ---------- 
	
	//정체 정보 Ajax 시작 ---------
	$("#congesList").change(function(){
		$("#congesArea1").hide();
		$("#congesArea2").show();
		$("#congesArea3").hide();
		$("#congesArea4").show();
		var A = $("#congesList").val();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=congesInfo&mode=congesArea&roadNo="+A+"",
			success : congesInfo
		});
	});
	$("#conges").click(function(){
		$("#congesInfo1").hide();
		$("#congesInfo2").show();
		var A = $("#congesList").val();
		var B = $("#congesId").val();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=congesInfo&mode=congesView&roadNo="+A+"&congesId="+B+"",
			success : congesInfo2
		});
	});

	$("#conges2").click(function(){
		$("#congesInfo1").hide();
		$("#congesInfo2").show();
		var A = $("#congesList").val();
		var B = $("#congesId2").val();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=congesInfo&mode=congesView&roadNo="+A+"&congesId="+B+"",
			success : congesInfo2
		});
	});

	function congesInfo(msg){
		$("#congesArea2").html(msg);
	}
	function congesInfo2(msg){
		$("#congesInfo2").html(msg);
	}
	//정체 정보 Ajax 끝 -------------
	
	//원클릭 교통정보
	$("#oneClickBtn").click(function(){
		var A = $("#start").val();
		var B = $("#end").val();
		var C = $("#currentTimeMillis").val();
		var url = "/oneClick.do?start="+A+"&end="+B+"&currentTimeMillis="+C;
		var target = "_blank, width=900, height=700";
		window.open(url,'oneClick',target);
	});
	
	//on-air버튼 변경
	$("#onAir").click(function(){
		$("#suhwa").show();
		$("#onAir2").show();
		$("#onAir").hide();
		$("#mediaPlayer1").hide();
		$("#movieController").hide();
		$("#mediaPlayer2").show();
		
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=onAir&type=1",
			success : mediaPlayer2
		});
		
	});
	$("#moviePlay").click(function(){
		$("#onAir2").show();
		$("#suhwa").show();
		$("#onAir").hide();
		$("#mediaPlayer1").hide();
		$("#mediaPlayer2").show();
		
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=onAir&type=1",
			success : mediaPlayer2
		});
		
	});
	$("#playBtn").click(function(){
		$("#onAir2").show();
		$("#suhwa").show();
		$("#onAir").hide();
		$("#mediaPlayer1").hide();
		$("#mediaPlayer2").show();
		
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=onAir&type=1",
			success : mediaPlayer2
		});
		
	});
	$("#onAir2").click(function(){
		$("#onAir2").hide();
		$("#suhwa").hide();
		$("#tts").hide();
		$("#onAir").show();
		$("#mediaPlayer2").show();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=onAir&type=6",
			success : mediaPlayer2
		});
	});
	
	
	//수화방송 TTS방송 버튼 변경
	$("#suhwa").click(function(){
		$("#suhwa").hide();
		$("#tts").show();
		$("#mediaPlayer1").hide();
		$("#mediaPlayer2").show();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=onAir&type=2",
			success : mediaPlayer2
		});
	});
	
	$("#tts").click(function(){
		$("#tts").hide();
		$("#suhwa").show();
		$("#mediaPlayer1").hide();
		$("#mediaPlayer2").show();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=onAir&type=3",
			success : mediaPlayer2
		});
	});
	
	
	
	//생방송 리스트
	$("#listOnair1").click(function(){
		$("#mediaPlayer1").hide();
		$("#mediaPlayer2").show();
		var scheId = $("#listOnair1Tmp").val();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=onAir&type=5&scheId="+scheId,
			success : mediaPlayer2
		});
	});
	$("#listOnair2").click(function(){
		$("#mediaPlayer1").hide();
		$("#mediaPlayer2").show();
		var scheId = $("#listOnair2Tmp").val();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=onAir&type=5&scheId="+scheId+"",
			success : mediaPlayer2
		});
	});
	$("#listOnair3").click(function(){
		$("#mediaPlayer1").hide();
		$("#mediaPlayer2").show();
		var scheId = $("#listOnair3Tmp").val();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=onAir&type=5&scheId="+scheId+"",
			success : mediaPlayer2
		});
	});
	$("#listOnair4").click(function(){
		$("#mediaPlayer1").hide();
		$("#mediaPlayer2").show();
		var scheId = $("#listOnair4Tmp").val();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=onAir&type=5&scheId="+scheId+"",
			success : mediaPlayer2
		});
	});
	$("#listOnair5").click(function(){
		$("#mediaPlayer1").hide();
		$("#mediaPlayer2").show();
		var scheId = $("#listOnair5Tmp").val();
		$.ajax({
			type : "POST",
			url : "/main.do",
			data : "op=onAir&type=5&scheId="+scheId+"",
			success : mediaPlayer2
		});
	});
	function mediaPlayer2(msg){
		$("#mediaPlayer2").html(msg);
	}
	$("#listOnair1").hover(function () {
	    $(this).css({'cursor': 'pointer'});
	});
	$("#listOnair2").hover(function () {
	    $(this).css({'cursor': 'pointer'});
	});
	$("#listOnair3").hover(function () {
	    $(this).css({'cursor': 'pointer'});
	});
	$("#listOnair4").hover(function () {
	    $(this).css({'cursor': 'pointer'});
	});
	$("#listOnair5").hover(function () {
	    $(this).css({'cursor': 'pointer'});
	});
	

	//openPollPopup();
};
