var max_wnd = xc_getwndnum();
var clipboard_data = "";
function scan_window_and_copy_init() {
	clipboard = new ClipboardJS('#clipboard', {
		text: function () {
			return clipboard_data;
		}
	});

	clipboard.on('success', function (e) {
		alert($.i18n.prop('playlist_copy_text_ok') + "\n" + clipboard_data);
		console.log(e);
	});

	clipboard.on('error', function (e) {
		alert($.i18n.prop('playlist_copy_text_error'));
		console.log(e);
	});
}
function copyurl(url_text) {
	clipboard_data = url_text;
	$("#clipboard").trigger("click");

}
function get_xcfind(){
	$("#xcurl_unget_div").hide();
	$("#xcurl_input_div").hide();
	$("#xcurl_content_div").hide();
	$.ajax({
		type: "GET",
		url: "http://" + xc_gethost() + "/xcfind",
		dataType: "xml",
		cache: false,
		error: function () {
		},
		success: function (data) {
			var result = "<select id='xcfind_sel' name='xcfind_sel' onchange='change_xcdevice()'>";
			var i = 0;
			$(data).find("ds").children("d").each(function () {
				var xcfind_sel = $(this).text();
				result += '<option value="' + i + '">' + xcfind_sel + '</option>';
				i += 1;
			});
			if (i == 0) {
				var playlist_serxcfind = $.i18n.prop('playlist_serxcfind')
				result += '<option value="1000">' + playlist_serxcfind + '</option>';
			}

			result += "</select>";
			$('#xcfind_div').append(result);
			$('#xcdeviceip').attr("value", $("#xcfind_sel option:checked").text());
		}
	});
}
function change_xcdevice(){
	var xcdevice_ip = $("#xcfind_sel option:checked").text();
	$('#xcdeviceip').attr("value", xcdevice_ip);
}
function getxcurl(){
	var device_service = $('#xcdeviceip').val();
	var device_usr = $('#xcdeviceusr').val();
	var device_pwd = $('#xcdevicepwd').val();
	$.ajax({
		type: "GET",
		url: "http://" + xc_gethost() + "/xcstreams?device_ip=" + device_service + "&device_usr=" + device_usr + "&device_pwd=" + device_pwd,
		cache: false,
		success: function (data) {
			var input_sel = "<span id='xcurl_input' class='small_title'></span><select id='xcurl_input_sel' name='xcurl_input_sel' style='margin: 0px 15px 0px 4px;' onchange='change_xcurl_input()'>";
			var i = 0;
			$(data).find("status").children("vi").each(function(){
				n = i + 1;
				input_sel += '<option value="' + i + '">Input '+ n +'</option>';
				i += 1;
			});
			change_xcurl_input();
			
			input_sel += "</select>";
			$("#xcurl_input_div").html(input_sel);
			$('#xcurl_input').html($.i18n.prop('xcurl_input'))
		},
		error: function(){
		}
	});
}
function change_xcurl_input(){
	var device_service = $('#xcdeviceip').val();
	var device_usr = $('#xcdeviceusr').val();
	var device_pwd = $('#xcdevicepwd').val();
	$.ajax({
		type: "GET",
		url: "http://" + xc_gethost() + "/xcstreams?device_ip=" + device_service + "&device_usr=" + device_usr + "&device_pwd=" + device_pwd,
		cache: false,
		success: function (data) {
			var i = $("#xcurl_input_sel option:checked").val();
			var result = "";
			for(var n = 0; n < 8; n++){
					var ts_url = $(data).find("status").children('vi[id=' + i +']').children("venc[id=" + n + "]").children('ts_url0').text();
					var hls_url = $(data).find("status").children('vi[id=' + i +']').children("venc[id=" + n + "]").children('hls_url0').text();
					var flv_url = $(data).find("status").children('vi[id=' + i +']').children("venc[id=" + n + "]").children('flv_url0').text();
					var rtsp_url = $(data).find("status").children('vi[id=' + i +']').children("venc[id=" + n + "]").children('rtsp_url0').text();
					var rtmp_url = $(data).find("status").children('vi[id=' + i +']').children("venc[id=" + n + "]").children('rtmp_url0').text();
					var multi_url = $(data).find("status").children('vi[id=' + i +']').children("venc[id=" + n + "]").children('multicast_url0').text();
					var srt_url = $(data).find("status").children('vi[id=' + i +']').children("venc[id=" + n + "]").children('srt_url0').text();
					var srt_pub_url = $(data).find("status").children('vi[id=' + i +']').children("venc[id=" + n + "]").children('srt_publish_url0').text();
					var hls_pub_url = $(data).find("status").children('vi[id=' + i +']').children("venc[id=" + n + "]").children('srt_publish_url0').text();
					var hls_fmp4_url = $(data).find("status").children('vi[id=' + i +']').children("venc[id=" + n + "]").children('hls_fmp4_url0').text();
					var fmp4_url = $(data).find("status").children('vi[id=' + i +']').children("venc[id=" + n + "]").children('fmp4_url0').text();
					if(ts_url == "" && hls_url == "" && flv_url == "" && rtsp_url == "" && rtmp_url == "" && multi_url == "" && srt_url == "" && srt_pub_url == "" && hls_pub_url == "" && hls_fmp4_url == "" && fmp4_url == ""){
						result += "";
					}
					else result += "<span id='xc_stream" + n +"' class='small_title'></span><br>";

					if(ts_url != ""){
						result += "<span class='small_title'> </span><span id='xc_tsurl_"+ n +"'></span><span>"+ ts_url +"</span><span id=\"copy_ts"+ n +"\" class=\"copycss\" onclick=\"copyurl(\'" + ts_url + "\');\"></span><br>";
					}if(hls_url != ''){
						result += "<span class='small_title'> </span><span id='xc_hlsurl_"+ n +"'></span><span>"+ hls_url +"</span><span id=\"copy_hls"+ n +"\" class=\"copycss\" onclick=\"copyurl(\'" + hls_url + "\');\"></span><br>";
					}if(flv_url != ''){
						result += "<span class='small_title'> </span><span id='xc_flvurl_"+ n +"'></span><span>"+ flv_url +"</span><span id=\"copy_flv"+ n +"\" class=\"copycss\" onclick=\"copyurl(\'" + flv_url + "\');\"></span><br>";
					}if(rtsp_url != ''){
						result += "<span class='small_title'> </span><span id='xc_rtspurl_"+ n +"'></span><span>"+ rtsp_url +"</span><span id=\"copy_rtsp"+ n +"\" class=\"copycss\" onclick=\"copyurl(\'" + rtsp_url + "\');\"></span><br>";
					}if(rtmp_url != ''){
						result += "<span class='small_title'> </span><span id='xc_rtmpurl_"+ n +"'></span><span>"+ rtmp_url +"</span><span id=\"copy_rtmp"+ n +"\" class=\"copycss\" onclick=\"copyurl(\'" + rtmp_url + "\');\"></span><br>";
					}if(multi_url != ''){
						result += "<span class='small_title'> </span><span id='xc_multiurl_"+ n +"'></span><span>"+ multi_url +"</span><span id=\"copy_multi"+ n +"\" class=\"copycss\" onclick=\"copyurl(\'" + multi_url + "\');\"></span><br>";
					}if(srt_url != ''){
						result += "<span class='small_title'> </span><span id='xc_srturl_"+ n +"'></span><span>"+ srt_url +"</span><span id=\"copy_srt"+ n +"\" class=\"copycss\" onclick=\"copyurl(\'" + srt_url + "\');\"></span><br>";
					}if(srt_pub_url != ''){
						result += "<span class='small_title'> </span><span id='xc_srtpuburl_"+ n +"'></span><span>"+ srt_pub_url +"</span><span id=\"copy_srtpub"+ n +"\" class=\"copycss\" onclick=\"copyurl(\'" + srt_pub_url + "\');\"></span><br>";
					}if(hls_pub_url != ''){
						result += "<span class='small_title'> </span><span id='xc_hlspuburl_"+ n +"'></span><span>"+ hls_pub_url +"</span><span id=\"copy_hlspub"+ n +"\" class=\"copycss\" onclick=\"copyurl(\'" + hls_pub_url + "\');\"></span><br>";
					}if(hls_fmp4_url != ''){
						result += "<span class='small_title'> </span><span id='xc_hlsfmp4url_"+ n +"'></span><span>"+ hls_fmp4_url +"</span><span id=\"copy_hlsfmp4"+ n +"\" class=\"copycss\" onclick=\"copyurl(\'" + hls_fmp4_url + "\');\"></span><br>";
					}if(fmp4_url != ''){
						result += "<span class='small_title'> </span><span id='xc_fmp4url_"+ n +"'></span><span>"+ fmp4_url +"</span><span id=\"copy_fmp4"+ n +"\" class=\"copycss\" onclick=\"copyurl(\'" + fmp4_url + "\');\"></span><br>";
					}
			}
			if(result != ''){
				$("#xcurl_unget_div").hide();
				$("#xcurl_input_div").show();
				$("#xcurl_content_div").show();
				$("#xcurl_content_div").html(result);
				$("#xc_stream0").html($.i18n.prop("xc_main_text"));
				for(var n = 1; n < 8; n++){
					$("#xc_stream" + n).html($.i18n.prop("xc_second_text") + n +"：");
				}
				for(var n = 0; n < 8; n++){
					$("#xc_tsurl_" + n).html($.i18n.prop("xc_tsurl_text"));
					$("#xc_hlsurl_" + n).html($.i18n.prop("xc_hlsurl_text"));
					$("#xc_flvurl_" + n).html($.i18n.prop("xc_flvurl_text"));
					$("#xc_rtspurl_" + n).html($.i18n.prop("xc_rtspurl_text"));
					$("#xc_rtmpurl_" + n).html($.i18n.prop("xc_rtmpurl_text"));
					$("#xc_multiurl_" + n).html($.i18n.prop("xc_multiurl_text"));
					$("#xc_srturl_" + n).html($.i18n.prop("xc_srturl_text"));
					$("#xc_srtpuburl_" + n).html($.i18n.prop("xc_srtpuburl_text"));
					$("#xc_hlspuburl_" + n).html($.i18n.prop("xc_hlspuburl_text"));
					$("#xc_hlsfmp4url_" + n).html($.i18n.prop("xc_hlsfmp4url_text"));
					$("#xc_fmp4url_" + n).html($.i18n.prop("xc_fmp4url_text"));

					$('#copy_ts'+ n).html($.i18n.prop('playlist_copy'));
					$('#copy_hls'+ n).html($.i18n.prop('playlist_copy'));
					$('#copy_flv'+ n).html($.i18n.prop('playlist_copy'));
					$('#copy_rtsp'+ n).html($.i18n.prop('playlist_copy'));
					$('#copy_rtmp'+ n).html($.i18n.prop('playlist_copy'));
					$('#copy_multi'+ n).html($.i18n.prop('playlist_copy'));
					$('#copy_srt'+ n).html($.i18n.prop('playlist_copy'));
					$('#copy_srtpub'+ n).html($.i18n.prop('playlist_copy'));
					$('#copy_hlspub'+ n).html($.i18n.prop('playlist_copy'));
					$('#copy_hlsfmp4'+ n).html($.i18n.prop('playlist_copy'));
					$('#copy_fmp4'+ n).html($.i18n.prop('playlist_copy'));

				}
			}else{
				$("#xcurl_input_div").hide();
				$("#xcurl_content_div").hide();
				$("#xcurl_unget_div").show();
			}
		},
		error: function(){
		}
	});
}
function get_playlist() {
	$.ajax({
		type: "GET",
		url: "http://" + xc_gethost() + "/get_playlist",
		dataType: "xml",
		cache: false,
		error: function () {
		},
		success: function (data) {
			var wnd = $(data).find("playlist").attr("wnd");
			$('#wnd').val(wnd);
			showdiv(wnd);
			var usb = $(data).find("playlist").attr("usb");//liulin			
			var uri = "";
			var uri_audio = "";
			var uri_pindex = 0;
			for (var i = 0; i < max_wnd; i++) {
				uri = $(data).find("uri" + i).text();
				$('#uri' + i).attr("value", uri);
				uri_audio = $(data).find("uri" + i).attr('audio');
				if (uri_audio == "true" || uri_audio == "1") {
					document.all.audioselect[i].checked = true;
					$('#uri_audio_' + i).attr("custom_selected", "1");
				}
				var record = $(data).find("uri" + i).attr('record');
				if (record == "true" || record == "1") {
					$('#record' + i).attr("checked", "checked");
				}
				var recordtime = $(data).find("uri" + i).attr('recordtime');
				$('#recordtime' + i).attr("value", recordtime);

				uri_pindex = $(data).find("uri" + i).attr("pindex");
				$('#playlist_pid_select' + i).attr("value", uri_pindex);
				var cache = $(data).find("uri" + i).attr('cache');
				$('#cache' + i).attr("value", cache);
				if (usb == "false")//liulin
				{
					$('#playlist_record' + i).hide();
					$('#record' + i).hide();
					$('#playlist_recordtime' + i).hide();
					$('#recordtime' + i).hide();
					$('#recordtime_value' + i).hide();
				}
				else {
					$('#playlist_record' + i).show();
					$('#record' + i).show();
					$('#playlist_recordtime' + i).show();
					$('#recordtime' + i).show();
					$('#recordtime_value' + i).show();
				}

			}
		}
	});
}
function change_onvifdive() {
	var device_service = $("#onviflist_sel option:checked").text();
	$('#onvifdivce').attr("value", device_service);
}

