var url = window.location.href;
var intPos = url.indexOf("="); 
var slotno= url.substr(intPos + 1);
var ENGLISH = 0;
var CHINESE = 1;
var ANNEXB_64 = 11;
var ANNEXB_256 = 13;
function funcUpdateDisplay() 
{	 	
	$("#switch").val(VID_QAM_CI_ALARM_SWITCH);
	$("#In_switch").val(VID_QAM_CI_SWITCH);
	$("#qammode").val(VID_QAM_CI_IN_MOD);
	$("#freq").val(VID_QAM_CI_IN_FREQ);
	$("#symbolrate").val(VID_QAM_CI_IN_SR);
	$("#sysrate").val(VID_QAM_CI_SYS_RATE);
	$("#vldrate").val(VID_QAM_CI_VLD_RATE);
	$("#curslot").val(slotno);
}

function jump(id)
{	
	if(id==1)
	{
		window.location.href="C523_cardparam.asp?slotno="+slotno;
	}
	else if(id==2)
	{
		window.location.href="C523_camprog.asp?slotno="+slotno;
	}
}

function jumpcard(id)
{	
	if(id==1)
	{
		window.location.href="C523_cardparam.asp?slotno="+slotno;
	}
	else if(id==2)
	{
		window.location.href="C523_cardparam2.asp?slotno="+slotno;
	}
}

function submitcheck()
{
	var returnnum;
	returnnum = validateParam($("#freq"),"INT_DEC", 52000, 858000, "<Frequency(KHz)>", "<中心频率(KHz)>", language);
	if(returnnum == false)
	{
		return;
	}
	if((parseInt($("#qammode").val(), 10) != ANNEXB_64) && (parseInt($("#qammode").val(), 10) != ANNEXB_256))
	{
		returnnum = validateParam($("#symbolrate"),"INT_DEC", 3500, 7000, "<Symbolrate(KBand)>", "<符号率(KBand)>", language);
		if(returnnum == false)
		{
			return;
		}
	}
	else if(parseInt($("#qammode").val(), 10) == ANNEXB_64)
	{
		returnnum = validateParam($("#symbolrate"),"INT_DEC", 5035, 5080, "<Symbolrate(KBand)>", "<符号率(KBand)>", language);
		if(returnnum == false)
		{
			return;
		}	
	}
	else if(parseInt($("#qammode").val(), 10) == ANNEXB_256)
	{
		returnnum = validateParam($("#symbolrate"),"INT_DEC", 5335, 5385, "<Symbolrate(KBand)>", "<符号率(KBand)>", language);
		if(returnnum == false)
		{
			return;
		}	
	}
	$("#paramform").submit();
    setTimeout("self.location.reload(true)",1000);

}

function validateParam(obj, type, minValue, maxValue, str1, str2, language)
{
	var patten;
	var strVal = obj.val();
	var numVal;
	switch(type) 
	{
		case "INT_DEC":  //十进制整数
			patten = /^-?\d+$/;
			if(!patten.test(strVal))
			{
				if(language == ENGLISH)
				{
					alert(str1 + " should be decimal integer!");
				}
				else if(language == CHINESE)
				{
					alert(str2 + "应该是十进制整数！");
				}
				setTimeout(function () {obj.focus()}, 0);
				setTimeout(function () {obj.select()}, 0);
				return false; 
			}
			break;		
		default:
			break;
	}
	numVal = parseInt(strVal, 10);
	if((minValue < maxValue) || ((minValue > 0) && (minValue = maxValue))) //输入0,0表示参数没有取值范围
	{
		if((numVal < minValue) || (numVal > maxValue))
		{
			if(language == ENGLISH)
			{
				alert(str1 + "should be between " + minValue + " and " + maxValue + "!");
			}
			else if(language == CHINESE)

			{
				alert(str2 + "应该在" + minValue + "和" + maxValue + "之间！");
			}
			setTimeout(function () {obj.focus()}, 0);
			setTimeout(function () {obj.select()}, 0);
			return false;
		}
	}
	return true; 
}
