/*Global Var*/
var Language = $("#LanSle").val();

/*start version function*/
function GetVersion(hostip)
{	 
	$.ajax({ 
   type:"GET",
   url:"http://"+hostip+"/get_version",
   dataType:"xml",
   cache:false,
   success:function(data){	   
	var version=$(data).find("version").text();
	version=parseFloat(version)+3.5;
	version=toDecimal2(version);
	$("#version").append(version);		
	}
	});
}
 
function toDecimal2(x) 
{
	var f = parseFloat(x);    
	if (isNaN(f)) {    
		return false;    
	}    
	var f = Math.round(x*100)/100;    
	var s = f.toString();    
	var rs = s.indexOf('.');    
	if (rs < 0) {    
		rs = s.length;    
		s += '.';    
	}    
	while (s.length <= rs + 2) {    
		s += '0';    
	}  
	return s;    
}
/*end version function*/

/*start osd function*/
function GetInputOsd(input, output) {
	Getalpha(input, output);
	for (var i = 0; i < 4; i++) {
		GetOSD(input, output, i);
	}
}

function Getalpha(input, output, osd_chn) {
	$.ajax({
		type: "GET",
		url: "http://" + hostip + "/get_osd?input=" + input + "&enc_chn=" + output + "&osd_chn=0",
		dataType: "xml",
		cache: false,
		success: function (data) {
			var alpha = $(data).find("alpha").text();
			$("#alpha").attr("value", alpha);
		}
	});
}
function GetOSD(input, output, num) {
	$.ajax({
		type: "GET",
		url: "http://" + hostip + "/get_osd?input=" + input + "&enc_chn=" + output + "&osd_chn=" + num,
		dataType: "xml",
		cache: false,
		success: function (data) {
			var select_enable = $(data).find("enable").text();
			$('#select_enable' + num).attr("value", select_enable);
			var select_TP = $(data).find("type").text();
			$('#select_TP' + num).attr("value", select_TP);
			var x = $(data).find("x").text();
			$('#x' + num).attr("value", x);
			var y = $(data).find("y").text();
			$("#y" + num).attr("value", y);

			if (y > 1080) y = 1080;
			if (x > 30) x = 30;
			$("#scallX" + num).attr("value", x);
			$("#scallY" + num).attr("value", y);

			var txt = $(data).find("txt").text();
			$("#txt" + num).attr("value", txt);
			var font_size = $(data).find("font_size").text();
			$("#font_size" + num).attr("value", font_size);
			var color = parseInt($(data).find("color").text());
			$("#color" + num).attr("value", color);
			var tem = color.toString(16);
			var intleng = 6 - tem.length;
			for (k = 0; k < intleng; k++) {
				tem = "0" + tem;
			}
			color = "#" + tem;
			$("#DisColor" + num).css("background-color", color);
			var bcolor = $(data).find("bcolor").text();
			$("#bcolor" + num).attr("value", bcolor);
			var logosel = $(data).find("bmp").text();
			$("#logosel" + num).attr("value", logosel);
			OsdShow(select_enable, num);
			typeshow(select_TP, num)
		}
	});
}

function OsdShow(select_enable, num) {
	if (select_enable == 0) {
		$("#osd" + num).hide();

	}
	else {
		$("#osd" + num).show();
	}
}
function typeshow(select_TP, num) {
	select_TP = parseInt(select_TP);
	if (select_TP == 0) {
		$("#txtX" + num).show();
		$("#txtY" + num).show();
		$("#txtOsd" + num).show();
		$("#fontsizeOsd" + num).show();
		$("#colorOsd" + num).show();
		$("#colorpanelOsd" + num).show();
		$("#bcolorOsd" + num).show();
		$("#logoOsd" + num).hide();
		$("#SX" + num).hide();
		$("#SY" + num).hide();
	}
	else if (select_TP == 1) {
		$("#txtX" + num).show();
		$("#txtY" + num).show();
		$("#txtOsd" + num).hide();
		$("#fontsizeOsd" + num).hide();
		$("#colorOsd" + num).hide();
		$("#colorpanelOsd" + num).hide();
		$("#bcolorOsd" + num).hide();
		$("#logoOsd" + num).show();
		$("#SX" + num).hide();
		$("#SY" + num).hide();
	}
	else if (select_TP == 10) {
		$("#txtX" + num).hide();
		$("#txtY" + num).hide();
		$("#txtOsd" + num).show();
		$("#fontsizeOsd" + num).show();
		$("#colorOsd" + num).show();
		$("#colorpanelOsd" + num).show();
		$("#bcolorOsd" + num).show();
		$("#logoOsd" + num).hide();
		$("#SX" + num).show();
		$("#SY" + num).show();
	}
	else if(select_TP==11)
	{
		$("#txtX"+num).show();
		$("#txtY"+num).show();
		$("#txtOsd"+num).hide();
		$("#fontsizeOsd"+num).show();			
		$("#colorOsd"+num).show();
		$("#colorpanelOsd"+num).show();
		$("#bcolorOsd"+num).show();
		$("#logoOsd"+num).hide();
		$("#SX"+num).hide();
		$("#SY"+num).hide();
	}
}