function change_sapdive() {
	var url = $("#saplist_sel option:checked").val();
	if ("1000" == url) {
		$('#sap_sap_div').hide();
		$('#sap_sap_div_discription').hide();
	}
	else {
		$('#sap_sap_div').show();
		$('#sap_sap_div_discription').show();
		var url_text = "'" + url + "'";
		$('#sap_url_text').html(url + '<span id="playlist_copy_sap" class="copycss" onclick="copyurl(' + url_text + ');"></span>');
		$('#playlist_copy_sap').html($.i18n.prop('playlist_copy'));
	}
}

//liulin
function get_onviflist() {
	$('#rtsp_url_div').hide();
	$('#rtsp_explain_div').hide();
	$.ajax({
		type: "GET",
		url: "http://" + xc_gethost() + "/onvifcfind",
		dataType: "xml",
		cache: false,
		error: function () {
		},
		success: function (data) {
			var result = "<select id='onviflist_sel' name='onviflist_sel' onchange='change_onvifdive()'>";
			var i = 0;
			$(data).find("d").each(function () {
				var onviflist_sel = $(this).text();
				result += '<option value="' + i + '">' + onviflist_sel + '</option>';
				i += 1;
			});
			if (i == 0) {
				var playlist_serchonvif = $.i18n.prop('playlist_serchonvif')
				result += '<option value="1000">' + playlist_serchonvif + '</option>';
			}

			result += "</select>";
			$('#onviflist_div').append(result);
			$('#onvifdivce').attr("value", $("#onviflist_sel option:checked").text());
		}
	});
}
//liulin
function get_ndilist() {
	$.ajax({
		type: "GET",
		url: "http://" + xc_gethost() + "/ndifind",
		dataType: "xml",
		cache: false,
		error: function () {
		},
		success: function (data) {
			var ndi = $(data).find("discover").attr("ndi");
			if( -1 == ndi )
			{
				$('#content_box_ndi').hide();
			}
			else
			{
				$('#content_box_ndi').show();
			}
			var result = "<span id='playlist_ndilist_txt'>";
			var i = 0;
			$(data).find("d").each(function () {
				var ndilist = $(this).text();
				url_text = "'" + ndilist + "'";
				result += '<span>' + ndilist + '<span id="playlist_copy_' + i + '" class="copycss" onclick="copyurl(' + url_text + ');"></span></span><br/>';
				i += 1;
			});
			result += "</span>";
			$('#ndilist_div').append(result);
			for (var j = 0; j < i; j++) {
				$('#playlist_copy_' + j).html($.i18n.prop('playlist_copy'));
			}
		}
	});
}


