//This is GotoPage() function to open given page



function GotoPage(Pagename) 

{

	//alert(Pagename);

	location.href=Pagename;

}

function GoToShipDetails(recordNo)

{

		document.forms[0].action="shipdetailspage.php";

		document.forms[0].RecordPointer.value=recordNo;

		

		document.forms[0].submit();

}

//==========================================================

	function ShowConsolidate()

	{

				document.forms[0].PageCounter.value=0;

			   var val=document.frmlist;

				 for(i=0;i<val.elements.length;i++)

				  {



					if(val.elements[i].checked===true)

					 {

						return true;

					}

				   }

					alert("Please select atleast one option before consolidation");

				 return false;

				//document.forms[0].submit();

	}

//////////////////////////////////////////////////////////////////////////

// A GENERLIZE FUNCITON FOR FORM CLEAR / RESET THE FORM 

// author =  kishor ranga , 20th June,2005

//=============================================================================================================================

	function ResetForm()

		{

		

		var a;

			for(a=0; a< document.forms.length; a++)

			{	

				var frm = document.forms[a];

				var i;

				for(i=0; i< frm.elements.length; i++)

				{	

				//	alert(frm.elements[i].name +" - "+ frm.elements[i].type);

					if(frm.elements[i].type!='button' && frm.elements[i].type!='submit'  )

					{

						frm.elements[i].value='';

					}

					if(frm.elements[i].type=='radio'  || frm.elements[i].type=='checkbox'  )

					{

					//alert(frm.elements[i].name +" - "+ frm.elements[i].type);

							frm.elements[i].checked=false;

					}

						

				}			

			}

		}

//=============================================================================================================================

// A GENERLIZE FUNCITON FOR CONTROL CLEAR / RESET THE FORM IF ITS VALUE IS 0 OR ''

/////////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////////

// A GENERLIZE FUNCITON FOR CONTROL CLEAR / RESET  WHILE EDITING

// author =  Teena Goswami , 3rd Oct,2006

//=============================================================================================================================

	function ResetControl(ctrl)

		{

			if(ctrl.value==0)

				ctrl.value="";

				

		}

//=============================================================================================================================

// A GENERLIZE FUNCITON FOR FORM CLEAR / RESET FORM CONTROL

/////////////////////////////////////////////////////////////////////////



//============ KISHOR ==============================================================\\

//a function for placing ids of ship which has to delete from database 

// which ship types now the builder is not offering, but previously offered

//============= KISHOR =============================================================\\

function SearchForCats(Id,control)

			{

				if(control.status==true)

				{	

					if(document.forms[0].myids.value=='')

						document.forms[0].myids.value=Id;	

					else

						document.forms[0].myids.value+="," + Id;		

				}

				else

				{

				var strVal=document.forms[0].myids.value;

					if(strVal.search(""+Id)>0)

					{	

						document.forms[0].myids.value=strVal.replace(","+Id,"");

						strVal=document.forms[0].myids.value;

					}

				}

			}

//====================================================

//==================================================================

//==================================================================

//FUNCTION TO SET COLOR OF THE TABLE ROW ON MOUSE OVER

//==================================================================

//==================================================================

function SetbackColorRow(vals,Count)

{

	var i;

	for(i=1; i<=Count; i++)

	{

		document.getElementById(vals +'00'+ i).style.background='#D0D3DD';

		document.getElementById(vals +'00'+ i).style.fontWeight='normal';

		document.getElementById(vals +'00'+ i).style.border='#009D00';

	}

}



//==================================================================

//==================================================================

//==================================================================

//FUNCTION TO REMOVE COLOR OF THE TABLE ROW ON MOUSE FOCUS LOST

//==================================================================

//==================================================================

function RemovebackColorRow(vals,Count, RowClass)

{

	var i;

	for(i=1; i<=Count; i++)

	{

		if(RowClass == 'tdcol1')

			document.getElementById(vals +'00'+ i ).style.background='#F9F9F9';

		else

			if(RowClass == 'tdcol2')

				document.getElementById(vals +'00'+ i ).style.background='#F0F1F4';

			else

				if(RowClass != '')

					document.getElementById(vals +'00'+ i ).style.background= RowClass;

				else

					document.getElementById(vals +'00'+ i ).style.background='#F0F1F4';



		document.getElementById(vals +'00'+ i ).style.fontWeight='normal';

		document.getElementById(vals +'00'+ i ).style.color='#383872';

	}

}

//==================================================================

//==================================================================

//FUNCTION TO SET COLOR OF THE TABLE ROW ON MOUSE OVER

//==================================================================

//==================================================================

function SetbackColorCol(vals,CountFrom, CountTo)

{

	var i;

	for(i=CountFrom; i<=CountTo; i++)

	{

		document.getElementById(vals +'00'+ i ).style.background='red';

		document.getElementById(vals +'00'+ i ).style.fontWeight='bold';

		document.getElementById(vals +'00'+ i ).style.color='white';

		document.getElementById(vals +'00'+ i ).style.border='#009D00';

	}

}

//==================================================================

//====================================================================

//==================== trimmer() ends ============================

//====================================================================

 

 // function for top tip in alphbet list and matrix of builders

 		// permission is granted to use this javascript provided that the below code is not altered

var DH = 0;var an = 0;var al = 0;var ai = 0;if (document.getElementById) {ai = 1; DH = 1;}else {if (document.all) {al = 1; DH = 1;} else { browserVersion = parseInt(navigator.appVersion); if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {an = 1; DH = 1;}}} 



function fd(oi,ws) {if (ws == 1) {if (ai) {return (document.getElementById(oi).style);}

else {if (al) {return (document.all[oi].style);} else {if (an) {return (document.layers[oi]);}};}} else {if (ai) {return (document.getElementById(oi));} else {if (al) {return (document.all[oi]);} else {if (an) {return (document.layers[oi]);}};}}} 



function pw() {if (window.innerWidth != null) return window.innerWidth; if (document.body.clientWidth != null)

return document.body.clientWidth; return (null);} 



function popUp(evt,oi)

 { 

 

 if (DH) 

 { 

 

 var wp = pw(); ds = fd(oi,1); dm = fd(oi,0); st = ds.visibility; if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; if (st == "visible" || st == "show") { ds.visibility = "hidden"; } else  { if (evt.y || evt.pageY) {if (evt.pageY) {tv = evt.pageY + 20;

lv = evt.pageX - (ew/4);} else {tv = evt.y + 20 + document.body.scrollTop; lv = evt.x  - (ew/4) + document.body.scrollLeft;} if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2;if (!an) {lv += 'px';tv += 'px'};ds.left = lv; ds.top = tv;} ds.visibility = "visible";}}}

//====================================================================

//====================================================================

//==================================================================

//==================================================================

//FUNCTION TO REMOVE COLOR OF THE TABLE ROW ON MOUSE FOCUS LOST

//==================================================================

//==================================================================

function RemovebackColorCol(vals,CountFrom, CountTo, RowClass)

{

	var i;

	for(i=CountFrom; i<= CountTo; i++)

	{

		document.getElementById(vals +'00'+ i ).style.background=RowClass;

		document.getElementById(vals +'00'+ i ).style.fontWeight='normal';

		document.getElementById(vals +'00'+ i ).style.color='#383872';

		document.getElementById(vals +'00'+ i ).style.border='#ffffff  1px solid';

	}

}

//=============================================================================================================================

//THIS FUNCTION POSTS FORM FOR NEXT PAGE ....

//THIS FUNCTION POSTS FORM FOR NEXT PAGE ....

//=============================================================================================================================

function NextPage()

{

	

	document.frmlist.PageCounter.value = eval(document.frmlist.PageCounter.value) + 1  ;

	document.frmlist.submit();

}

//=============================================================================================================================

//=============================================================================================================================

//THIS FUNCTION POSTS FORM FOR PREVIOUS PAGE ....

//THIS FUNCTION POSTS FORM FOR PREVIOUS PAGE ....

//=============================================================================================================================

function PrePage()

{

	document.frmlist.PageCounter.value = eval(document.frmlist.PageCounter.value) - 1  ;

	document.frmlist.submit();

}



//=============================================================================================================================

//=============================================================================================================================

//THIS FUNCTION POSTS FORM FOR SPECIFIED PAGE NUMBER....

//THIS FUNCTION POSTS FORM FOR SPECIFIED PAGE NUMBER....

//=============================================================================================================================

function NextPageLink(val)

{

	document.frmlist.PageCounter.value = eval(val)-1  ;

	document.frmlist.submit();

}

//=============================================================================================================================

//========function SubmitForPage used to submit form ==========================================================================

//=============================================================================================================================

//function SubmitForPage(FormName, ControlName, ControlValue, FormAction,Query='')

function SubmitForPage(FormName, ControlName, ControlValue, FormAction)

{

	ControlName.value = ControlValue;

	FormName.action = FormAction;

	FormName.submit();

}

//=============================================================================================================================

//THIS FUNCTION POSTS FORM FOR SPECIFIED ALPHABET LISTING....

//=============================================================================================================================

function AlphaList(val)

{

	document.frmlist.PageCounter.value = 0  ;

	document.frmlist.AlphaValue.value = val;

	document.frmlist.submit();

}

//=============================================================================================================================

/************************************************************************************

	BELOW FUNCTION IS TO OPEN A WAIT WINDOW, DISPLAYED UNTILL THE PAGE IS NOT CLOSED

************************************************************************************/	

//Wait();

var waitwindow ;

function Wait()

{

//	waitwindow = window.open("ancharts/wait.php", "_blank", "height=100, width=200, left=340, top=360, fullscreen=0, menubar=0, scrollbars=0, titlebar=0, toolbar=0, status=0, resizable=0");

}



function ShowPage()

{

		document.getElementById('loading').style.display = "none";

}



function ShowChartPage()

{

		document.getElementById('loading').style.display = "none";

}



/**************************************************************************************

************************************************************************************/

function SetbackColor()

{

	//event.srcElement.className="boxfocus";

}



function RemovebackColor()

{

	//event.srcElement.className="white";

}



/**************************************************************************************

************************************************************************************/

//this is OpenFullDetailsWindow() function to open details info file into new page

function OpenFullDetailsWindow(FileName)

{

	var Height = screen.height - 120;

	var Width = screen.width - 100;



	Detailinfo = window.open(FileName, "_blank", "height="+Height+", width="+Width+", left=50, top=40, fullscreen=0, menubar=0, scrollbars=1, titlebar=0, toolbar=0, status=1, resizable=1");

}



/**************************************************************************************

/**************************************************************************************

************************************************************************************/

//this is OpenDetailsWindow() function to open details info file into new page

function OpenTheDetailsWindow(FileName)

{

	Detailinfo = window.open(FileName, "_blank", "height=600, width=800, left=100, top=30, fullscreen=0, menubar=1, scrollbars=1, titlebar=0, toolbar=1, status=0, resizable=1");

}



/**************************************************************************************

************************************************************************************/

//this is OpenNewFile() function to open details info file into new page

function OpenNewFile(FileName,Width,Height)

{

	Detailinfo = window.open(FileName, "_blank", "height="+Height+", width="+Width+", left=50, top=50, fullscreen=0, menubar=0, scrollbars=1, titlebar=0, toolbar=0, status=0, resizable=1");

}



function windowopen(FileName) 

{

	Detailinfo =window.open(FileName,'_blank', 'height=350, width=900, left=100, top=160, fullscreen=0, menubar=0, scrollbars=1, titlebar=0, toolbar=0, status=0, resizable=0');

}



/**************************************************************************************

************************************************************************************/

//THIS IS OrderBy() FUNCTION, TO SUBMIT FORM TO DISPLAY DATA IN SELECTED ORDER

