function Trim(TRIM_VALUE)

{

	if(TRIM_VALUE.length < 1)

	{

	return"";

	}

	TRIM_VALUE = RTrim(TRIM_VALUE);

	TRIM_VALUE = LTrim(TRIM_VALUE);

	if(TRIM_VALUE=="")

	{

	return "";

	}

	else

	{

	return TRIM_VALUE;

	}

} //End Function



function RTrim(VALUE)

{

	var w_space = String.fromCharCode(32);

	var v_length = VALUE.length;

	var strTemp = "";

	if(v_length < 0)

	{

	return"";

	}

	var iTemp = v_length -1;



	while(iTemp > -1)

	{

	if(VALUE.charAt(iTemp) == w_space)

	{

	}

	else

	{

	strTemp = VALUE.substring(0,iTemp +1);

	break;

	}

	iTemp = iTemp-1;



	} //End While

	return strTemp;



} //End Function



function LTrim(VALUE)

{

	var w_space = String.fromCharCode(32);

	if(v_length < 1)

	{

	return"";

	}

	var v_length = VALUE.length;

	var strTemp = "";



	var iTemp = 0;



	while(iTemp < v_length)

	{

	if(VALUE.charAt(iTemp) == w_space)

	{

	}

	else

	{

	strTemp = VALUE.substring(iTemp,v_length);

	break;

	}

	iTemp = iTemp + 1;

	} //End While

	return strTemp;

} //End Function



// Add date

function DateAdd(mo, dy, yr, ma, da, ya)

{

	var TheDate = parseFloat(mo+ma)+"/"+parseFloat(dy+da)+"/"+parseFloat(yr+ya);				

	Date1 = new Date(TheDate)

	Day=Date1.getDate();				

	Mon=Date1.getMonth()+1;				

	Yr=Date1.getYear();

	if(Yr < 1900)Yr+=1900;

	TheUpDate= Mon + "/" + Day + "/" + Yr;				

	return TheUpDate

}

function CheckDateValidity(day,mon,year)

{

		var dtDate;

		dtDate = new Date(year,mon,day);

		//alert(dtDate);

		return ((day==dtDate.getDate()) && (mon==dtDate.getMonth())&& (year==dtDate.getFullYear()));

}

function clickButton(e, buttonid)

{ 

      var bt = document.getElementById(buttonid); 

      if (typeof bt == 'object'){ 

            if(navigator.appName.indexOf("Netscape")>(-1)){ 

                  if (e.which == 13){ 

                        bt.click(); 

                        return false; 

                  } 

            } 

            if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 

                  if (event.keyCode == 13){ 

                        bt.click(); 

                        return false; 

                  } 

            } 

      } 

} 

//to check valid date

function CheckTheDate(szFromDate)

{



		var dateLength = szFromDate.length;

		validatedate = false

		

		if (dateLength <= 10)

		{

			var iIndexOfSlash = szFromDate.lastIndexOf('/');

			var iYearPart = dateLength - (iIndexOfSlash + 1);	

			

			iIndexOfSlash = szFromDate.lastIndexOf('/');	

			iYearPart = dateLength - (iIndexOfSlash + 1);

			

			if (iYearPart == 4)

			{

				IsValidYear = true;

				var iYear = szFromDate.substr(iIndexOfSlash + 1,4);												

				for(i=(dateLength-1);i>=(iIndexOfSlash + 1);i--)

				{

					if (IsNumber(szFromDate.substr(i,1)) == false)

					{

						IsValidYear = false

					}

				}

				

				if (IsValidYear)

				{

					IsValidDate=true;

					var iIndexOfFirstSlash = szFromDate.indexOf('/');

					var iDay = szFromDate.substr((iIndexOfFirstSlash + 1),(iIndexOfSlash-(iIndexOfFirstSlash+1)));

					

					szFromDate = FormatDate(szFromDate,iIndexOfFirstSlash,iIndexOfSlash)



					iMonth = szFromDate.substr(0,2)

					

					IsValidDate = ValidateMonth(iDay, iMonth, iYear)

					

					if (IsValidDate)

					{

						var fromDate = new Date(szFromDate);	

						if(CheckDateValidity(fromDate.getDate(), fromDate.getMonth(), fromDate.getFullYear()))

						{		

							validatedate = true										

			

						}

						else

						{

							validatedate = false

						}

					}

					else

					{

							validatedate = false

					}

				}

				else

				{

					validatedate = false

				}

			}						

		}	

		return validatedate				



}