function get_saplist() {
	$.ajax({
		type: "GET",
		url: "http://" + xc_gethost() + "/sapcfind",
		dataType: "xml",
		cache: false,
		error: function () {
		},
		success: function (data) {
			var result = "<select id='saplist_sel' name='saplist_sel' onchange='change_sapdive()'>";
			var i = 0;
			$(data).find("d").each(function () {
				var name = (this).getAttribute('name');
				var ip = (this).getAttribute('ip');;
				var sap = $(this).text();
				var fox = name + "(" + ip + ")";
				result += '<option value="' + sap + '">' + fox + '</option>';
				i += 1;
			});
			if (i == 0) {
				var playlist_serchsap = $.i18n.prop('playlist_serchsap')
				result += '<option value="1000">' + playlist_serchsap + '</option>';
			}
			result += "</select>";
			$('#saplist_div').append(result);
			change_sapdive();
		}
	});
}

//liulin
function getrtspurl() {
	var device_service = $('#onvifdivce').val();
	var device_usr = $('#username_text').val();
	var device_pwd = $('#password_text').val();
	$.ajax({
		type: "GET",
		url: "http://" + xc_gethost() + "/onvifcrtsp?device_service=" + device_service + "&device_usr=" + device_usr + "&device_pwd=" + device_pwd,
		cache: false,
		success: function (data) {
			$('#rtsp_url_div').show();
			var rtsp_url_text = $(data).find("rtsp").text();
			if (rtsp_url_text != "") {
				$('#rtsp_explain_div').show();
				url_text = "'" + rtsp_url_text + "'";
				$('#rtsp_url_text').html(rtsp_url_text + '<span id="playlist_copy" class="copycss" onclick="copyurl(' + url_text + ');"></span>');
				$('#playlist_copy').html($.i18n.prop('playlist_copy'));
			}
			else {
				$('#rtsp_explain_div').hide();
				$('#rtsp_url_text').html($.i18n.prop('playlist_get_nortsp'));
			}
		},
		error: function () {
			$('#rtsp_url_text').html($.i18n.prop('playlist_get_rtsp'));
		}
	});
}