function OrderBy( FieldVal, OrderBy)

{

	//if same field is ordered again, order by in reverse 

		//if previously it was in ascending order, change it to descending order

	if(FieldVal == document.frmlist.orderfield.value)

		if(document.frmlist.orderby.value == 'asc')

			OrderBy = 'desc';

		else

			OrderBy = 'asc';



	document.frmlist.orderfield.value = FieldVal;

	document.frmlist.orderby.value = OrderBy;

	document.frmlist.submit();

}



/**************************************************************************************

************************************************************************************/

//function to dusplay the details of the  the selected order

function OpenDetailWindow(type,Id)

{

   var urlstr="showorderdetail.php?type="+type + "&id="+Id + "&otype=order";

	window.open(urlstr, Id,"alwaysRaised=1,dependent=0,height=680,location=0,menubar=0,personalbar=0,scrollbars=1,status=0,toolbar=0,width=800,resizable=1,left=40,top=10");

}



//=============================================================================================================================

//THIS FUNCTION POSTS FORM FOR ORDER BY....

//THIS FUNCTION POSTS FORM FOR ORDER BY....

//=============================================================================================================================

function OrderPage(OrderBy)

{

	

	document.frmlist.PageCounter.value = eval(document.frmlist.PageCounter.value);



	if(document.frmlist.orderby.value.search(OrderBy)<0)

	{    

		document.frmlist.orderby.value = OrderBy;

	}

	else

	{ 

		if(document.frmlist.orderby.value.search(' desc')<0)

		{

			

			document.frmlist.orderby.value = OrderBy+' desc';

		}

		else

		

			document.frmlist.orderby.value = OrderBy;

	}

//	SamePagePost();

	document.frmlist.submit();

}



//====================================================================

//REPLACEMENT FUNCTION FOR trim() FUNCTION.....

//REPLACEMENT FUNCTION FOR trim() FUNCTION.....

//====================================================================

//====================================================================

function Trimmer(pVal) {

	

    TRs=0; 

    for (i=0; i<pVal.length; i++) 

	{ 

        if (pVal.substr(i,1)==" ") 

		{

			TRs++;

		} 

		else 

			{break;} 

    } 



    TRe=pVal.length-1; 

    for (i=TRe; i>TRs-1;i--)

	{ 

        if (pVal.substr(i,1)==" ") 

		{

			TRe--;

		}

		else 

			{break;} 

    } 



    return (pVal.substr(TRs, TRe-TRs+1)); 

} 



//====================================================================

//==================== trimmer() ends ============================



//=========================================================================================

// FUNCTION FOR CHECK VALID DATE FORMAT ( EG. 02-Jun-2005 ) 

// created on 18/6/2005

// by Kishor 	

		function validDate(dateComponent, displayStr)

		{

			if(dateComponent.value!='')

			{

			//========================= validation code =======================================\\

					var Arr_Kishor = ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

					var d1, flag=0;

					d1 = dateComponent.value.split("-");		

					if(d1.length < 2)

						flag=1;

					else if(d1[0].length!=2 || d1[1].length!=3  || d1[1].length!=3)

						flag=1;

					else

					{

						 flag=1;

						for(i=0;i<Arr_Kishor.length;i++)

						 {

						   if(d1[1]==Arr_Kishor[i])

								 flag=0; 		

						}

						if(d1[0] > 31 || d1[0] < 0)

							flag=1;

						if(d1[2] > 2200 || d1[2] < 1950)

							flag=1;

					}	

					if(flag==1)

						{

							alert("Please enter a valid "  + displayStr + " date  ");

							//dateComponent.value='';

							dateComponent.focus();

							return false;

						}

					return true;

			//========================= END.... validation code =======================================\\		

			}

			else

			{

				alert("Please enter a valid " + displayStr +" date");

				dateComponent.focus();

				return false;

			}		

		}	

	

//====================================================================

//====================================================================

//Trim by Object name.....

//====================================================================

//====================================================================

function TrimObj(theObj) 

{ 

	var pVal = theObj.value;



    var TRs=0; 

    for (var i=0; i<pVal.length; i++) 

	{ 

        if (pVal.substr(i,1)==" ") 

		{

			TRs++;

		} 

		else 

			{break;} 

    } 



   	var TRe=pVal.length-1; 

    for (i=TRe; i>TRs-1;i--)

	{ 

        if (pVal.substr(i,1)==" ") 

		{

			TRe--;

		}

		else 

			{break;} 

    } 



    theObj.value = pVal.substr(TRs, TRe-TRs+1); 

} 

//==================== trimmer() ends ============================

//====================================================================

//====================================================================

 // function for top tip in alphbet list and matrix of builders

 		// permission is granted to use this javascript provided that the below code is not altered

		

var DH = 0;var an = 0;var al = 0;var ai = 0;if (document.getElementById) {ai = 1; DH = 1;}else {if (document.all) {al = 1; DH = 1;} else { browserVersion = parseInt(navigator.appVersion); if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {an = 1; DH = 1;}}} function fd(oi,ws) {if (ws == 1) {if (ai) {return (document.getElementById(oi).style);}

else {if (al) {return (document.all[oi].style);} else {if (an) {return (document.layers[oi]);}};}} else {if (ai) {return (document.getElementById(oi));} else {if (al) {return (document.all[oi]);} else {if (an) {return (document.layers[oi]);}};}}} function pw() {if (window.innerWidth != null) return window.innerWidth; if (document.body.clientWidth != null)

return document.body.clientWidth; return (null);} function popUp(evt,oi) {  if (DH) {var wp = pw(); ds = fd(oi,1); dm = fd(oi,0); st = ds.visibility; if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; if (st == "visible" || st == "show") { ds.visibility = "hidden"; } else  { if (evt.y || evt.pageY) {if (evt.pageY) {tv = evt.pageY + 20;

lv = evt.pageX - (ew/4);} else {tv = evt.y + 20 + document.body.scrollTop; lv = evt.x  - (ew/4) + document.body.scrollLeft;} if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2;if (!an) {lv += 'px';tv += 'px'};ds.left = lv; ds.top = tv;} ds.visibility = "visible";}}}



function CheckEmailId(val) {

// Check for a properly formatted email address.

   if ((val.value.length == 0)) {

      return false;

   }



   if (val.value.length != 0) {

     // var emailformat = /^.+@.+\..{2,3}$/;

      var emailformat = /^[^@\s]+@([-a-z0-9]+\.)+([a-z]{2}|com|net|edu|org|gov|mil|int|biz|pro|info|arpa|aero|coop|name|museum|nic|in|co.in|co|inc)$/;

      if (!emailformat.test(val.value))

	   {

         alert("Please enter a valid email-Id.");

		 val.value="";

		 val.focus();

		 return false;

      }

   }

   return true;

}



//===============================================================================================================================

//======================================== FUNCTION dateConversion() start =========================================

//=============================================================================================================================

//function for date

//compare date

function DateComparison(date1,date2)

{

// alert('kishor');

    var d1,d2,m1,m2,y1,y2;

    var fromdate=date1.split('-');

    var todate=date2.split('-');   

	var ARR_MONTH = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN","JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];

	var FromMonth='';

	var ToMonth='';

    var mon=fromdate[1];

	mon=mon.toUpperCase();

    var mon1=todate[1];

	mon1=mon1.toUpperCase(mon1);



	for(i=0;i<ARR_MONTH.length;i++)

	 {

	   if(mon==ARR_MONTH[i])

	   {

	     FromMonth=i+1;

	   }

	   if(mon1==ARR_MONTH[i])

	   {

	     ToMonth=i+1;

	   }

	 }



	

   d1=eval(fromdate[0]);

   d2=eval(todate[0]);

   m1=eval(FromMonth);

   m2=eval(ToMonth);

   y1=eval(fromdate[2]);

   y2=eval(todate[2]);



   //return true if second is greater  or equal to first date

   	if (y2 > y1)

	{

   		return true;

	}

	else

	{

		if(y1 > y2)

		{

			return false;

		}

		else

		{

			if(m2>m1)

			{

				return true;

			}

			else

			{

				if(m1>m2)

				{

					return false;

				}

				else

				{

					if(d2>=d1)

					{

						return true;

					}

					else

					{

						return false;

					}



				}



			}



		}



	}   



 }







//=============================================================================================================================



//THIS FUNCTION TO CONVERT DATE IN LAUNCH DATE FORMAT....



//FORMAT : INPUT (DD-MMM-YYYY) : OUTPUT : (YYYY-MM-DD)....



//=============================================================================================================================







function dateYYYYMMDD(date)



{



	var d=date.substr(0,2);



	var m=date.substr(3,3);



	var months = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");



	var digitmonths = new Array("01","02","03","04","05","06","07","08","09","10","11","12");



	for(var i=0;i<12;i++)



	{



		if(m==months[i])



			break;



	}



	var y=date.substr(7,4);



	var newdate=y+'-'+digitmonths[i]+'-'+d;



	return newdate ;



}



//=============================================================================================================================



//THIS FUNCTION TO CONVERT DATE IN LAUNCH DATE FORMAT....



//FORMAT : INPUT (DD-MMM-YYYY) : OUTPUT : (YYYYMMDD)....



//=============================================================================================================================







function DateToNumber(date)



{ 

    

	var d=date.substr(0,2);



	var m=date.substr(3,3);



	var months = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");



	for(var i=0;i<12;i++)



	{



		if(m==months[i])



			break;



	}



	i++;



	var y=date.substr(7,4);



	if(i<10)



		var newdate=y+'0'+i+d;



	else



		var newdate=y+i+d;



	return newdate ;



}







//==============================================================================



//==============================================================================



//FUNCTION CHECKS FOR NUMBER ONLY INPUT



//==============================================================================



//==============================================================================



function NumberCheck(Val)



{

	var NumVal=Val.value;

	if(NumVal.substr(NumVal,0,1)=='.')

		NumVal=NumVal.concat(0,NumVal);

	if(isNaN(NumVal))



	{



		NumVal=NumVal.substr(0,NumVal.length-1);



	}	



}







//==============================================================================







////////////////////////////////////////////////////////////////////



/// This function used for show the popup help



///////////////////////////////////////////////////////////////////



var oPopup = window.createPopup();



function ShowHelpWindow(Purpose,Process){



var countVal=(Purpose.length)+ (Process.length)+100;



//alert(countVal);







	if(countVal>600 && countVal <1000 ){ countVal = countVal/2;}



	else if(countVal>350 && countVal<600){ countVal = countVal/1.5;}



	else if (countVal < 200){countVal = 200;}



	else if(countVal>1000 && countVal <2000 ){ countVal = countVal/3;}



		//alert(countVal);











    var oPopBody = oPopup.document.body;



    oPopBody.style.backgroundColor = 'white';



    oPopBody.style.border = 'solid #5978AA 1px';



	oPopBody.innerHTML = '<basefont face=arial color=navy><table width="100%" cellspacing=5 cellspacing=4 border=0 align=center style="font-size:12px;color:navy;border:SILVER 1px solid">'



	+ '<TR><th bgcolor=#859BC1 height=25><font color=white>Admin Help Details </font>'



	+ '</th><TR><TD style="font-size:12px;background:white">'



	+'<table width=96% cellspacing=4 cellspacing=8 border=0 align=center style="font-size:12px;color:navy"><TD style="font-size:12px;background:white">'



	+ '<font size=3 face=arial style="font-size:12px"><p align=justify><u style="color:Blue"><strong>OBJECTIVE</strong></u> :&nbsp;'



	+ Purpose + '</p>' 



	+ '<p align=justify><u style="color:Blue"><strong>HOW CAN USE OR WORKOUT</strong></u> :&nbsp;'+ Process +' </font></p></table></table>'



	+ '<BR><div align=right style="font-size:12px"><BR> Press <b> "ESC" </b> to close the window &nbsp;&nbsp;</div>';



	  oPopup.show(400, 5, 400, countVal, document.body);



	



}







