function viewdet(id)
{
	document.frm.hdnid.value=id;
	document.frm.submit();
}

function changepage(a,tgt)
{
	document.frm.txtcurrentpage.value=a;
	if (a==-1) 
	{
		document.frm.txtcurrentpage.value=document.frm.cmbPageNo.value;
		//document.frm.txtpagesize.value=document.frm.cmbpagesize.value;
	}
	document.frm.action=tgt;
	document.frm.submit();
}
function setpagesize(tgt)
{
	document.frm.txtpagesize.value=document.frm.cmbpagesize.value;
	document.frm.txtcurrentpage.value=1;
	document.frm.action=tgt;
	document.frm.submit();
}
function viewallrecs(tgt)
{
	document.frm.txtsearchtext.value="";
	document.frm.txtpagesize.value="0";
	document.frm.txtcurrentpage.value=1;
	document.frm.datefrom.value="";
	document.frm.dateto.value="";
	document.frm.action=tgt;
	document.frm.submit();
}
function submitsearch(tgt)
{
	if (document.frm.txtsearchtext.value.split(" ").join("").length < 1 && (document.frm.datefrom.value.split(" ").join("").length<1 && document.frm.dateto.value.split(" ").join("").length<1))
	{
			alert("Please enter a search keyword or Please select daterange.");
			document.frm.txtsearchtext.focus();
			return false;
	}	
	else
	{
		if (document.frm.datefrom.value.split(" ").join("").length>1 && document.frm.dateto.value.split(" ").join("").length>1)	
		{
			if(check1())
			{
			document.frm.txtpagesize.value=document.frm.cmbpagesize.value;
			document.frm.txtcurrentpage.value=1;	
			document.frm.action=tgt;
			document.frm.submit();
			}
			else
			return false;
		}
		else
		{
			document.frm.txtpagesize.value=document.frm.cmbpagesize.value;
			document.frm.txtcurrentpage.value=1;	
			document.frm.action=tgt;
			document.frm.submit();	
		}
	}
	
	
}
function check_press(frm)
{
	title=trim(frm.title.value);
	strcontent=(document.getElementById('strContent').value);

	if(title=="")
	{
		alert("Please enter title");
		frm.title.focus();
		return false;
	}
	//if(strcontent=="")
//	{
//		alert("Please enter content");
//		return false;
//	}
	return true;
}
function go(a,b,tgt)
{
	document.frm.action = tgt;
	
	if ( a != "" && a == "nothing") 
	{
		document.frm.cpage.value = "";		
	}
	
	if (b != "go")
	{
		if ( a != "nothing" && a != "" )
		{ 
			document.frm.hdnorderby.value = a;
			document.frm.hdnorder.value = b;	
//			document.frm.cpage.value = "";
		}
	}
	
	if (b == "go")
	{
		document.frm.cpage.value = a;
	}	
	
	document.frm.submit();
}
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}
function check1()
{
		var dtCh= "-";

		if (document.frm.datefrom.value=="")
		{
			alert("Please select from date");
			return false;
		}
		
		if (document.frm.dateto.value=="")
		{
			alert("Please select to date");
			return false;
		}
		d1 = document.frm.datefrom.value;
		var pos1=d1.indexOf(dtCh);
		var daysInMonth = DaysArray(12);
		var pos2=d1.indexOf(dtCh,pos1+1)
		var strMonth=d1.substring(0,pos1)
		var strDay=d1.substring(pos1+1,pos2)
		var strYear=d1.substring(pos2+1);
		
		d2 = document.frm.dateto.value;
		var pos1=d2.indexOf(dtCh);
		var daysInMonth = DaysArray(12);
		var pos2=d2.indexOf(dtCh,pos1+1)
		var strMonth2=d2.substring(0,pos1)
		var strDay2=d2.substring(pos1+1,pos2)
		var strYear2=d2.substring(pos2+1);
		if (strYear>strYear2)
		{
			alert("From date must be less than or equal to To date");
			return false;
		}
		if (strYear==strYear2 && strMonth>strMonth2)
		{
			alert("From date must be less than or equal to To date");
			return false;
		}
		if (strYear==strYear2 && strMonth==strMonth2 && strDay>strDay2)
		{
			alert("From date must be less than or equal to To date");
			return false;
		}

		return true;
		
}