function showdiv(wndnum) {
	for (var i = 0; i < max_wnd; i++) {
		if (i < wndnum) {
			$('#div' + i).show();
		} else {
			$('#div' + i).hide();
		}
	}

	if (wndnum == 1) {
		$('#full_btn_0').hide();
		$('#full_btn_1000').hide();
	} else {
		$('#full_btn_0').show();
		$('#full_btn_1000').show();
	}
}

function changewnd() {
	var wnd = $('#wnd').val();
	showdiv(wnd);
}

function IsInteger(interger) {
	var IsInteger = true;
	if (parseInt(interger) == interger) {
		IsInteger = true;
	} else {
		IsInteger = false;
	}
	return IsInteger;
}

function check_url_valid(url, cache) {
	var temp_url = $.trim(url);
	if (!(temp_url.substring(0, 3) == "ndi")) {
		if (temp_url.indexOf(" ") != -1) {
			return -1;
		}
	}
	var Intcache = parseInt(cache);
	var IsIntcache = IsInteger(cache);
	if (Intcache < 0 || Intcache > 60000 || IsIntcache == false) {
		return -1;
	}

	return 0;
}

function playlist_setting() {
	var wnd = $('#wnd').val();
	var chc = $("input[name='audioselect']:checked").val();
	var ptmp = "";
	ptmp += ("wnd=" + wnd + "&");
	for (var i = 0; i < max_wnd; i++) {
		var url = $.trim($('#uri' + i).val());
		var cache = $('#cache' + i).val();
		var record = $("#record" + i).attr("checked") == "checked" ? "1" : "0";
		var recordtime = $('#recordtime' + i).val();
		var valid = check_url_valid(url, cache);
		if (valid == -1) {
			alert($.i18n.prop("playlist_format_error_start_info") + i + $.i18n.prop("playlist_format_error_end_info"));
			return;
		}

		var audio = "0";
		if (i == chc) {
			audio = "1";
		}
		var url_playlist_pid = $('#playlist_pid_select' + i).val();
		ptmp += ("uri" + i + "=" + encodeURIComponent(url) + "&uri" + i + "_audio=" + encodeURIComponent(audio) + "&uri" + i + "_record=" + record + "&uri" + i + "_recordtime=" + recordtime + "&uri" + i + "_pindex=" + url_playlist_pid + "&uri" + i + "_cache=" + cache + "&");
	}
	$.ajax({
		type: "GET",
		url: "http://" + xc_gethost() + "/set_playlist" + "?" + ptmp,
		cache: false,
		success: function (data) {
			alert($.i18n.prop('playlist_setting_success'));
		},
		error: function () {
			alert($.i18n.prop('playlist_setting_failed'));
		}
	});
}