////////////////////////////////////////////////////////////////////







// JAVA SCRIPT FILE USED FOR THE MEMBER SIDE SEARCH IN  WORLDYARDS============\\







//============================Om Ganasay Namah===============================\\







//=======================================================================\\



//=========FUNCTION TO ELIMINATE PER. OR UNDERSCORE =======\\



function removePerUnderScore(theField)



{



  var len=eval(theField.value.length);



  var newValue="";



   if(theField.value==" " && len==1)



     theField.value=Trimmer(theField.value);



   if(theField.value.charAt(len-1)==" " && theField.value.charAt(len-2)==" " && len>=2)



     theField.value=theField.value.substr(0,len-1);//Trimmer(theField.value);



  for(var i=0;i<len;i++)



   {



     if(theField.value.substr(i,1)=="%" || theField.value.substr(i,1)=="_" || theField.value.substr(i,1)=="-")



      {



	    continue;



	  }



     else



	   newValue+=theField.value.substr(i,1);



   }



   //Assign new value to the object 



 theField.value=newValue;



}



//=======================================================================\\



//=======CHECK THAT FIELD IS A VALID NUMBER FIELD========================\\



//=======================================================================\\



function isNumberField(theField)

{



  var numFlag=true;



  var countDot=0;



  var ch="";



  var newValue="";



  theField.value=Trimmer(theField.value);



  for(i=0;i<theField.value.length;i++)



   {



     ch=theField.value.charAt(i);



	 if(ch==".")



	  countDot+=1;



     if ((ch >= "0" && ch <= "9") || (ch == "."))



	  {



		  if(countDot>1)



		  {



		    //CODE TO ALERT THE USER



			//alert("Enter a valid number value");



		  //  theField.value="";



		  //  return false; 



		   //CODE TO REMOVE THE OTHER VALUES EXCEPT NUMBER



		   continue;



		  }



		  else



		  {



		   newValue+=ch;  //NEW VALUE OF THE NUMBER



		  }	



	  }



	 else



	 {



		    //CODE TO ALERT THE USER



		//alert("Enter a valid numeric value");



		//theField.value="";



		//return false; 



		continue;



	 } 



   } 



   //====for correct new value==\

  //alert(theField.name);

   theField.value=newValue;

 // theField.select();

}





//=======================================================================\\





///=======CHECK THAT FIELD IS A VALID NUMBER FIELD========================\\



//=======================================================================\\



function isIntegerField(theField)



{



  var numFlag=true;



  var ch="";



  var newValue="";



    theField.value=Trimmer(theField.value);

	//if(theField.value == '')

		//return;

		

  for(i=0;i<theField.value.length;i++)



   {



     ch=theField.value.charAt(i);



	 if((ch >= "0" && ch <= "9"))



	   newValue+=ch;



	  // continue;



	 else



	  {



		    //CODE TO ALERT THE USER



	   ///alert("Enter a valid integer value");



	   ///theField.value="";



	   ///return false; 



	   continue;



	  }



   } 



   //====for correct new value==\

	//if(eval(theField.value) == 0)

   		//theField.value='';

   //else

	   theField.value=newValue;

   



}



//=======================================================================\\



//=======================================================================\\



//=======CHECK THAT FIELD IS A VALID DATE FORMAT========================\\



//=======================================================================\\



//=======================================================================\\



//CHECK THAT FIELD IS A VALID DATE FORMAT========================\\

//Check that field is a valid date format

//Function Added by Swati Vyas on 19-Feb-2009

function isDateValue(theField)

{

	var val;

	

	theField.value=Trimmer(theField.value);

	

	if(theField.value=="")

	{

		return;

	}

	val=theField.value.toUpperCase();

	//Regular Expression for check date format.

	var longform =  /^[0-9]{2}-(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)-[0-9]{4}$/;

		

		//If condition for test that the date is valid or not. 

		if (longform.test(val))

		{

			var DateArr = val.split("-");

		

			//If condition for check that the month is Feb

			if (DateArr[1]=='FEB') 

			{	

				//If condition for check that the year is Leap Year or not

				if (((DateArr[2]%4==0) && (DateArr[2]%100>0)) || (DateArr[2]%400==0)) 	

				{

					if(DateArr[0]>29)	

					{

						alert("Please enter proper Date.");

						theField.value='';

					}

				}

				else

				{

					if(DateArr[0]>28)	

					{

						alert("Please enter proper Date.");

						theField.value='';

					}

				}

			}

		

			if ((DateArr[1]=='APR') || (DateArr[1]=='JUN') || (DateArr[1]=='SEP') ||(DateArr[1]=='NOV'))

			{

				if(DateArr[0]>30)

				{

				alert("Please enter proper Date.");

				theField.value='';

				}

			}

			else

			{

				if ((DateArr[1]=='JAN') || (DateArr[1]=='MAR') || (DateArr[1]=='MAY') ||(DateArr[1]=='JUL') || (DateArr[1]=='AUG') 

					|| (DateArr[1]=='OCT') || (DateArr[1]=='DEC'))

				{

					if(DateArr[0]>31)

					{

						alert("Please enter proper Date.");

						theField.value='';

					}

				}

			}

			return true;

		}

	alert ("Please enter date as format (01-Jan-2004)");



	theField.value="";



	theField.focus();



     return false;



}



//Commented by Swati Vyas 0n 19-Feb-2009



/*

function isDateValue(theField)

{

     // alert(theField);

	  theField.value=Trimmer(theField.value);



	  if(theField.value=="")



	   return;



	   



	   theField.value.toUpperCase();



	  var longform =  /^[0-9]{2}-([JAN]|[FEB]|[MAR]|[APR]|[JUN]|[JUL]|[AUG]|[SEP]|[OCT]|[NOV]|[DEC])-[0-9]{4}$/;



         if (longform.test(theField.value))



		  {



            return true;



         }



         alert ("Please enter date as format (01-Jan-2004)");



        theField.value="";



         theField.focus();



         return false;



}

*/







//=======================================================================\\



//============================Om Ganasay Namah===========================\\



//isNumberField(this) is used for number field like 10.0000



//isIntegerField(this) is used for integer field



//removePerUnderScore(this) is used to remove the % and under score 







//=======================================================================\\



//=======================================================================\\



////////////////////////////////////////////////////////////////////////////////////////



// function for comparison of Second value greater



/////////////////////////////////////////////////////////////////////



	function GreaterCondition(firstVal,SecondVal,displayString)



	{



	//alert(eval(firstVal.value));



	isNumberField(SecondVal);



			if(eval(firstVal.value) > eval(SecondVal.value))



			{



				alert("Please enter second value greater of "+ displayString);



				SecondVal.focus();



				return false;



			}



		



		return true;		



		



	}











		function checkall(form)



		 {



		  var val=form;



		  var count=0;



		  for(;count <val.elements.length;count++)



			val.elements[count].checked=true;



		 }



		// uncheck all



		function uncheckall(form)

		 {

			//alert("gfkjdlgkdg");

		  var val=form;

		  var count=0;

		

		  for(;count <val.elements.length;count++)

			{

			val.elements[count].checked=false;

			}



		 }



		 



//==============================================================================



//=====function to display city according to selected country===========



function ShowCity(CountryControl, CityControl, ExCity)

{

  	var CountryID = CountryControl.value;

	//remove all cities from city select control



	CityControl.length = 0;

	//select all countries from array, related with country



	var thecount = 0;



	var optcount = 1;



			



	var option = new Option();

	CityControl.options[0] = option;

	CityControl.options[0].text='Please select';



	CityControl.options[0].value='';

	while(thecount < TotalCity)

	{ 

		if(CountryCode[thecount] == CountryID)



		{

			var option = new Option(CityName[thecount], CityId[thecount]);



	      	CityControl.options[optcount] = option;



			



			if(CityId[thecount] == ExCity)



				CityControl.options[optcount].selected = true;



				



			optcount = optcount + 1;



		}



		thecount = thecount + 1;



	}



	if(optcount == 1)



	{



		CityControl.options[0].text='No city found';



	}



}



//============================END FUNCTION========================================================



//========================================================================



//=====function to increment date by day==================



//====the date must be in dd-mm-yyyy format=============



//================================================================



function IncrementDay(TheDate, DayAfter) 



{



    // parse s for month, day, year



    var dateArray = TheDate.split('-');



    sdate = new Date(dateArray[2],dateArray[1],dateArray[0]-1);







// figure out day, month, year according to days after



    var odate = new Date(sdate.getTime() + (DayAfter * 86400000));







// return value



	if(odate.getDate()<10)



		var TheDay = '0'+ odate.getDate();



	else



		var TheDay = odate.getDate();



	



 	if((odate.getMonth()+1)<10)



		var TheMonth = '0'+ odate.getMonth();



	else



		var TheMonth = odate.getMonth();







	return TheDay + '-' + TheMonth + '-' + odate.getYear();



}



//========================================================================



//========================================================================



//=================================================================



//==============FUNCTION TO RESET KEYWORD SEARCH===================



function DSResetKeyword(LinkPage)



{



	document.frmlist.keyword.value = '';



	document.frmlist.PageCounter.value = 0;



	document.frmlist.orderby.value = '';



	location.href = LinkPage;



}



//=================================================================



//=================================================================



//==============================================================================



//=====function to display ship type according to selected ship segment===========

function ShowyardType(SyardControl, SbuildrControl, ExShipYard)



{

	var varSBID = SbuildrControl.value;



	//remove all ship types from ship type select control



	SyardControl.length = 0;



	//select all ship types from array, related with ship segment



	var thecount = 0;



	var optcount = 1;

	var ExCounter = 0;

			



	var option = new Option();



	SyardControl.options[0] = option;



	SyardControl.options[0].text = 'Please select';



	SyardControl.options[0].value = '';





	while(thecount < TotalSY)



	{

		if(SBName[thecount] == varSBID)



		{



			var option = new Option(ShipYardName[thecount], ShipYardId[thecount]);



	      	SyardControl.options[optcount] = option;



			if(ShipYardId[thecount] == ExShipYard)



				SyardControl.options[optcount].selected = true;



			



			optcount = optcount + 1;



		}



		thecount = thecount + 1;



	}



	if(optcount == 1)



	{

			SyardControl.options[0].text='No shipyard found';



	}







}



//============================END FUNCTION========================================================

//=====function to display ship type according to selected ship segment===========



function ShowShipType(STControl, SegControl, ExShipType)



{

	 //alert('ok');

	var varSegID = SegControl.value;



	//remove all ship types from ship type select control



	STControl.length = 0;



	//select all ship types from array, related with ship segment



	var thecount = 0;



	var optcount = 1;

	var ExCounter = 0;

			



	var option = new Option();



	STControl.options[0] = option;



	STControl.options[0].text = 'Please select';



	STControl.options[0].value = '';





	while(thecount < TotalST)



	{

		if(SegName[thecount] == varSegID)



		{



			var option = new Option(ShipTypeName[thecount], ShipTypeId[thecount]);



	      	STControl.options[optcount] = option;



			if(ShipTypeId[thecount] == ExShipType)



				STControl.options[optcount].selected = true;

			



			optcount = optcount + 1;



		}



		thecount = thecount + 1;



	}



	if(optcount == 1)



	{

			STControl.options[0].text='Please select segment first';



	}







}



//============================END FUNCTION========================================================

//==============================================================================

//===============function to set size field name and unit according to selected ship type=========

function SetSizeByShipType(STControl, SizeControl, UnitControl)

