function calculateDate(mon,vid){
	var mydate=new Date();
	var fdate=new Date();
	var month=mon;
	var vid1=vid;
	
	var daysToAdd = month*30; //6 months
	
	var fTime = fdate.getTime()+(daysToAdd*24*60*60*1000);
	fdate.setTime(fTime);
	
	//document.dform.currentdate.value = formatDate(mydate);
	//document.dform.futuredate.value = formatDate(fdate);
	document.getElementById(vid1).value=formatDate(fdate);
}
function formatDate(d) {
	var theyear=d.getYear()
	if (theyear < 1000) theyear+=1900
	
	var theday=d.getDay()
	var themonth=d.getMonth()+1
	if (themonth<10) themonth="0"+themonth
	
	var theday = d.getDate()
	if (theday<10) theday="0"+theday
	
	var displayfirst=themonth;
	var displaysecond=theday;
	var displaythird=theyear;
	
	return displaythird+"-"+displayfirst+"-"+displaysecond;
}

function limitText(limitField, limitNum) 
	{
		alert(limitField)
		if (limitField.value.length > limitNum)
		{
			limitField.value = limitField.value.substring(0, limitNum);
			alert("Only 159 characters are allowed ");
				
		} 
    }
function handleEnter(inField, e,val) {
	
	//alert(val);
    var charCode;
    
    if(e && e.which){
        charCode = e.which;
    }else if(window.event){
        e = window.event;
        charCode = e.keyCode;
		
    }
	//alert(parseInt(document.sms.message.value.length));
    if(parseInt(document.sms.message.value.length)<=parseInt(val))
	{
		 //alert(document.sms.message.value.length);
		if(charCode == 13) {
			//alert("Enter was pressed on " + inField.vid);
			document.sms.display.value=document.sms.display.value-2;
		}
		else
		{
			
			 document.sms.display.value=parseInt(val)-parseInt(document.sms.message.value.length);
		}
	}
	else
	{
		document.sms.message.value=document.sms.message.value.substr(0,val) 
		
	}
}

function show_table(tid)
  {
	  //alert(vid);
  var tid1=tid;
  if(tid1=='tr_id')
     {
	  alert('1');
	  document.getElementById('tr_id').style.visibility="visible";
	 }
	 else
	 {
		  alert('2');
	  document.getElementById('hrs_id').value='-1';
	  document.getElementById('mint_id').value='-1';
	  document.getElementById('txtdate_id').value='';
	  //document.getElementById('tr_id').style.visibility="hidden";
	  
	 }
  }
  
  function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