//used to check valid date

function ValidateMonth(iDay, iMonth, iYear)

{

	IsValidDate = true;

	if (iMonth == "02")

	{

		if (iDay > 29 || iDay < 1)

		{

			IsValidDate = false;

			

		}

		else if(iDay == 29)

		{

			var szLeapValue = iYear/4;

			if(szLeapValue.toString().indexOf('.') > -1)

			{

				IsValidDate = false;

			}									

		}								

	}

	else if (iMonth == "01" || iMonth == "03" || iMonth == "05" || iMonth == "07" || iMonth == "08" || iMonth == "10" || iMonth == "12") 

	{

		if (iDay > 31 || iDay < 1)

		{

			IsValidDate = false;

			

		}

	}

	else if (iMonth == "04" || iMonth == "06" || iMonth == "09" || iMonth == "11") 

	{

		if (iDay > 30 || iDay < 1)

		{

			IsValidDate = false;

			

		}

	}

	else if (iMonth > "12")									

	{

			IsValidDate = false;								

	}

	return IsValidDate;

	

}



//used to check valid date

function IsNumber(iNumber)

{

	if (iNumber == 1 || iNumber == 2 || iNumber == 3 || iNumber == 4 || iNumber == 5 || iNumber == 6 || iNumber == 7 || iNumber == 8 || iNumber == 9 || iNumber == 0)				

	{

		return true;

	}

	else

	{	

		return false;

	}

}



//Add To Favorites

function AddToFavorites(szFileName,szFilePath)

{

	if (window.sidebar) // firefox

	{	

		alert('Due to security restrictions placed, we are unable to automatically add a bookmark.\nPress CTRL + D to add one manually.')

	}

	else if(document.all) // ie

	{

		window.external.AddFavorite(szFilePath, szFileName);

	}

}



function Findtherightproduct(ques1, ques2, ques3)

		{		

			var szRightProduct;

			if(ques1[1].checked && ques2[1].checked && ques3[1].checked )

			{

				szRightProduct = "Recall;/products/dualfuel/recallincentive.htm";					

			}

			else if (ques1[1].checked && ques2[1].checked && ques3[2].checked )

			{

				szRightProduct = "Recall NYMEX Plus;/products/dualfuel/recallincentive.htm"

				

			}

			else if (ques1[1].checked && ques2[2].checked && ques3[1].checked )

			{

				szRightProduct = "Voluntary Recall;/products/dualfuel/recallincentive.htm"

				

			}

			else if (ques1[1].checked && ques2[2].checked && ques3[2].checked )

			{

				szRightProduct = "Voluntary Recall NYMEX Plus;/products/dualfuel/recallincentive.htm"

				

			}

			else if(ques1[2].checked && ques2[1].checked && ques3[1].checked )

			{

				szRightProduct = "Total Energy;/products/dualfuel/totalenergy.htm";

			

			}

			else if (ques1[2].checked && ques2[1].checked && ques3[2].checked )

			{

				szRightProduct = "Total Energy NYMEX Plus;/products/dualfuel/totalenergy.htm";

				

			}

			else if (ques1[2].checked && ques2[2].checked && ques3[1].checked )

			{

				szRightProduct = "Energy Election;/products/dualfuel/energyelection.htm";

				

			}

			else if (ques1[2].checked && ques2[2].checked && ques3[2].checked )

			{

				szRightProduct = "Energy Election NYMEX Plus;/products/dualfuel/energyelection.htm";

				

			}		

			return 	szRightProduct;

		

	}

	