{

	var varSTId = STControl.value;

	var thecount = 0;

	SizeControl.value = '';

	UnitControl.value = '';



	//==============if ship type size is dwt/gt...set it as mandatory..else set another field as ship size

	document.getElementById('dwtmand').style.display = "none";

	document.getElementById('wyshipfld').style.display = "none";



	while(thecount < TotalST)

	{

		if(ShipTypeId[thecount] == varSTId)

		{

			if(ShipSizeField[thecount] == 'dwt')

			{

				document.getElementById('dwtmand').style.display = "inline";

				SizeControl.value = 'dwt';

				document.getElementById('specfldnam').value = 'dwt';

			}

			else

			{

				if(ShipSizeField[thecount] == 'gt')

				{

					SizeControl.value = 'gt';

					document.getElementById('specfldnam').value = 'gt';

				}

				else

				{

					document.getElementById('wyshipfld').style.display = "inline";

					SizeControl.value = 'size';

					UnitControl.value = "("+ShipSizeUnit[thecount]+")";

					document.getElementById('specfldnam').value = ShipSizeField[thecount];

				}				

			}

		}

		thecount = thecount + 1;

	}

}

//============================END FUNCTION========================================================

//==============================================================================

//=========FUNCTION TO CHECK PROPER RANGE OF NUMBERS==============================================



function CheckRange(FromControl, ToControl, FocusControl, LabelMsg)



{



	



		if(eval(Trimmer(FromControl.value)) > eval(Trimmer(ToControl.value)))



		{



				FocusControl.focus();

				FocusControl.value = '';

				alert("Please enter proper range for "+LabelMsg+".");



				return false;



		}



		return true;



}



//============================END FUNCTION========================================================



//==============================================================================



//==========FUNCTION TO CONVERT DELIVERY DATE FORMAT TO DD-MON-YYYY FORMAT========================



function ChangeDeliveryDateForm(DeliveryDate)



{



	if(DeliveryDate == '')



		return;



    var DelArr = DeliveryDate.split('-');



	



	//=======if delivery date is in proper format=========



	if(DelArr.length == 3)



		return DeliveryDate;



	else



	{



		if(DelArr.length == 1)



			return '01-Jan-'+DelArr[0];



		else



		{



			if(DelArr[0].length == 3)	//for month only



				return '01-'+DeliveryDate;



			else



			{



					switch(DelArr[0])



					{



						case 'H1':



							return '01-Jan-'+DelArr[1];



							break;



						case 'H2':



							return '01-Jul-'+DelArr[1];



							break;



						case 'Q1':



							return '01-Jan-'+DelArr[1];



							break;



						case 'Q2':



							return '01-Apr-'+DelArr[1];



							break;



						case 'Q3':



							return '01-Jul-'+DelArr[1];



							break;



						case 'Q4':



							return '01-Oct-'+DelArr[1];



							break;



						



					}



			}



		}



	}



}



	//======================================================================

	//===========================================================================

	function setColorBack(FormName)

	{

		var total=FormName.elements.length;

		var i;

		var fldName ='';

		for(i=0; i<=total; i++)

		{

			fldName=FormName.elements[i].name;

			if(FormName.elements[fldName].value!='')

				if(FormName.elements[fldName].id!='')

					{

						var compId = FormName.elements[fldName].id;

						document.getElementById(compId).style.background='yellow';

					}

		}

	}

	//=========function to change background color===========



//=================================================================

//function to validate date format=========

//=================================================================

function ValidateDateFormat(DateField)

{

	DateValue = DateField.value;

	var TheFlag = 0;

	var ch;

	var Counter = 0;

	if(DateValue.length == 0)

		return;

		

	if(DateValue.length == 7 || DateValue.length == 4 )

	{

		if(DateValue.length == 7)

		{

			if(DateValue.search("/") != 2)

			{

				alert("Please enter date in mm/yyyy format only.");

				TheFlag = 1;

			}

			else

			{

				if(eval(DateValue.substr(0,2)) > 12 || eval(DateValue.substr(0,2)) < 1)

				{

					alert("Please enter proper month value.");

					TheFlag = 1;

				}

				else

				{	

					  	for(var i=3;i<7;i++)

					  	{

						 	ch=DateValue.charAt(i);

						 	if((ch >= "0" && ch <= "9"))

							{

								Counter++;

							}

							else

							{

								alert("Please enter proper year value.");

								TheFlag = 1;

								break;

							}

						}

				}

			}

		}

		else

		{

					  	for(var i=0;i<4;i++)

					  	{

						 	ch=DateValue.charAt(i);

						 	if((ch >= "0" && ch <= "9"))

							{

								Counter++;

							}

							else

							{

								alert("Please enter proper year value.");

								TheFlag = 1;

								break;

							}

						}

		}

	}

	else

	{

		alert("Please enter date in mm/yyyy format only.");

		TheFlag = 1;

	}

	

	

	if(TheFlag == 1)

	{

		DateField.value = '';

		DateField.focus();

	}



}

//=========================================================================================================================

//=====in mm/yyyy format=====if FromDate is less than or equal to ToDate, return true...else return false============

//=========================================================================================================================

function ValidateSearchDate(FromDate, ToDate)

{

	var FromMonth = FromDate.substr(0,2);

	var FromYear = FromDate.substr(3,4);

	var ToMonth = ToDate.substr(0,2);

	var ToYear = ToDate.substr(3,4);



	if(FromDate == '' || ToDate == '')

		return true;

		

	if(ToYear > FromYear)

		return true;

	else

	{

		if(ToYear < FromYear)

			return false;

		else

		{

			if(ToYear == FromYear)

			{

				if(ToMonth < FromMonth)

					return false;

				else

					return true;

			}

		}

	}

}



//=========================================================================================================================

//EDITED BY MAHESH SONI TO CHECK THE DATE FORMAT AS DDMMYYYY

//=========================================================================================================================

function validDateMMDDYY(dateComponent, displayStr)

{

			if(dateComponent.value!='')

			{

			//========================= validation code =======================================\\

					var Arr_Kishor = ["01", "02", "03", "04", "05", "06","07", "08", "09", "10", "11", "12"];

					var d1, flag=0;

					d1 = dateComponent.value.split("/");		

					if(d1.length < 2)

						flag=1;

					else if(d1[0].length!=2 || d1[1].length!=2  || d1[1].length!=2)

						flag=1;

					else

					{

						 flag=1;

						for(i=0;i<Arr_Kishor.length;i++)

						 {

						   if(d1[1]==Arr_Kishor[i])

								 flag=0; 		

						}

						if(d1[0] > 31 || d1[0] < 0)

							flag=1;

						if(d1[2] > 2200 || d1[2] < 1950)

							flag=1;

					}	

					if(flag==1)

						{

							alert("Please enter a valid "  + displayStr + " date  ");

							//dateComponent.value='';

							dateComponent.focus();

							return false;

						}

					return true;

			//========================= END.... validation code =======================================\\		

			}

			else

			{

				return true;

			}		

}

//=========================================================================================================================

//===============================================================================================================================

//EDITED BY MAHESH SONI TO COMPARE DATE VALUE TO THE CURRENCT DATE

//======================================== FUNCTION dateConversion() start =========================================

//=============================================================================================================================

//function for date

//compare date

function DateComparisonFORDDMMYY(date1, date2,type)

{

    var d1,d2,m1,m2,y1,y2;

    var fromdate=date1.split('/');

    var todate=date2.split('/'); 

	

	if(type=='MM')  

		var ARR_MONTH = ["01", "02", "03", "04", "05", "06","07", "08", "09", "10", "11", "12"];

	else 

		var ARR_MONTH = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN","JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];



	var FromMonth='';

	var ToMonth='';

    var mon=fromdate[1];

	mon=mon.toUpperCase();

    var mon1=todate[1];

	mon1=mon1.toUpperCase(mon1);



	for(i=0;i<ARR_MONTH.length;i++)

	 {

	   if(mon==ARR_MONTH[i])

	   {

	     FromMonth=i+1;

	   }

	   if(mon1==ARR_MONTH[i])

	   {

	     ToMonth=i+1;

	   }

	 }



	

   d1=eval(fromdate[0]);

   d2=eval(todate[0]);

   m1=eval(FromMonth);

   m2=eval(ToMonth);

   y1=eval(fromdate[2]);

   y2=eval(todate[2]);



   //return true if second is greater  or equal to first date

   	if (y2 > y1)

	{

   		return true;

	}

	else

	{

		if(y1 > y2)

		{

			return false;

		}

		else

		{

			if(m2>m1)

			{

				return true;

			}

			else

			{

				if(m1>m2)

				{

					return false;

				}

				else

				{

					if(d2>d1)

					{

						return true;

					}

					else

					{

						return false;

					}



				}



			}



		}



	}   



 }

//=============================================================================================================================



//=========================================================================================================================

//=====in dd/mm/yyyy format=====if FromDate is less than or equal to ToDate, return true...else return false============

//=========================================================================================================================

function ValidateSearchDateDDMMYY(FromDate, ToDate)

{

	var FromDay = FromDate.substr(0,2);

	var FromMonth = FromDate.substr(3,5);

	var FromYear = FromDate.substr(6,10);

	

	var ToDay = ToDate.substr(0,2);

	var ToMonth = ToDate.substr(3,5);

	var ToYear = ToDate.substr(6,10);

	

	/*=========done by teena for testing purpose

	if(FromDate.length==8)

	{

		var FromDay = FromDate.substr(0,2)

		var ToDay = ToDate.substr(0,2);

		var FromMonth = FromDate.substr(3,5);

		var ToMonth = ToDate.substr(3,5);

		var FromYear = FromDate.substr(6,10);

		var ToYear = ToDate.substr(6,10);

	}

	else if(FromDate.length>=6)

	{

		var FromMonth = FromDate.substr(0,2);

		var ToMonth = ToDate.substr(0,2);

		var FromYear = FromDate.substr(3,7);

		var ToYear = ToDate.substr(3,7);

	}

	else if(FromDate.length>=4)

	{

		var FromYear = FromDate.substr(0,4);

		var ToYear = ToDate.substr(0,4);

	}

	

	alert(FromDay+"   :    "+ToDay+"   :   "+FromMonth+"   :   "+ToMonth+"   :   "+FromYear+"   :    "+ToYear);

	==========================================*/

	

	if(FromDate == '' || ToDate == '')

		return true;

		

	if(ToYear > FromYear)

		return true;

	else

	{

		if(ToYear < FromYear)

			return false;

		else

		{

			if(ToYear == FromYear)

			{

				if(ToMonth < FromMonth)

					return false;

				else

				{

					if(ToDay < FromDay)

						return false;

					else

						return true;

				}

			}

		}

	}

}



//====================================================================================================

//=========function to open ship file window.........................................................

//====================================================================================================

function OpenShipFilesWindow(FileName, ShipWYNum, Permanent)

{

	var URLstr = FileName + "?shipwynum="+ShipWYNum+"&permanent="+Permanent;



	var Id = 'shipfilewin';

	window.open(URLstr, Id,"alwaysRaised=1,dependent=0,height=550,location=0,menubar=0,personalbar=0,scrollbars=1,status=0,toolbar=0,width=700,resizable=1,left=40,top=10");

}

//====================================================================================================



//Function OpenSBFilesWindow() Added by Kailash Pati on 12 December 2006

//====================================================================================================

//=========function to open Files window for shipbuilder when we click the button in shipbuilder edit module.

//====================================================================================================

function OpenSBFilesWindow(FileName, SBWYNum, Permanent)