function changeOsdShow(num) {
	var select_enable = $('#select_enable' + num).val();
	OsdShow(select_enable, num);
}
function changetypeshow(num) {
	var select_TP = $('#select_TP' + num).val();
	typeshow(select_TP, num);
}
function SetOsdInput(input, output) {
	var alpha = $("#alpha").val();
	var validated = IsvalidatAlpha(Language, alpha);
	for (var i = 0; i < 4; i++) {
		var select_enable = $("#select_enable" + i).val();
		var select_TP = $("#select_TP" + i).val();
		var txt = $("#txt" + i).val();
		txt = encodeURIComponent(txt);
		var font_size = $("#font_size" + i).val();
		var logosel = $("#logosel" + i).val();
		var x = $("#x" + i).val();
		var y = $("#y" + i).val();
		if (select_TP == 10) {
			x = $("#scallX0").val();
			y = $("#scallY0").val();
		}
		validated += IsValidateOSD(Language, select_enable, select_TP, font_size, x, y, txt, i, logosel);
	}
	if (validated == 0) {
		var result = 0;
		for (var i = 0; i < 4; i++) {
			var select_enable = $("#select_enable" + i).val();
			var select_TP = $("#select_TP" + i).val();
			var txt = $("#txt" + i).val();
			txt = encodeURIComponent(txt);
			var font_size = $("#font_size" + i).val();
			var color = $("#color" + i).val();
			var bcolor = $("#bcolor" + i).val();
			var logosel = $("#logosel" + i).val();
			var x = $("#x" + i).val();
			var y = $("#y" + i).val();
			if (select_TP == 10) {
				x = $("#scallX0").val();
				y = $("#scallY0").val();
			}
			result += setosd(input, output, i, alpha, select_enable, select_TP, font_size, x, y, txt, color, logosel, bcolor);
		}
		if(Language == "Chinese") {
			if (result == 0) {
				alert('设置成功,请重启设备！');
			}
			else {
				alert('设置失败！');
			}
		}else{
			if (result == 0) {
				alert('Set successfully, please restart your device!');
			}
			else {
				alert('Failed to set!');
			}
		}
	}
}
function setosd(input, output, num, alpha, select_enable, select_TP, font_size, x, y, txt, color, logosel, bcolor) {
	var result = 0;
	$.ajax({
		url: "http://" + hostip + "/set_osd?input=" + input + "&enc_chn=" + output + "&osd_chn=" + num + "&alpha=" + alpha + "&txt=" + txt + "&font_size=" + font_size + "&x=" + x + "&y=" + y + "&enable=" + select_enable + "&type=" + select_TP + "&bmp=" + logosel + "&color=" + color + "&bcolor=" + bcolor,
		dataType: "text",
		cache: false,
		success: function (data) {
			if (data == "succeed") {
				result = 0;
			}
			else {
				result = 1;
			}
		}
	});
	return result;
}
function GetName(language, num) {
	var result = "";
	if(language == "Chinese"){
		if (num == 0) {
			result = "区域一";
		}
		else if (num == 1) {
			result = "区域二";
		}
		else if (num == 2) {
			result = "区域三";
		}
		else if (num == 3) {
			result = "区域四";
		}
	}
	else {
		if (num == 0) {
			result = "Zone 1";
		}
		else if (num == 1) {
			result = "Zone 2";
		}
		else if (num == 2) {
			result = "Zone 3";
		}
		else if (num == 3) {
			result = "Zone 4";
		}
	}
	return result;
}
function IsvalidatAlpha(language, alpha) {
	var validated = 0;
	var Intalpha = IsInteger(alpha);
	if(language == "Chinese") {
		if (alpha < 0 || alpha > 128 || Intalpha == false) {
			alert('透明度应是0-128间的整数！');
			validated = 1;
		}
	}
	else {
		if (alpha < 0 || alpha > 128 || Intalpha == false) {
			alert('Alpha should be an integer between 0-128!');
			validated = 1;
		}
	}
	return validated;
}