function click_full_btn(id) {
	$.ajax({
		type: "GET",
		url: "http://" + xc_gethost() + "/set_full" + "?chn=" + id,
		cache: false,
		success: function (data) {
			//alert($.i18n.prop('playlist_setting_success'));
			/*for (var i = 0; i < max_wnd; i++) {
			 $('#uri_audio_' + i).attr("checked",false);
			 $('#uri_audio_' + i).attr("custom_selected","0");
			 }
			 $('#uri_audio_' + id).attr("checked",true);
			 $('#uri_audio_' + id).attr("custom_selected","1");*/
		},
		error: function () {
			//alert($.i18n.prop('playlist_setting_failed'));
		}
	});
}

function parentpage_adjust_height() {
	changewnd();
	window.parent.setup_iframe_height();
}

function language_setup() {
	var current_language = window.parent.get_language_setup();
	jQuery.i18n.properties({
		name: 'common',
		path: '../lang/',
		mode: 'map',
		language: current_language,
		callback: function () {
			$('#playlist_wndnum').html($.i18n.prop('playlist_wndnum'));
			for (var i = 0; i < max_wnd; i++) {
				if (!(current_language == "zh" || current_language == "zh-CN")) {
					$('#playlist_url' + i).html($.i18n.prop('playlist_url') + (i + 1) + " " + $.i18n.prop('playlist_url_symbol'));
					//$('#url' + i+'_param').html($.i18n.prop('playlist_url')+(i+1)+" "+$.i18n.prop('playlist_url_param'));
				} else {
					$('#playlist_url' + i).html($.i18n.prop('playlist_url') + (i + 1) + $.i18n.prop('playlist_url_symbol'));
					//$('#url' + i+'_param').html($.i18n.prop('playlist_url')+(i+1)+$.i18n.prop('playlist_url_param'));
				}

				$('#playlist_cache' + i).html($.i18n.prop('playlist_cache'));
				$('#playlist_audio' + i).html($.i18n.prop('playlist_audio'));
				$('#playlist_record' + i).html($.i18n.prop('playlist_record'));
				$('#playlist_recordtime' + i).html($.i18n.prop('playlist_recordtime'));
				$('#full_btn_' + i).val($.i18n.prop('playlist_full_btn'));

				$('#playlist_pid' + i).html($.i18n.prop('playlist_pid'));
				for (var pid = 0; pid < 32; pid++) {
					$('#playlist_pid_select' + i).append('<option value="' + pid + '">' + $.i18n.prop('playlist_pid_txt') + ' ' + (pid + 1) + '</option>');
				}
			}
			$('#playlist_setting').val($.i18n.prop('playlist_setting'));
			$('#full_btn_1000').val($.i18n.prop('playlist_nofull_btn'));
			$('#header_text').html($.i18n.prop('index_playlist'));
			$('#header_xcfind').html($.i18n.prop('index_playlist_xcfind'));
			$('#header_onvif').html($.i18n.prop('index_playlist_onvif'));
			$('#header_ndi').html($.i18n.prop('index_playlist_ndi'));

			$('#playlist_config_discription').html($.i18n.prop('playlist_config_discription'));
			$('#playlist_config_discription_rtsp').html($.i18n.prop('playlist_config_discription'));
			$('#playlist_config_discription_ndi').html($.i18n.prop('playlist_config_discription'));
			$('#playlist_config_discription_txt_per_1').html($.i18n.prop('playlist_config_discription_txt_per_1'));
			$('#playlist_config_discription_txt_per_2').html($.i18n.prop('playlist_config_discription_txt_per_2'));
			$('#playlist_config_discription_txt_per_2_2').html($.i18n.prop('playlist_config_discription_txt_per_2_2'));
			$('#playlist_config_discription_txt_per_3').html($.i18n.prop('playlist_config_discription_txt_per_3'));
			$('#playlist_xcfind').html($.i18n.prop('playlist_xcfind'));
			$('#playlist_xcdeviceip').html($.i18n.prop('playlist_xcdeviceip'));
			$('#playlist_xcdeviceusr').html($.i18n.prop('playlist_xcdeviceusr'));
			$('#playlist_xcdevicepwd').html($.i18n.prop('playlist_xcdevicepwd'));
			$('#playlist_get_btu_xcurl').val($.i18n.prop('playlist_get_btu_xcurl'));
			$('#xcurl_unget').html($.i18n.prop('xcurl_unget'));
			$('#xcurl_unget_txt').html($.i18n.prop('xcurl_unget_txt'));

			$('#playlist_onviflist').html($.i18n.prop('playlist_onviflist'));
			$('#playlist_username').html($.i18n.prop('playlist_username'));
			$('#playlist_password').html($.i18n.prop('playlist_password'));
			$('#playlist_get_btu_url').val($.i18n.prop('playlist_get_btu_url'));
			$('#playlist_rtsp_explain').html($.i18n.prop('playlist_rtsp_explain'));
			$('#playlist_ndi_explain').html($.i18n.prop('playlist_ndi_explain'));
			$('#playlist_ndilist').html($.i18n.prop('playlist_ndilist'));
			$('#playlist_onvifdivce').html($.i18n.prop('playlist_onvifdivce'));
			$('#playlist_rtsp_url').html($.i18n.prop('playlist_rtsp_url'));
			$('#header_sap').html($.i18n.prop('index_playlist_sap'));
			$('#playlist_saplist').html($.i18n.prop('playlist_saplist'));
			$('#playlist_config_discription_sap').html($.i18n.prop('playlist_config_discription'));
			$('#playlist_sap_explain').html($.i18n.prop('playlist_sap_explain'));
		}
	});
}

function init_input_ratio_click() {
	$("input[name='audioselect']").click(function () {
		if ($(this).attr("custom_selected") == "1") {
			$(this).attr("checked", false);
			$(this).attr("custom_selected", "0");
		} else {
			$(this).attr("checked", true);
			$("input[name='audioselect']").attr("custom_selected", "0");
			$(this).attr("custom_selected", "1");
		}
	});
}

$(function () {
	language_setup();
	get_playlist();
	get_xcfind();
	get_onviflist();
	get_ndilist();
	get_saplist();
	init_input_ratio_click();
	scan_window_and_copy_init();
});