{

	var URLstr = FileName + "?sbwynum="+SBWYNum+"&permanent="+Permanent;



	var Id = 'sbfilewin';

	window.open(URLstr, Id,"alwaysRaised=1,dependent=0,height=550,location=0,menubar=0,personalbar=0,scrollbars=1,status=0,toolbar=0,width=700,resizable=1,left=40,top=10");

}

//====================================================================================================



//Function OpenRemarksWindow() Added by Kailash Pati on 31 January 2007

//====================================================================================================

//=========function to open Remarks window for facility. 

//====================================================================================================

function OpenRemarksWindow(FileName, FCWYNum, Permanent)

{

	var URLstr = FileName + "?fcwynum="+FCWYNum+"&permanent="+Permanent;



	var Id = 'remarksfilewin';

	window.open(URLstr, Id,"alwaysRaised=1,dependent=0,height=550,location=0,menubar=0,personalbar=0,scrollbars=1,status=0,toolbar=0,width=700,resizable=1,left=40,top=10");

}

//====================================================================================================



//Function OpenNewsWindow() Added by Kailash Pati on 06 January 2007

//====================================================================================================

//=========function to open shipbuilder file window.........................................................

//====================================================================================================

function OpenNewsWindow(FileName, SBWYNum)

{

	var URLstr = FileName + "?hsbwynum="+SBWYNum+"&called=SB";



	var Id = 'newswin';

	window.open(URLstr, Id,"alwaysRaised=1,dependent=0,height=630,location=0,menubar=0,personalbar=0,scrollbars=1,status=0,toolbar=0,width=950,resizable=0,left=40,top=10");

}

//====================================================================================================



//====================================================================================================

//===========================================================================

//===========function to change combo values dynamically.........................

//===========================================================================

/*

SourceControl : Combo, from which the value is taken to fill the target combo

TargetControl : Combo, in which values are to be filled



SourceValArr : The Existing array...containing values for combo of source control ...the indices for this array are matched with array for target controls values

TargetValArr : The Existing array...containing values for combo of target control 

TargetCapArr : The Existing array...containing Text for combo of target control

TheCountVar  : The existing variable ..containing total count of target values

EmptyMessage : Message to be shown if no value exists in target array for selected source

ExTargetValue : The values for target..which should be shown as selected (if not null)

*/

function ShowComboValue(SourceControl, TargetControl, SourceValArr, TargetValArr, TargetCapArr, TheCountVar, EmptyMessage, ExTargetValue)

{

	var SourceId = SourceControl.value;

	//remove all values from target control

	TargetControl.length = 0;

	//select all values from target array, related with source control's values

	var thecount = 0;

	var optcount = 1;

			

	var option = new Option();

	TargetControl.options[0] = option;

	TargetControl.options[0].text='Please select';

	TargetControl.options[0].value='';



	while(thecount < TheCountVar)

	{

		if(SourceValArr[thecount] == SourceId)

		{

			var option = new Option(TargetCapArr[thecount], TargetValArr[thecount]);

	      	TargetControl.options[optcount] = option;

			

			if(ExTargetValue !='' && TargetValArr[thecount] == ExTargetValue)

				TargetControl.options[optcount].selected = true;

				

			optcount = optcount + 1;

		}

		thecount = thecount + 1;

	}

	if(optcount == 1)

	{

		TargetControl.options[0].text = EmptyMessage;

	}

}

//===========================================================================

//===========================================================================

//==============================================================================

//==============================================================================

//====================function to open file to generate PDF for chart=======================

function OpenPDF(ValueString)

{

	window.open(ValueString, "_blank", "height=600, width=800, left=100, top=20, fullscreen=0, menubar=0, scrollbars=1, titlebar=0, toolbar=0, status=1, resizable=1");

}

//==============================================================================

//==============================================================================

//=================================================================================================================

// This function is used to check all or uncheck all shipwynum to generate excel or gnerate compressed text report

//=================================================================================================================	

function CheckAllForExcel(flag)

{

	if(flag==true)

	{  

		for(i=0; i < document.forms[0].elements.length; i++)

			document.forms[0].elements[i].checked=true;

			document.forms[0].compressId.value ="," + document.forms[0].AllWyNums.value;

			

			//====Added by Richa on 22 Aug 2007======To make the compress button enable============

			document.forms[0].compbutnotselected.value ="," + document.forms[0].AllWyNums.value;

			document.forms[0].compressFlag.value='true';

			if(document.forms[0].compress)

			{

			document.forms[0].compress.disabled= false;

			document.getElementById('compress').className ="butheading";

			}

			if(document.forms[0].generate2)

			{

				document.forms[0].generate2.disabled= false;

				document.getElementById('generate2').className ="butheading";

			}

			//==================================================================

	}

	if(flag==false)

	{  

		for(i=0; i < document.forms[0].elements.length; i++)

			document.forms[0].elements[i].checked=false;

			document.forms[0].compressId.value = '';

			//====Added by Richa on 22 Aug 2007======To make the compress button disable============

			document.forms[0].compbutnotselected.value = '';

			document.forms[0].compressFlag.value='false';

			if(document.forms[0].compress)

			{

				document.forms[0].compress.disabled= true;

				document.getElementById('compress').className ="butheadingdisabled";

			}

			if(document.forms[0].generate2)

			{

				document.forms[0].generate2.disabled= true;

				document.getElementById('generate2').className ="butheadingdisabled";

			}

			//====================================================================================

	}

}

//=================================================================================================================

//=====function CompressPassWyNum() is used to store/remove checked/unchekced shipwynum to generate excel or compressed text report

//=================================================================================================================

function CompressPassWyNum(wynum, object)

{

  

	var MyShipIds = document.forms[0].compressId.value;

	if(object.checked==false)

		document.forms[0].compressId.value = MyShipIds.replace(","+wynum,"");		

	else if(object.checked==true)

	{

		document.forms[0].compressId.value=document.forms[0].compressId.value + "," + wynum;

		document.forms[0].compbutnotselected.value=document.forms[0].compressId.value ;

	}	

		if(document.forms[0].compressId.value=='')

		     document.forms[0].compressFlag.value='false';

	if(document.forms[0].compressFlag.value!='true')

	{ 

	   if(document.forms[0].compress)

	    {

		 	if(Trimmer(document.forms[0].compressId.value)=='')

			{	

				document.forms[0].compress.disabled= true;

				document.getElementById('compress').className ="butheadingdisabled";

			}

			else

			{	

		

				document.forms[0].compress.disabled= false;

				document.getElementById('compress').className ="butheading";

			}

		}

	}

		

		//if(document.forms[0].compressId.value=='')

		//     document.forms[0].compressFlag.value='flase';

	//	else	

		    // document.forms[0].compressFlag.value='true';



}

//====================================================================

	function CheckOrNot()

	{



		var frmNam = document.forms[0];

		var CheckFlag=0;

		var i;

		//======== for loop ==============\

		for(i=0; i < frmNam.elements.length; i++)

		//====== check flag make 1 ==========\\ 

		if(frmNam.elements[i].checked==true)

			CheckFlag=1;

		//==== if check flag 0 than return false

		if(CheckFlag==0 && frmNam.compressId.value=='')

		{

			//alert("Please check atleast one vessel");

			//frmNam.focus();

			//return false;

			document.forms[0].target='_self';

			document.forms[0].PageCounter.value=0;			

			document.forms[0].compressFlag.value=true

			document.forms[0].compressId.value="," + document.forms[0].AllWyNums.value;

			frmNam.submit();

			return true;

		}

		else

		{

			document.forms[0].target='_self';

			document.forms[0].PageCounter.value=0;			

			document.forms[0].compressFlag.value=true

			frmNam.submit();

			return true;

		}	



	}

	

//=================================================================================================================

// THIS USED FOR COMPRESSION FEEATURE IN EVERY WHERE IN SYSTEM

//=================================================================================================================		

		





			function NumberOfCommEntry(PostAtPath,frmNum)

			{

				//alert(PostAtPath);

				var EntryCount = prompt("Enter number of commercial entry will be shown under ship, \nIf you would like to see all commercial entries than directly press 'OK'. ","All");

				if(EntryCount > 0 )

				{

					document.forms[frmNum].target='new';

					document.forms[frmNum].action=PostAtPath;

					document.forms[frmNum].TotalCommEntry.value=" limit 0,"+ EntryCount + " ";

					document.forms[frmNum].submit();

					//return true;

				}

				else if(EntryCount=='All')

				{

					document.forms[frmNum].target='new';

					document.forms[frmNum].action=PostAtPath;

					document.forms[frmNum].TotalCommEntry.value="";

					document.forms[frmNum].submit();

					//return true;

				}

				else if(EntryCount!=null)

				{

					alert("Please enter a valid number");

				}	

				return false;

			}

//=================================================================================================================

//=================================================================================================================

	

//************This function is used for check the validation of date format in mm-yyyy. year must be greater then 1900***********************

function ValidateDate(DateField)

{

	dateval=DateField.value;



	

if(dateval!='')

{

	var arr_date = dateval.split('-');

	if(isNaN(arr_date[0]) || isNaN(arr_date[1]))

	{

		alert("Invalid date format: '" + dateval + "'.\nFormat accepted is MM-YYYY.");

		document.frmlist.date.value='';

		return false;

	}

		if(arr_date[1].length!=4 || arr_date[0].length!=2)

		{		

	 		alert("Invalid date format: '" + dateval + "'.\nFormat accepted is MM-YYYY.");

			document.frmlist.date.value='';

			return false;

		}

		else if(arr_date[1]<1900 && arr_date[0]>12)

		{

			alert("Invalid date format: '" + dateval + "'.\nPlease enter year > 1900 and month < 13.");

	  	 	document.frmlist.date.value='';

			return false;

		}

		else if(arr_date[1]<1900 || arr_date[0]>12)

		{

			if(arr_date[1] < 1900)

			{

			alert("Invalid date format: '" + dateval + "'.\nPlease enter year > 1900 .");

	  	 	document.frmlist.date.value='';

		    }

			if(arr_date[0] > 12)

			{

			alert("Invalid date format: '" + dateval + "'.\nPlease enter month < 13.");

	  	 	document.frmlist.date.value='';

		    }

	  	 return false;

   	    }

}

return true;

}

//===============================================

//===============================================

function PutLinkUnderLine(vals)

{

	//alert(vals);

	/*

	var obj = document.getElementById("marvel"); 

obj.style.fontFamily = "Verdana"; 

obj.style.fontSize = "40pt"; 

obj.style.backgroundColor = "red"; 

obj.style.color = "black"; 

obj.style.textDecoration = "underline"; 

obj.style.textAlign = "center"; 

obj.style.letterSpacing = "10";

	*/

	document.getElementById(vals).style.textDecoration='underline';

}

function RemoveLinkUnderLine(vals)

{

	document.getElementById(vals).style.textDecoration='none';

}



//============================================================================================

//======================================================================

//=========================================================================================================================

//THIS IS ValidateDateAll() FUNCTION TO CHECK PROPER FORMAT OF ALL DATES (YYYY / MM-YYYY / MM/YYYY / DD-MM-YYYY / DD/MM/YYYY)

/*=========                 @parameters              =================================

	DateControl	-	Name of Date control used by the user

	Seperator	-	Seperator used (/ OR  - Or anything else)

	DateType	-	Y indicates year only, M indincates inclusion of month, D indicates complete date, DM for date or month, MY for month or year, DMY for any type

	DateFormat	-	YF inicates Year first - YYYY-MM-DD, MF indicates Month first - MM-DD-YYYY, DF indicates Day first - DD-MM-YYYY

	DisplayStr	-	Label of Date to display in the message

*/        

//=========================================================================================================================

function ValidateDateAll(DateControl, Seperator, DateType, DateFormat, DisplayStr)