function IsValidateOSD(language, select_enable, select_TP, font_size, x, y, txt, num, logosel) {
	var room = GetName(language, num);
	validated = 0;
	var Intfont_size = IsInteger(font_size);
	var Intx = IsInteger(x);
	var Inty = IsInteger(y);
	if (select_enable == 1) {
		var max_x = $("#osd" + num + "_x").html();
		var max_y = $("#osd" + num + "_y").html();
		var IntMax_x = parseInt(max_x);
		var IntMax_y = parseInt(max_y);
		var max_position = $("#osd" + num + "_y_scroll").html();
		var IntMax_position = parseInt(max_position);
		if(language == "Chinese") {
			if (select_TP == 0) {
				if (x < 0 || x > IntMax_x || Intx == false) {
					alert(room + '文本X的值应是0-' + IntMax_x + '间的整数！');
					validated = 1;
				}
				else if (y < 0 || y > IntMax_y || Inty == false) {
					alert(room + '文本Y的值应是0-' + IntMax_y + '间的整数！');
					validated = 1;
				}
				else if (txt == "") {
					alert(room + '文本不能为空！');
					validated = 1;
				}
				else if (font_size < 8 || font_size > 72 || Intfont_size == false) {
					alert(room + '文本字体大小应是8-72间的整数！');
					validated = 1;
				}
			}
			else if (select_TP == 1) {
				if (x < 0 || x > IntMax_x || Intx == false) {
					alert(room + '图片X的值应是0-' + IntMax_x + '间的整数！');
					validated = 1;
				}
				else if (y < 0 || y > IntMax_y || Inty == false) {
					alert(room + '图片Y的值应是0-' + IntMax_y + '间的整数！');
					validated = 1;
				}
				else if (logosel == "" || logosel == null) {
					alert('请为' + room + '选择LOGO！');
					validated = 1;
				}
			}
			else if (select_TP == 10){
				if (x < 0 || x > 30 || Intx == false) {
					alert(room + '速度的值应是0-30间的整数！');
					validated = 1;
				}
				else if (y < 0 || y > IntMax_position || Inty == false) {
					alert(room + '位置的值应是0-' + IntMax_position + '间的整数！');
					validated = 1;
				}
				else if (txt == "") {
					alert(room + '文本不能为空！');
					validated = 1;
				}
				else if (font_size < 8 || font_size > 72 || Intfont_size == false) {
					alert(room + '文本字体大小应是8-72间的整数！');
					validated = 1;
				}
			}
			else if(select_TP == 11) {
				if (x < 0 || x > IntMax_x || Intx == false) {
					alert(room + '文本X的值应是0-' + IntMax_x + '间的整数！');
					validated = 1;
				}
				else if (y < 0 || y > IntMax_y || Inty == false) {
					alert(room + '文本Y的值应是0-' + IntMax_y + '间的整数！');
					validated = 1;
				}
				else if (font_size < 8 || font_size > 72 || Intfont_size == false) {
					alert(room + '文本字体大小应是8-72间的整数！');
					validated = 1;
				}
			}
		}
		else {
			if (select_TP == 0) {
				if (x < 0 || x > IntMax_x || Intx == false) {
					alert('X should be an integer between 0-' + IntMax_x + ' for ' + room + '!');
					validated = 1;
				}
				else if (y < 0 || y > IntMax_y || Inty == false) {
					alert('Y should be an integer between 0-' + IntMax_y + ' for ' + room + '!');
					validated = 1;
				}
				else if (txt == "") {
					alert('Txt cannot be empty for ' + room + '!');
					validated = 1;
				}
				else if (font_size < 8 || font_size > 72 || Intfont_size == false) {
					alert('Font size should be an integer between 8-72 for ' + room + '!');
					validated = 1;
				}
			}
			else if (select_TP == 1) {
				if (x < 0 || x > IntMax_x || Intx == false) {
					alert('X should be an integer between 0-' + IntMax_x + ' for ' + room + '!');
					validated = 1;
				}
				else if (y < 0 || y > IntMax_y || Inty == false) {
					alert('Y should be an integer between 0-' + IntMax_y + ' for ' + room + '!');
					validated = 1;
				}
				else if (logosel == "" || logosel == null) {
					alert('Select LOGO for ' + room + '!');
					validated = 1;
				}
			}
			else if(select_TP == 10){
				if (x < 0 || x > 30 || Intx == false) {
					alert('Speed should be an integer between 0-30 for ' + room + '!');
					validated = 1;
				}
				else if (y < 0 || y > IntMax_position || Inty == false) {
					alert('Position should be an integer between 0-' + IntMax_position + ' for ' + room + '!');
					validated = 1;
				}
				else if (txt == "") {
					alert('Txt cannot be empty for ' + room + '!');
					validated = 1;
				}
				else if (font_size < 8 || font_size > 72 || Intfont_size == false) {
					alert('Font size should be an integer between 8-72 for ' + room + '!');
					validated = 1;
				}
			}
			else if(select_TP == 11)
			{
				 if(x<0 || x>IntMax_x || Intx==false)
				{
				  alert('X should be an integer between 0-' + IntMax_x + ' for ' + room + '!');
				  validated=1;
				}	  
				 else if(y<0 || y>IntMax_y || Inty==false)
				{
				   alert('Y should be an integer between 0-' + IntMax_y + ' for ' + room + '!');
				  validated=1;
				}
				 else if(font_size<8 || font_size>72 || Intfont_size==false)
				{
				   alert('Font size should be an integer between 8-72 for '+room+'!');
				   validated=1;
				}  
			}
		}
	}
	return validated;
}