{

	//========if DateValue is empty...return the control==========

	var DateValue = DateControl.value;

	if(DateValue == '')

		return true;

	else

	{

		var MonthArr = ["01", "02", "03", "04", "05", "06","07", "08", "09", "10", "11", "12"];

		var Flag = 1;

		

		var DateLength = DateValue.length;

		//=============Check the date length..for single date type==================================

		if((DateType == "D" && DateLength != 10) || (DateType == "M" && DateLength != 7) || (DateType == "Y" && DateLength != 7))

			Flag = 0;

		//=============Check the date length..for multiple date type==================================

		else

		{

		 	if((DateType == "DM" && !(DateLength == 10 || DateLength == 7)) || (DateType == "MY" && !(DateLength == 7 || DateLength == 4)) || (DateType == "DMY" && !(DateLength == 10 || DateLength == 7 || DateLength == 4)))

				Flag = 0;

			//===============split the date into multiple components========================

			else 

			{

				if(DateLength == 4)	//=if date has only year values........check it 

				{

					if(DateValue >= 1900 && DateValue <= 2500)

						return true;

					else

						Flag = 0;

				}

				else

				{

					var DateArr = DateValue.split(Seperator);

					var DayValue = '';

					var MonthValue = 0;

					var YearValue = 0;

					if(DateLength == 7)	//====if date has month and year values

					{

						if(DateFormat == 'YF' || (DateFormat == 'DF' && DateType == 'DMY')) 

						{

							MonthValue = DateArr[0];

							YearValue = DateArr[1];

						}

						else 

							if(DateFormat == 'MF')

							{

								MonthValue = DateArr[1];

								YearValue = DateArr[0];

							}

							else

								Flag = 0;

					}//...........end if for month and year

					else

					{

						if(DateLength == 10)	//====if date has date, month and year values

						{

							if(DateFormat == 'YF') 

							{

								DayValue = DateArr[2];

								MonthValue = DateArr[1];

								YearValue = DateArr[0];

							}

							else 

								if(DateFormat == 'MF') 

								{

									DayValue = DateArr[1];

									MonthValue = DateArr[0];

									YearValue = DateArr[2];

								}

								else 

									if(DateFormat == 'DF') 

									{

										DayValue = DateArr[0];

										MonthValue = DateArr[1];

										YearValue = DateArr[2];

									}

									else

										Format = 0;

						}

					}//...........end if for  date, month and year

					//################==============================================

					//.....check for proper values of day, month and year...if improper return false....

						if(DayValue != '' && (DayValue < 1 || DayValue > 31))

						{

							Flag = 0;

						}

						else 

							if(MonthValue != 0)	

							{

								for(var Counter = 0; Counter < MonthArr.length; Counter++)

								{

								   if(MonthValue == MonthArr[Counter])

										 break; 		

								}

								if(Counter == MonthArr.length)

								{

									Flag = 0;

								}

							}//..........end if month value checking........

							else 	

								if(YearValue != 0 && (YearValue < 1900 && YearValue > 2500))

								{

									Flag = 0;

								}

					//################==============================================

					//################==============================================

				}//......end else when date vaue is not 'yyyy' only......

			}

		}

			if(Flag == 1)

				return true;

			else

			{

				alert("Please enter " + DisplayStr +" in proper format");

				DateControl.focus();

				return false;

			}

	}

}

//========================================================================================================================

//Added by Ganesh Prasad on 02-02-2006

//This function is useful for proper date format ddmmyyyy or mmyyyy

//DateField - 	Name of first Date control used by the user

//FrmDatVal-   Name of  second Date control used by the user.This is usefull when we want to

//			   compare both the date.  .i.e FrmDatVal is always less than DateField.otherwise not.

//changed by richa bissa on Nov 2,2006

//Function changed by swati vyas on 8-jan-2010 according to Msg No: [25859] [Bug - serch by built date - URGENT]

//=========================================================================================================================

function IntegerFormatDate(DateField,FrmDatVal)

{

	

	isIntegerField(DateField);

	var date = new Date() ;

	var deldat=date.getFullYear();

	var ExpDate=deldat+15;

	DateValue = DateField.value;

	

	

	

	var TheFlag = 0;

	var ch;

	var Counter = 0;

	if(DateValue.length == 0 && FrmDatVal.length == 0)

		return;

if((DateValue.length == 4 && FrmDatVal.length == 0 )|| (DateValue.length == 4 && FrmDatVal.length == 4) || (DateValue.length == 0 && FrmDatVal.length == 4 ))

	{		

		if(DateValue.length!=0)

		{

			//Function changed by swati vyas on 8-jan-2010 according to Msg No: [25859] [Bug - serch by built date - URGENT]

			/*	if(eval(DateValue) > ExpDate || eval(DateValue) < 1970)

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}else */

				if(eval(DateValue) > ExpDate)

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}

				else if(eval(DateValue) < eval(FrmDatVal))

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}

				 

		}

		else

		{

			//Function changed by swati vyas on 8-jan-2010 according to Msg No: [25859] [Bug - serch by built date - URGENT]

			/*if(eval(FrmDatVal) > ExpDate || eval(FrmDatVal) < 1970)

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}*/

				if(eval(FrmDatVal) > ExpDate )

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}

				

		}

	}

	else if((DateValue.length == 6 && FrmDatVal.length == 0 )|| (DateValue.length == 6 && FrmDatVal.length == 6)|| (DateValue.length == 0 && FrmDatVal.length == 6))

	{			

		if(DateValue.length!=0)

		{

			

				if(eval(DateValue.substr(2,4)) < eval(FrmDatVal.substr(2,4)))

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}/**/

				else if(eval(DateValue.substr(2,4))== eval(FrmDatVal.substr(2,4)))

				{

					if(eval(DateValue.substr(0,2)) < eval(FrmDatVal.substr(0,2)))

					{

						alert("Please enter proper month value.");

						TheFlag = 1;

					}

				}

				//Function changed by swati vyas on 8-jan-2010 according to Msg No: [25859] [Bug - serch by built date - URGENT]

				/*if(eval(DateValue.substr(2,4)) > ExpDate || eval(DateValue.substr(2,4)) < 1970)

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}*/

				if(eval(DateValue.substr(2,4)) > ExpDate)

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}

				if(eval(DateValue.substr(0,2)) > 12 || eval(DateValue.substr(0,2)) < 1)

				{

					alert("Please enter proper month value.");

					TheFlag = 1;

				}

		}

		else

		{

			//Function changed by swati vyas on 8-jan-2010 according to Msg No: [25859] [Bug - serch by built date - URGENT]

			/*if(eval(FrmDatVal.substr(2,4)) > ExpDate || eval(FrmDatVal.substr(2,4)) < 1970)

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}*/

				if(eval(FrmDatVal.substr(2,4)) > ExpDate)

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}

				if(eval(FrmDatVal.substr(0,2)) > 12 || eval(FrmDatVal.substr(0,2)) < 1)

				{

					alert("Please enter proper month value.");

					TheFlag = 1;

				}	

		}

	}

		else if((DateValue.length == 8 && FrmDatVal.length == 0 )|| (DateValue.length == 8 && FrmDatVal.length == 8)|| (DateValue.length == 0 && FrmDatVal.length == 8))

	{		

		if(DateValue.length !=0 )		

		{	

				//Function changed by swati vyas on 8-jan-2010 according to Msg No: [25859] [Bug - serch by built date - URGENT]

				/*if(eval(DateValue.substr(4,8)) > ExpDate || eval(DateValue.substr(4,8)) < 1970)

				{

						

						alert("Please enter proper year value.");

						TheFlag = 1;

				}*/

				if(eval(DateValue.substr(4,8)) > ExpDate)

				{

						

						alert("Please enter proper year value.");

						TheFlag = 1;

				}

				else if(eval(DateValue.substr(2,2)) > 12 || eval(DateValue.substr(2,2)) < 1)

				{

						alert("Please enter proper month value.");

						TheFlag = 1;

				}

				else if(eval(DateValue.substr(2,2)) == 1 ||eval(DateValue.substr(2,2))==3 || eval(DateValue.substr(2,2))==5 ||eval(DateValue.substr(2,2))==7 || eval(DateValue.substr(2,2))==8  || eval(DateValue.substr(2,2))==10 || eval(DateValue.substr(2,2))==12)

				{	

						if(eval(DateValue.substr(0,2)) > 31  || eval(DateValue.substr(0,2)) < 1)

							 {

								alert("Please enter proper day's value");

								TheFlag = 1;	

							 }

				}

				else if(eval(DateValue.substr(2,2)) == 2)

				{

					 //=========Added by Richa Bissa on 11th Sep. 2007 

					 //=========To check year value===================

					   if(DateValue.length==6)

					   {

							var Yar=eval(DateValue.substr(2,4));

					   }

					   if(DateValue.length==8)

					   {

							var Yar=eval(DateValue.substr(4,4));

					   }

					 //================================================  

						if(Yar % 4==0)

						{ 

							if(eval(DateValue.substr(0,2)) > 29  || eval(DateValue.substr(0,2)) < 1)

							 { 

								alert("Please enter proper day's value");

								TheFlag = 1;	

							 }

						}

						else if(eval(DateValue.substr(0,2)) > 28  || eval(DateValue.substr(0,2)) < 1)

						{  //alert(eval(DateValue.substr(0,2)));

							alert("Please enter proper day's value");

							TheFlag = 1;	

						}

						

				}

				else if(eval(DateValue.substr(0,2)) > 30  || eval(DateValue.substr(0,2)) < 1)

				 {

						alert("Please enter proper day's value");

						TheFlag = 1;	

				 }

				

				//end

						if(eval(DateValue.substr(4,4)) < eval(FrmDatVal.substr(4,4)))

						{

							alert("Please enter proper year value.");

							TheFlag = 1;

						}

						else if(eval(DateValue.substr(4,4))== eval(FrmDatVal.substr(4,4)))

						{

							

							if(eval(DateValue.substr(2,2)) < eval(FrmDatVal.substr(2,2)))

							{

								alert("Please enter proper month value.");

								TheFlag = 1;

							}

							else if(eval(DateValue.substr(2,2)) == eval(FrmDatVal.substr(2,2)))

							{

								

								if(eval(DateValue.substr(0,2)) <= eval(FrmDatVal.substr(0,2)))

								{	

									alert("Please enter proper day's value");

									TheFlag = 1;

								}

							}

						}

		}

		else

		{

				if(eval(FrmDatVal.substr(4,8)) > ExpDate || eval(FrmDatVal.substr(4,8)) < 1970)

				{

						

						alert("Please enter proper year value.");

						TheFlag = 1;

				}

				else if(eval(FrmDatVal.substr(2,2)) > 12 || eval(FrmDatVal.substr(2,2)) < 1)

				{

						alert("Please enter proper month value.");

						TheFlag = 1;

				}

				else if(eval(FrmDatVal.substr(2,2)) == 1 ||eval(FrmDatVal.substr(2,2))==3 || eval(FrmDatVal.substr(2,2))==5 ||eval(FrmDatVal.substr(2,2))==7 || eval(FrmDatVal.substr(2,2))==8  || eval(FrmDatVal.substr(2,2))==10 || eval(FrmDatVal.substr(2,2))==12)

				{	

						if(eval(FrmDatVal.substr(0,2)) > 31  || eval(FrmDatVal.substr(0,2)) < 1)

							 {

								alert("Please enter proper day's value");

								TheFlag = 1;	

							 }

				}

				else if(eval(FrmDatVal.substr(2,2)) == 2)

				{

						var Yar=eval(FrmDatVal.substr(2,2));

						if(Yar % 4==0)

						{

							if(eval(FrmDatVal.substr(0,2)) > 29  || eval(FrmDatVal.substr(0,2)) < 1)

							 {

								alert("Please enter proper day's value");

								TheFlag = 1;	

							 }

						}

						else if(eval(FrmDatVal.substr(0,2)) > 28  || eval(FrmDatVal.substr(0,2)) < 1)

						{     

							alert("Please enter proper day's value");

							TheFlag = 1;	

						}

						

				}

				else if(eval(FrmDatVal.substr(0,2)) > 30  || eval(FrmDatVal.substr(0,2)) < 1)

				 {

						alert("Please enter proper day's value");

						TheFlag = 1;	

				 }

				

				//end

		}

	}

	else

	{

		alert("Please enter date in right format only.");

		TheFlag = 1;

	}

	

	if(TheFlag == 1)

	{

		DateField.value = '';

		DateField.focus();

		return false;

	}

	else

	{

		var len=DateValue.length;

		if(len== 4)

		{

			

			return DateValue; 

		}

		if(len==6)

		{

			var year=DateValue.substring(len-4,4);

			var mon=DateValue.substring(0,len-4);

			var dat=mon+"/"+year;

			return dat; 

		}

		else

		{	//alert(len);

			var year=DateValue.substring(len-4);

			var mon=DateValue.substring(len-6,len-4);

			var dd=DateValue.substring(0,len-6);

			var dat=dd+"/"+mon+"/"+year;

			

			return dat; 

		}

	}

}







/*function IntegerFormatDate(DateField,FrmDatVal)

{

	isIntegerField(DateField);

	var date = new Date() ;

	var deldat=date.getFullYear();

	var ExpDate=deldat+15;

	DateValue = DateField.value;

	

	var TheFlag = 0;

	var ch;

	var Counter = 0;

	if(DateValue.length == 0 && FrmDatVal.length == 0)

		return;

	if((DateValue.length == 4 && FrmDatVal.length == 0 )|| (DateValue.length == 4 && FrmDatVal.length == 4) || (DateValue.length == 0 && FrmDatVal.length == 4 ))

	{	//		alert(DateValue.length);

		if(DateValue.length!=0)

		{

				if(eval(DateValue) > ExpDate || eval(DateValue) < 1970)

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}

				

				else if(eval(DateValue) < eval(FrmDatVal))

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}

		}

		else

		{

			if(eval(FrmDatVal) > ExpDate || eval(FrmDatVal) < 1970)

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}

				

		}

	}

	else if((DateValue.length == 6 && FrmDatVal.length == 0 )|| (DateValue.length == 6 && FrmDatVal.length == 6)|| (DateValue.length == 0 && FrmDatVal.length == 6))

	{			//alert(DateValue.length);

		if(DateValue.length!=0)

		{

				if(eval(DateValue.substr(2,4)) < eval(FrmDatVal.substr(2,4)))

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}

				//else if(eval(DateValue.substr(2,4))== eval(FrmDatVal.substr(2,4)))

				{

					if(eval(DateValue.substr(0,2)) < eval(FrmDatVal.substr(0,2)))

					{

						alert("Please enter proper month value.");

						TheFlag = 1;

					}

				}

				

				if(eval(DateValue.substr(2,4)) > ExpDate || eval(DateValue.substr(2,4)) < 1970)

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}

				if(eval(DateValue.substr(0,2)) > 12 || eval(DateValue.substr(0,2)) < 1)

				{

					alert("Please enter proper month value.");

					TheFlag = 1;

				}

		}

		else

		{

			if(eval(FrmDatVal.substr(2,4)) > ExpDate || eval(FrmDatVal.substr(2,4)) < 1970)

				{

					alert("Please enter proper year value.");

					TheFlag = 1;

				}

				if(eval(FrmDatVal.substr(0,2)) > 12 || eval(FrmDatVal.substr(0,2)) < 1)

				{

					alert("Please enter proper month value.");

					TheFlag = 1;

				}	

		}

	}

	else if((DateValue.length == 8 && FrmDatVal.length == 0 )|| (DateValue.length == 8 && FrmDatVal.length == 8)|| (DateValue.length == 0 && FrmDatVal.length == 8))

	{

		if(DateValue.length !=0 )		

		{	

				if(eval(DateValue.substr(4,8)) > ExpDate || eval(DateValue.substr(4,8)) < 1970)

				{

						

						alert("Please enter proper year value.");

						TheFlag = 1;

				}

				else if(eval(DateValue.substr(2,2)) > 12 || eval(DateValue.substr(2,2)) < 1)

				{

						alert("Please enter proper month value.");

						TheFlag = 1;

				}

				else if(eval(DateValue.substr(2,2)) == 1 ||eval(DateValue.substr(2,2))==3 || eval(DateValue.substr(2,2))==5 ||eval(DateValue.substr(2,2))==7 || eval(DateValue.substr(2,2))==8  || eval(DateValue.substr(2,2))==10 || eval(DateValue.substr(2,2))==12)

				{	

						if(eval(DateValue.substr(0,2)) > 31  || eval(DateValue.substr(0,2)) < 1)

							 {

								alert("Please enter proper day's value");

								TheFlag = 1;	

							 }

				}

				else if(eval(DateValue.substr(2,2)) == 2)

				{

					 //=========Added by Richa Bissa on 11th Sep. 2007 

					 //=========To check year value===================

					   if(DateValue.length==6)

					   {

							var Yar=eval(DateValue.substr(2,4));

					   }

					   if(DateValue.length==8)

					   {

							var Yar=eval(DateValue.substr(4,4));

					   }

					 //================================================  

						if(Yar % 4==0)

						{ 

							if(eval(DateValue.substr(0,2)) > 29  || eval(DateValue.substr(0,2)) < 1)

							 { 

								alert("Please enter proper day's value");

								TheFlag = 1;	

							 }

						}

						else if(eval(DateValue.substr(0,2)) > 28  || eval(DateValue.substr(0,2)) < 1)

						{  //alert(eval(DateValue.substr(0,2)));

							alert("Please enter proper day's value");

							TheFlag = 1;	

						}

						

				}

				else if(eval(DateValue.substr(0,2)) > 30  || eval(DateValue.substr(0,2)) < 1)

				 {

						alert("Please enter proper day's value");

						TheFlag = 1;	

				 }

				

				//end

						if(eval(DateValue.substr(4,4)) < eval(FrmDatVal.substr(4,4)))

						{

							alert("Please enter proper year value.");

							TheFlag = 1;

						}

						else if(eval(DateValue.substr(4,4))== eval(FrmDatVal.substr(4,4)))

						{

							

							if(eval(DateValue.substr(2,2)) < eval(FrmDatVal.substr(2,2)))

							{

								alert("Please enter proper month value.");

								TheFlag = 1;

							}

							else if(eval(DateValue.substr(2,2)) == eval(FrmDatVal.substr(2,2)))

							{

								

								if(eval(DateValue.substr(0,2)) <= eval(FrmDatVal.substr(0,2)))

								{	

									alert("Please enter proper day's value");

									TheFlag = 1;

								}

							}

						}

		}

		else

		{

				if(eval(FrmDatVal.substr(4,8)) > ExpDate || eval(FrmDatVal.substr(4,8)) < 1970)

				{

						

						alert("Please enter proper year value.");

						TheFlag = 1;

				}

				else if(eval(FrmDatVal.substr(2,2)) > 12 || eval(FrmDatVal.substr(2,2)) < 1)

				{

						alert("Please enter proper month value.");

						TheFlag = 1;

				}

				else if(eval(FrmDatVal.substr(2,2)) == 1 ||eval(FrmDatVal.substr(2,2))==3 || eval(FrmDatVal.substr(2,2))==5 ||eval(FrmDatVal.substr(2,2))==7 || eval(FrmDatVal.substr(2,2))==8  || eval(FrmDatVal.substr(2,2))==10 || eval(FrmDatVal.substr(2,2))==12)

				{	

						if(eval(FrmDatVal.substr(0,2)) > 31  || eval(FrmDatVal.substr(0,2)) < 1)

							 {

								alert("Please enter proper day's value");

								TheFlag = 1;	

							 }

				}

				else if(eval(FrmDatVal.substr(2,2)) == 2)

				{

						var Yar=eval(FrmDatVal.substr(2,2));

						if(Yar % 4==0)

						{

							if(eval(FrmDatVal.substr(0,2)) > 29  || eval(FrmDatVal.substr(0,2)) < 1)

							 {

								alert("Please enter proper day's value");

								TheFlag = 1;	

							 }

						}

						else if(eval(FrmDatVal.substr(0,2)) > 28  || eval(FrmDatVal.substr(0,2)) < 1)

						{     

							alert("Please enter proper day's value");

							TheFlag = 1;	

						}

						

				}

				else if(eval(FrmDatVal.substr(0,2)) > 30  || eval(FrmDatVal.substr(0,2)) < 1)

				 {

						alert("Please enter proper day's value");

						TheFlag = 1;	

				 }

				

				//end

		}

	}

	else

	{

		alert("Please enter date in right format only.");

		TheFlag = 1;

	}

	

	if(TheFlag == 1)

	{

		DateField.value = '';

		DateField.focus();

		return false;

	}

	else

	{

		var len=DateValue.length;

		if(len== 4)

		{

			

			return DateValue; 

		}

		if(len==6)

		{

			var year=DateValue.substring(len-4,4);

			var mon=DateValue.substring(0,len-4);

			var dat=mon+"/"+year;

			return dat; 

		}

		else

		{	//alert(len);

			var year=DateValue.substring(len-4);

			var mon=DateValue.substring(len-6,len-4);

			var dd=DateValue.substring(0,len-6);

			var dat=dd+"/"+mon+"/"+year;

			

			return dat; 

		}

	}

}*/

//**********************************************

// function for dynamically generate hidden input boxes 

// from URL String i.e. - 

// link.php?var1=value1&var2=value2; - this link will generate 

// 2 hidden boxes with  <input type=hidden name=var1 value=value1><input type=hidden name=var2 value=value2>

		function GenerateHiddenBoxes(urllink,formNam)

		{

			//************************************************

			var URL = urllink.substring(0,urllink.indexOf("?"));

			var QryStr = urllink.substring(urllink.indexOf("?")+1);

			var HidVars = Array();

			var HtmlData='';

			var CtrlFlag ;

			HidVars = QryStr.split("&");

			var i,j;

			var TheFormName = '';	

			var CtrlArr = new Array();

			//************************************************

			//========== set form ===================

			

			if(formNam!='' && formNam!=undefined)

				TheFormName = formNam;

			else

				TheFormName = document.forms[0];

			//************************************************

			//=== pupulate a array of forms existing element ==\\

			for(i=0; i < TheFormName.elements.length; i++)

				CtrlArr[i] =TheFormName.elements[i].name;

			//************************************************

			for(i=0; i < HidVars.length; i++)

			{

				var InnerArr = Array();				

				InnerArr = HidVars[i].split("=");

				//**************************************************				

				//==== checking in existing form eleemnts ========

				//**************************************************				

				CtrlFlag = false; 

				var CtrlIndex = 0;

				for(j=0; j < CtrlArr.length; j++)

				{

					var temp = CtrlArr[j];

					if(temp==InnerArr[0])

					{

						CtrlFlag = true;		

						CtrlIndex = j;

						break;	

					}

						

				}

				//**************************************************

				// if <input> object available in form putting 

				// value in existing input box

				//**************************************************				

				if(CtrlFlag==true)

					TheFormName.elements[CtrlIndex].value = InnerArr[1];

				//**************************************************

				// If control is not available then 

				// Dynamically creating controls and putting values 

				//**************************************************

				else

					//======= splited variable name and thier values ===========

					HtmlData+=" <input style='width:1px;height:1px' type=hidden name='" + InnerArr[0] + "' value='" + InnerArr[1] + "'>";

			}

			//alert(HtmlData);

			document.getElementById('hiddenBox').innerHTML = HtmlData;	

			TheFormName.action=URL;

			//alert(TheFormName.name + " - - - " +  TheFormName.action);

			TheFormName.submit();

		}	