function checkcolor(str) {
	var ss = /^(#[0-9a-fA-F]{6})$/;
	return ss.test(str);
}

var ColorHex = new Array('00', '33', '66', '99', 'CC', 'FF');
var SpColorHex = new Array('FF0000', '00FF00', '0000FF', 'FFFF00', '00FFFF', 'FF00FF');
var current = null;
function intocolor(num) {
	var colorTable = ''
	for (i = 0; i < 2; i++)   //循环2部分
	{
		for (j = 0; j < 6; j++)  //循环6行
		{
			colorTable = colorTable + '<tr>'
			for (k = 0; k < 3; k++) {
				for (l = 0; l < 6; l++) {
					colorTable = colorTable + '<td  onclick="doclick(this,' + num + ')" style="background-color:#' + ColorHex[k + i * 3] + ColorHex[l] + ColorHex[j] + '">'
				}
			}
		}
	}
	colorTable = '<table border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse; bordercolor="000000" >'
		+ colorTable + '</table><a onclick="colorpanelhide(' + num + ')">关闭</a>';
	document.getElementById("colorpanel" + num).innerHTML = colorTable;
}


function rgbToHex(aa) {
	if (aa.indexOf("rgb") != -1) {
		aa = aa.replace("rgb(", "")

		aa = aa.replace(")", "")

		aa = aa.split(",")

		r = parseInt(aa[0]);

		g = parseInt(aa[1]);

		b = parseInt(aa[2]);

		r = r.toString(16);

		if (r.length == 1) { r = '0' + r; }

		g = g.toString(16);

		if (g.length == 1) { g = '0' + g; }

		b = b.toString(16);

		if (b.length == 1) { b = '0' + b; }

		return ("#" + r + g + b).toUpperCase();

	}
	else {
		return aa;
	}
}

function colorpanelshow(num) {
	intocolor(num);
	$("#colorpanel" + num).show();
}
function colorpanelhide(num) {
	$("#colorpanel" + num).hide();
}
function doclick(obj, num) {
	var bg = $(obj).css('background-color');
	$("#DisColor" + num).css("background", bg);
	color = getHexColor(bg);
	$('#color' + num).attr("value", color);
}
function getHexColor(bg) {
	var rgb = bg.split('(');
	var color1 = parseInt(rgb[1].split(',')[0]) << 16;
	var color2 = parseInt(rgb[1].split(',')[1]) << 8;
	var color3 = parseInt(rgb[1].split(',')[2]);
	var color = color1 + color2 + color3;
	return color;
}
/*end osd function*/

/*start upload function*/
//upid上传文件input控件的id编号一般为upgrade1
//type上传logo和更新系统提示内容不一样，根据type区分, 0是上传logo, 1是更新系统
var upload_id = "";
function Upload(upid, type) {
	var upgrade = $("#upgrade" + upid).val();
	if (upgrade == "") {
		if(Language == "Chinese") {
			alert("请选择上传文件！");
		}else {
			alert("Please select a file upload!");
		}
	}
	else {
		if(0 == type) {
			upgrade = upgrade.slice(-9);
			var short_name = upgrade.slice(0, 5);
			var ext_name = upgrade.slice(5);
			if ((short_name == "logo1" || short_name == "logo2" || short_name == "logo3" || short_name == "logo4") &&
				(ext_name == ".bmp" || ext_name == ".png")) {
				upload_id = getTimeAndRandom();
				$.ajaxFileUpload({
					type: "post",
					url: "http://" + hostip + "/SetNet.html?id=" + upload_id,
					dataType: "json",
					fileElementId: 'upgrade' + upid,
					cache: false,
					success: function (data) {
					}
				})
				setTimeout(progressBar(upid, type), 1000);
			}
			else {
				if(Language == "Chinese") {
					alert("请按要求上传图片");
				}else {
					alert("The file name is not correct");
				}
			}
		}else{
			upload_id = getTimeAndRandom();
			$.ajaxFileUpload({
				type: "post",
				url: "http://" + hostip + "/SystemE.html?id=" + upload_id,
				dataType: "json",
				fileElementId: 'upgrade' + upid,
				cache: false,
				success: function (data) {
				}
			})
			setTimeout(progressBar(upid, type), 1000);
		}
	}
}

function Bargo(BarNum) {
	BarNum = parseInt(BarNum * 100);
	$("#bar").width((BarNum - 2) + "%");
	$("#bar").html("<div>" + BarNum + "%</div>");
}

function progressBar(upid, type) {
	$("#up_but" + upid).attr("disabled", true);
	$("#upgrade" + upid).attr("disabled", true);
	$("#topLoader" + upid).show();
	var loadvalue;
	var animateFunc = function () {
		$.ajax({
			type: "GET",
			url: "http://" + hostip + "/up_progress?id=" + upload_id,
			dataType: "text",
			cache: false,
			success: function (data) {
				loadvalue = data;
				Bargo(loadvalue);
				if (loadvalue == 1) {
					if(Language == "Chinese") {
						if(0 == type){
							alert("上传成功！");
						}else{
							alert("升级成功，请重启系统！");
						}
					}else{
						if(0 == type) {
							alert("Upload successfully!");
						}else{
							alert("Update succeed, reboot system!");
						}
					}
					$("#topLoader" + upid).hide();
					$("#up_but" + upid).attr("disabled", false);
					$("#upgrade" + upid).attr("disabled", false);
				}
				if (loadvalue == -1) {
					if(Language == "Chinese") {
						if(0 == type){
							alert("上传失败！");
						}else{
							alert("升级失败！");
						}
					}else{
						if(0 == type){
							alert("Update failed!");
						}else{
							alert("Update failed!");
						}
					}
					$("#topLoader" + upid).hide();
					$("#up_but" + upid).attr("disabled", false);
					$("#upgrade" + upid).attr("disabled", false);
				}
				if (loadvalue < 1 && loadvalue >= 0) {
					setTimeout(animateFunc, 25);
				}
			}
		})
	}
	setTimeout(animateFunc, 25);
}


function curDateTime() {
	var d = new Date();
	var year = d.getFullYear() + "";
	var month = d.getMonth() + 1;
	var date = d.getDate();
	var day = d.getDay();
	var Hours = d.getHours(); //获取当前小时数(0-23)
	var Minutes = d.getMinutes(); //获取当前分钟数(0-59)
	var Seconds = d.getSeconds(); //获取当前秒数(0-59)
	var curDateTime = year;
	if (month > 9) {
		curDateTime = curDateTime + month;

	}

	else {
		curDateTime = curDateTime + "0" + month;
	}
	if (date > 9)
		curDateTime = curDateTime + date;
	else
		curDateTime = curDateTime + "0" + date;
	if (Hours > 9)
		curDateTime = curDateTime + Hours;
	else
		curDateTime = curDateTime + "0" + Hours;
	if (Minutes > 9)
		curDateTime = curDateTime + Minutes;
	else
		curDateTime = curDateTime + "0" + Minutes;
	if (Seconds > 9)
		curDateTime = curDateTime + Seconds;
	else
		curDateTime = curDateTime + "0" + Seconds;
	return curDateTime;
}

function RndNum() {
	var rnd = "";
	for (i = 0; i <= 3; i++) {
		rnd += Math.floor(Math.random() * 10);
	}
	return rnd;
}
//输出指定位数的随机数的随机整数
function getTimeAndRandom() {
	return curDateTime() + RndNum(4);
}
/*end upload function*/

/*start other function*/
//判断IP
function checkIp(str) {
	var ss = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
	return ss.test(str);
}
//判断路径
function checkDress(str) {
	var result = true;
	str = str.substr(0, 7);
	if (str == "rtmp://") {
		result = false;
	}
	else {
		result = true;
	}
	return result;
}

function GetVideoSize(input, output, venc_width_height_same_as_input, width, height, des_width, des_height) {
	var arrWidthTxt = "";
	var IsSlected = 0;
	var result = '<select id="VideosizeSle" name="select_big">';
	width = parseInt(width);
	var arrWidth;
	if(input == 0 && output == 0) {
		arrWidth = new Array('0x0', '1920x1080', '1680x1056', '1680x1050', '1280x768', '1280x720', '1024x768', '1024x576', '850x480', '800x600', '720x576', '720x540', '720x480', '720x404', '704x576', '640x480', '640x360', '608x448', '544x480', '480x480', '480x384', '480x360', '480x320', '480x272', '480x270', '400x320', '400x224', '352x480', '352x228', '320x256', '320x240', '320x180', '240x180', '176x144');
	}else if(input == 0 && output == 1) {
		arrWidth = new Array('0x0', '1280x720', '1024x768', '1024x576', '850x480', '800x600', '720x576', '720x540', '720x480', '720x404', '704x576', '640x480', '640x360', '608x448', '544x480', '480x480', '480x384', '480x360', '480x320', '480x272', '480x270', '400x320', '400x224', '352x480', '352x228', '320x256', '320x240', '320x180', '240x180', '176x144');
	}else if(input == 1 && output == 0) {
		arrWidth = new Array('0x0', '720x576', '720x540', '720x480', '720x404', '704x576', '640x480', '640x360', '608x448', '544x480', '480x480', '480x384', '480x360', '480x320', '480x272', '480x270', '400x320', '400x224', '352x480', '352x228', '320x256', '320x240', '320x180', '240x180', '176x144');
	}else if(input == 1 && output == 1){
		arrWidth = new Array('0x0', '720x576', '720x540', '720x480', '720x404', '704x576', '640x480', '640x360', '608x448', '544x480', '480x480', '480x384', '480x360', '480x320', '480x272', '480x270', '400x320', '400x224', '352x480', '352x228', '320x256', '320x240', '320x180', '240x180', '176x144');
	}
	var j = 0;
	if (venc_width_height_same_as_input == "1") {
		if(Language == "Chinese") {
			arrWidthTxt = "与输入分辨率相同";
		}
		else {
			arrWidthTxt = "same as the input";
		}
		
		result += '<option value="' + arrWidth[0] + '" selected ="selected">' + arrWidthTxt + '</option>';
		IsSlected = 1;
		j = 1;
	}
	for (var i = j; i < arrWidth.length; i++) {
		if (arrWidth[i] == "0x0") {
			if(Language == "Chinese") {
				arrWidthTxt = "与输入分辨率相同";
			}
			else {
				arrWidthTxt = "same as the input";
			}
		}
		else {
			arrWidthTxt = arrWidth[i];
		}

		if (IsSlected == 1) {
			result += '<option value="' + arrWidth[i] + '">' + arrWidthTxt + '</option>';
		}
		else {
			var str_before = arrWidth[i].split('x')[0];
			str_before = parseInt(str_before);
			var str_after = arrWidth[i].split('x')[1];
			str_after = parseInt(str_after);
			if (width >= str_before) {
				if (des_width == str_before && des_height == str_after) {
					result += '<option value="' + arrWidth[i] + '" selected ="selected">' + arrWidthTxt + '</option>';
					IsSlected = 1;
				}
				else {
					result += '<option value="' + arrWidth[i] + '">' + arrWidthTxt + '</option>';
				}
			}
		}
	}

	result += '</select>';
	return result;
}

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