//=============================================================================================================================

//========function SubmitSecureForm used to submit form ==========================================================================

//=============================================================================================================================

//===============modified by teena on 26-07-06=======================//



function SubmitSecureForm(FormName, ActionControl, FormAction)

//function SubmitSecureForm(FormName, FormAction)

{

	//ActionControl.value = FormAction;

	FormName.action = FormAction;

	FormName.submit();

}

//=============================================================================================================================

/**************************************************************************************

************************************************************************************/

//this is OpenSecureWindow() function to open details info file into new page

function OpenSecureWindow()

{

	var FileName = document.securefrm.actval.value;// + "?sbwynum=" + document.securefrm.sbwynum.value;

	Detailinfo = window.open(FileName, "_blank", "height=600, width=800, left=100, top=30, fullscreen=0, menubar=0, scrollbars=1, titlebar=0, toolbar=0, status=1, resizable=1");

}





//===============================================================================================

//added by richa

//======Date validation function=========================

function isDate(val) 

{

 

	var IsValid = 0;

	 if (val.value.length != 0) 

     {

        var longform =  /^[0-9]{2}-[0-1][0-9]-[1-9][0-9]{3}$/;

        if(longform.test(val.value))

		  {

		  		var DateArr = val.value.split("-");

				if(DateArr[0]> 31 || DateArr[1] >12)

					IsValid = 0;

				else

					IsValid = 1;

          }

				  if(IsValid == 0)

				  {

				  	

					  val.value='';

					  alert("Please enter Date in a valid format.");

					 val.focus();

					 return false;

				  }

   }

   

   return true;

}	



//==================================================================================================  



// Function used to check country name is in alphabet

//=========================================================================

 function isAlpha(val,name) 

{

  if (val.value.length != 0)

   {

       for (i = 0; i < val.value.length; i++)

	   {

		   var ch = val.value.charAt(i);

		   if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == " ") || (ch=="-") || (ch==")") || (ch=="(") || (ch==""))

		   {

              continue;

            } 

		   else

		   {

		    val.value='';

            alert("Please enter valid"+" "+ name+" "+"Name"+".");

		    val.focus();

            return false;

           }

       }

    }



   return true;

}

//=======================================================

//..Function to Display scroll tooltip message..if scroller exists....

//========================================================

function ScrollTip()

{

	 if(document.getElementById("searchlisttable"))

	 {

		var TableHeight = document.getElementById("searchlisttable").clientHeight;

		//alert(TableHeight);

		if(eval(TableHeight) > 400)

		{

			document.getElementById("scrolltip").style.display = "inline";

		}

	 }

}

//=======================================================

//=======================================================

 

//=============================================================================================

//Function added by Richa on 20 january 2007 

function isPercentField(theField)

{

  var numFlag=true;



  var countDot=0;



  var ch="";



  var newValue="";



  theField.value=Trimmer(theField.value);



  for(i=0;i<theField.value.length;i++)



   {



     ch=theField.value.charAt(i);



	 if(ch==".")



	  countDot+=1;



     if ((ch >= "0" && ch <= "9") || (ch == ".") || (ch == '-'))



	  {



		  if(countDot>1)



		  {

		   continue;



		  }



		  else



		  {



		   newValue+=ch;  //NEW VALUE OF THE NUMBER

           

		  }	



	  }



	 else



	 {

		continue;



	 } 



   } 



   //====for correct new value==\

   theField.value=newValue;

   if(theField.value==0)

   theField.value='';



}

//==================================================

//Function added by Richa on 20 january 2007 to check the Year

//That is the effective year for the Capacity Significant Extra values added by Admin

function ValidYear(yearval)

{   var Flag=0;

  

		var date = new Date() ;

		Validyear=date.getFullYear()+1;

		if(yearval.value=='')

		{

			Flag=1;

		}

		else

		{	

	

			

				if(yearval.value<Validyear)

				{

						alert("Please enter proper year value.");

						yearval.value='';

						yearval.focus();

						Flag=1;

					  	

				}

			}	





		if(Flag==1)

			return false;

		else

			return true;	

}  

//===================================================================

//Function added by Teena Goswami on 5th May 2007 for the calculation of CGT accordering to th GT Value

//========================================================//

function CGTCal(GTVal,AVal,BVal,DBAvail,SubSeg)

{

	var AlertStr='';

	var CGTVal=0;

	//alert(DBAvail);

	if(AVal!='' && BVal!='' && GTVal!='')

	{

		CGTVal=Math.round(AVal*(Math.pow(GTVal,BVal)));

	

		document.getElementById('cgt').value=CGTVal;

		

	}

	/*else if(DBAvail==false && document.getElementById('wytypid').value!='')	

	{

		if(AVal=='')

			AlertStr+=" A Value";

		if(BVal=='')

		{	

			if(AlertStr!='')

				AlertStr+=" and";

			AlertStr+=" B Value";

		}	

		/*if(GTVal=='')

		{	

			if(AlertStr!='')

				AlertStr+=" and";

			AlertStr+=" Value of GT";

		}	/*

		if(AlertStr!='')

			alert(AlertStr+"  not available for calulating CGT or please select Sub-segment first");

		

	}*/

	else if(SubSeg=='' && GTVal!='')

		alert("Please select Sub-segment first to autocalculate CGT value");

	return true;

}

//====================================================

//===============Added by Richa on 23 Aug 2007 ====

//====To capture the enter event.....

function CaptureEvent(FormContrl)

{

	

	if(event.keyCode=='13')

	{

		//alert('ok');

		//if(FormContrl.type=='button')

		//{

		//	FormContrl.focus();

		//}

		//else

	//	{

			FormContrl.focus();	

			FormContrl.click();

		//}

	}	

}



function CaptureEventText(FormContrl)

{	

	if(event.keyCode=='13')

	{       // alert('ok');

	     return false;

			FormContrl.focus();	

			//FormContrl.click();

	}	

}



//===================================================



function ShowPopup(div)

{

	var dis=document.getElementById(div);

	

		dis.style.display='inline';

		

		dis.style.left = event.clientX + document.body.scrollLeft;

  		dis.style.top =  event.clientY +document.body.scrollTop;

		//dis.scrollLeft=document.body.scrollLeft;

		//dis.style.display='inline';

	

}



function HidePopup(div)

{

		var dis=document.getElementById(div);

	

		dis.style.display='none';

}



function isCharField(theField)

	{

		var notch=0;

		theField.value=Trimmer(theField.value);

			for(i=0;i<theField.value.length;i++)

			{

				ch=theField.value.charAt(i);

				if ((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z") || (ch == " ") || (ch == '-')  || (ch ==""))

				{

					continue;

				}

				else

				{

					notch=1;

				}	

			}

		if(notch==1)

		{

			alert("please enter correct name.");

			theField.value='';

			theField.focus();

			return false;

		} 

	}

	//end of function

	//====================================================================================================

	

	

	//====================================================================================================

	//Added By Swati Vyas on 8 August 08 for WebSite Validation 

	function IsURL ( theField )

	{

		var string = Trimmer(theField.value); 

			if(string != '')

			{

					if ( string.search(/^[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$/) != -1 )

					{

						//alert('Valid URL');

						 return true;

					}

					if ( string.search(/^[http://]+[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$/) != -1 )

					{

			 			//alert('valid URL');

					 	return true;

					}

						alert('Not a valid URL');

			

			theField.value='';			

			theField.focus();

		}  

		else

			return false;

	}

	//end of function	

	//====================================================================================================

	//====================================================================================================

	//Function Added By Swati Vyas on 11 August 08 for Length Validation

	function CheckLength(theField,val)

	{

		if (theField.value.length > val)

		{

			alert("Please enter proper length");

			theField.value='';

			theField.focus();

		}

	}



function OpenURL(URL)

		 {



		 window.open(URL, "_blank", "height=450, width=650, left=180, top=100, fullscreen=0, menubar=0, scrollbars=1, titlebar=0, toolbar=0, status=0, resizable=1");

		

		  }

		  

	

	function Checkuncheck()

	{



		var frmNam = document.forms[0];

		//alert(frmNam);

		var CheckFlag=0;

		var i;

	

		for(i=0; i < frmNam.elements.length; i++)

		{

			if(frmNam.elements[i].type=='checkbox')

	 		{



				if(frmNam.elements[i].checked==true)

				{

				CheckFlag=1;

				//alert(frmNam.elements[i].checked);

				break;

				}

				

			}

			

			//break;

		}

	

		if(CheckFlag==0)

		{

			alert("Please check atleast one shipbuilder");

			frmNam.focus();

			return false;

		}

		else

		{

			for(i=0; i < frmNam.elements.length; i++)

			{

				if(frmNam.elements[i].type=='checkbox')

				{

					

					//alert(frmNam.elements[i].type);

					if(frmNam.elements[i].checked==true)

	 				{

					

						var val=frmNam.elements[i].value;

					

						if(frmNam.compressId.value=='')

						{

							frmNam.compressId.value=val;

						}

						else

						{

							frmNam.compressId.value+=","+val;

						}

						

					}

						

				}

			

			}

			frmNam.savevalues.value=1;

				frmNam.submit();

				return true;

			}	



		}

		

		

//function for enter date is not greater then current date by Pooja Pitti according to Msg-Id[33350,Chat/Eda]		

function futurerestricteddate(date)
{
	var flag=0;
	var ARR_MONTH = ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	var d = new Date();
	var currentdate=d.getDate();
	var currentmonth=d.getMonth();
	var currentyear=d.getFullYear();
	date1=date.value;
	if(date1.length==4)
	{
		if(date1>currentyear)
		{
			flag=1;
		}
	}
	if(date1.length==8)
	{
		var curdate=date1.split('-');
		for(i=0;i<ARR_MONTH.length;i++)
		 {
		   if(curdate[0]==ARR_MONTH[i])
		   {
			 FromMonth=i+1;
		   }
		 }
		 if(curdate[1]>currentyear)
		 {
		 	flag=2;
		 }
		 if(curdate[1]==currentyear && FromMonth>currentmonth+1)
		 {
			 flag=2;
		 }
		 if(curdate[1]>currentyear && FromMonth>currentmonth+1)
		 {
			 flag=2;
		 }
	}	
	if(date1.length==11)
	{
		var curdate=date1.split('-');
		for(i=0;i<ARR_MONTH.length;i++)
		 {
		   if(curdate[1]==ARR_MONTH[i])
		   {
			 FromMonth=i+01;
		   }
		 }
		 if(curdate[2]>currentyear)
		 {
			 flag=3;
		 }
		if(FromMonth>currentmonth+1 && curdate[2]>currentyear)
		{
			flag=3;
		}
		if(curdate[0]>currentdate && FromMonth>currentmonth+1 && curdate[2]>currentyear)
		{
			flag=3;
		}
		if(curdate[0]>currentdate && FromMonth==currentmonth+1 && curdate[2]==currentyear)
		{
			flag=3;
		}
		if(curdate[0]<=currentdate && FromMonth>currentmonth+1 && curdate[2]==currentyear)
		{
			flag=3;
		}
	} 
	if(flag==1)
	{
		alert('Please enter year less then current year');
		date.value='';
		return false;
	}
	else if(flag==2 || flag==3)
	{
		alert('Please enter date less then current date');
		date.value='';
		return false;
	}
	if(flag!='')
	{
		date.focus();
		return false;
	}
	else
	{
		return true;
	}
}		