﻿var IsPopUp = false;
//debugger;
var IsPostBack = false;
window.onbeforeunload = EnableExcellenceSearchBar;
//window.onload = DisableExcellenceSearchBar;
function EnableExcellenceSearchBar()
{
	IsPostBack = true;
	PopulateSearchBar();
}

//var IsExcellence = false;
function CreatePopup()
{
	if (!window.createPopup)return; 
	
	IsPopUp = true;
	var m_oPopup = window.createPopup();			
	var oPopupBody = m_oPopup.document.body;
	oPopupBody.style.backgroundColor = 'white';
	oPopupBody.style.color			 = '#023A73';
	oPopupBody.style.border			 = 'solid black 1px';    
	oPopupBody.style.fontSize		 = '12px';
	oPopupBody.style.fontFamily 	 = 'Verdana, Arial';
	oPopupBody.style.padding		 = '10px'; 
	//oPopupBody.innerHTML = "<CENTER><center><OBJECT codeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' height='32' width='32' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' VIEWASTEXT><PARAM NAME='_cx' VALUE='847'><PARAM NAME='_cy' VALUE='847'><PARAM NAME='FlashVars' VALUE=''><PARAM NAME='Movie' VALUE='/phoenix/images/loading.swf'><PARAM NAME='Src' VALUE='/phoenix/images/loading.swf'><PARAM NAME='WMode' VALUE='Transparent'><PARAM NAME='Play' VALUE='-1'><PARAM NAME='Loop' VALUE='-1'><PARAM NAME='Quality' VALUE='High'><PARAM NAME='SAlign' VALUE=''><PARAM NAME='Menu' VALUE='-1'><PARAM NAME='Base' VALUE=''><PARAM NAME='AllowScriptAccess' VALUE=''><PARAM NAME='Scale' VALUE='ShowAll'><PARAM NAME='DeviceFont' VALUE='0'><PARAM NAME='EmbedMovie' VALUE='0'><PARAM NAME='BGColor' VALUE=''><PARAM NAME='SWRemote' VALUE=''><PARAM NAME='MovieData' VALUE=''><PARAM NAME='SeamlessTabbing' VALUE='1'><PARAM NAME='Profile' VALUE='0'><PARAM NAME='ProfileAddress' VALUE=''><PARAM NAME='ProfilePort' VALUE='0'><PARAM NAME='AllowNetworking' VALUE='all'><embed src='loading.swf' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='32' height='32'> </embed></OBJECT></center><center><img src='/phoenix/images/hebrew/loading_text.gif' border='0'/></center>";
	oPopupBody.innerHTML = "<br/><center><img src='/PhoenixMarketing/images/Excellence/Loading.gif' border='0'/><br/>אנא המתן</center>";
	m_oPopup.show((screen.availWidth-220)/2, (screen.availHeight-35)/2, 180, 80);
}
/*
function CreatePopup()
{
	IsPopUp = true;
	var	oDiv = document.createElement('div');
	oDiv.style.left = '300px';
	oDiv.style.right = '300px';
	oDiv.style.top = '300px';
	oDiv.style.height = '300px';
	oDiv.style.width = '300px';
	oDiv.style.position = 'absolute';
	
	oDiv.innerHTML = "<CENTER><OBJECT codeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' height='32' width='32' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' VIEWASTEXT><PARAM NAME='_cx' VALUE='847'><PARAM NAME='_cy' VALUE='847'><PARAM NAME='FlashVars' VALUE=''><PARAM NAME='Movie' VALUE='/phoenix/images/loading.swf'><PARAM NAME='Src' VALUE='/phoenix/images/loading.swf'><PARAM NAME='WMode' VALUE='Transparent'><PARAM NAME='Play' VALUE='-1'><PARAM NAME='Loop' VALUE='-1'><PARAM NAME='Quality' VALUE='High'><PARAM NAME='SAlign' VALUE=''><PARAM NAME='Menu' VALUE='-1'><PARAM NAME='Base' VALUE=''><PARAM NAME='AllowScriptAccess' VALUE=''><PARAM NAME='Scale' VALUE='ShowAll'><PARAM NAME='DeviceFont' VALUE='0'><PARAM NAME='EmbedMovie' VALUE='0'><PARAM NAME='BGColor' VALUE=''><PARAM NAME='SWRemote' VALUE=''><PARAM NAME='MovieData' VALUE=''><PARAM NAME='SeamlessTabbing' VALUE='1'><PARAM NAME='Profile' VALUE='0'><PARAM NAME='ProfileAddress' VALUE=''><PARAM NAME='ProfilePort' VALUE='0'><PARAM NAME='AllowNetworking' VALUE='all'><embed src='loading.swf' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='32' height='32'> </embed></OBJECT></CENTER><center><span class='RegularText'>בטעינה</span></center>";
	document.body.appendChild(oDiv);
	
	
	var m_oPopup = window.createPopup();			
	var oPopupBody = m_oPopup.document.body;
	oPopupBody.style.backgroundColor = 'white';
	oPopupBody.style.color			 = '#023A73';
	oPopupBody.style.border			 = 'solid black 1px';    
	oPopupBody.style.fontSize		 = '12px';
	oPopupBody.style.fontFamily 	 = 'Verdana, Arial';
	oPopupBody.style.padding		 = '10px'; 
	oPopupBody.innerHTML = "<CENTER><OBJECT codeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' height='32' width='32' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' VIEWASTEXT><PARAM NAME='_cx' VALUE='847'><PARAM NAME='_cy' VALUE='847'><PARAM NAME='FlashVars' VALUE=''><PARAM NAME='Movie' VALUE='/phoenix/images/loading.swf'><PARAM NAME='Src' VALUE='/phoenix/images/loading.swf'><PARAM NAME='WMode' VALUE='Transparent'><PARAM NAME='Play' VALUE='-1'><PARAM NAME='Loop' VALUE='-1'><PARAM NAME='Quality' VALUE='High'><PARAM NAME='SAlign' VALUE=''><PARAM NAME='Menu' VALUE='-1'><PARAM NAME='Base' VALUE=''><PARAM NAME='AllowScriptAccess' VALUE=''><PARAM NAME='Scale' VALUE='ShowAll'><PARAM NAME='DeviceFont' VALUE='0'><PARAM NAME='EmbedMovie' VALUE='0'><PARAM NAME='BGColor' VALUE=''><PARAM NAME='SWRemote' VALUE=''><PARAM NAME='MovieData' VALUE=''><PARAM NAME='SeamlessTabbing' VALUE='1'><PARAM NAME='Profile' VALUE='0'><PARAM NAME='ProfileAddress' VALUE=''><PARAM NAME='ProfilePort' VALUE='0'><PARAM NAME='AllowNetworking' VALUE='all'><embed src='loading.swf' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='32' height='32'> </embed></OBJECT></CENTER><center>בטעינה</center>";
	m_oPopup.show((screen.availWidth-220)/2, (screen.availHeight-35)/2, 180, 80);
	
}
*/
function CheckPopUp()
{
	if(IsPopUp)
		CreatePopup();
}
function CheckSerchFields(ComperGraph_ID,RiskGraph_ID,TableView_ID,FromDate_ID,ToDate_ID,Periods_ID,ErrorMSG_ID,IsExcellence)
{

// Client ID Objects
var ComperGraph = document.getElementById(ComperGraph_ID);
var TableView = document.getElementById(TableView_ID);
var RiskGraph = document.getElementById(RiskGraph_ID);
var Periods = document.getElementById(Periods_ID);
var FromDate = document.getElementById(FromDate_ID);
var ToDate = document.getElementById(ToDate_ID);
var tdErrorMSG  = document.getElementById(ErrorMSG_ID);
var ServerErrorMessages = document.getElementById("ServerErrorMessages");
//ServerErrorMessages.innerHTML = "";
tdErrorMSG.innerHTML = "";

//alert(FromDateValue.getDate() +364);

	if(ComperGraph.checked == false && TableView.checked == false && RiskGraph.checked == false)		
	{		
		tdErrorMSG.innerHTML = "<span><li/> יש לבחור לפחות אחת מתיבות הבחירה</span>";
		return false;
	}	
		
	// if the periods combo is empty	
	if(Periods.value == "0")
	{
		//checked if the textbox is empty
		if(FromDate.value == "")
		{
			tdErrorMSG.innerHTML = "<span><li/> יש לבחור תאריך בשדה מ:</span>";
			return false;
		}
		//checked if the textbox is empty
		else if(ToDate.value == "")	
		{
			tdErrorMSG.innerHTML = "<span><li/> יש לבחור תאריך בשדה עד:</span>";
			return false;
		}
		
		
		// set the date values
		var ToDateValue = ToDate.value;
		var FromDateValue = FromDate.value;

		// START ******* Change the date format and set a new date 
		var strFromDate = new String(FromDateValue)
		var FromDateArray = strFromDate.split('/');

		var strToDate = new String(ToDateValue)
		var ToDateArray = strToDate.split('/');

		var ToDateValue = new Date(ToDateArray[2] + "/" + ToDateArray[1] + "/" +ToDateArray[0]);
		var FromDateValue = new Date(FromDateArray[2] + "/" + FromDateArray[1] + "/" +FromDateArray[0]);

		// set today date 
		var today = new Date();

		// END ******* Change the date format and set a new date 
		
		
				
		//checked if the textbox value is biger then today date
		if(Math.round((FromDateValue - today)/(1000*60*60*24)) >= 0)
		{
			tdErrorMSG.innerHTML = "<span><li/> אין לבחור תאריך עתידי</span>";
			HidePage1Results();
			return false;
		}
		
		//checked if the textbox value is biger then today date
		else if (Math.round((ToDateValue - today)/(1000*60*60*24))> 0)
		{
			tdErrorMSG.innerHTML = "<span><li/> תאריך עד צריך להיות קטן או שווה לתאריך הנוכחי</span>";
			HidePage1Results();
			return false;
		}
		
		//checked if the between the dates ther is at least 3 mounth
		if(ToDateValue < FromDateValue)
		{
			tdErrorMSG.innerHTML = "<span><li/> תאריך מ- צריך להיות קטן מתאריך עד</span>";
			HidePage1Results();
			return false;
		}
		//debugger;		
		//checked if the between the dates ther is at least 3 mounth

			if(Math.round((ToDateValue - FromDateValue)/(1000*60*60*24)) <= 90)
			{
				if(IsExcellence == "0")
				{
					tdErrorMSG.innerHTML = "<span><li/> יש לבחור הפרש של 3 חודשים לפחות בין התאריכים</span>";
					HidePage1Results();
					return false;
				}
				else if(IsExcellence == "1")
				{
					return true;
				}
			}
	}	
	FromDate.setAttribute('disabled',false);
	ToDate.setAttribute('disabled',false);
	FromDate.style.color = '#a9a9a9';
	ToDate.style.color = '#a9a9a9';
	CreatePopup();
}

function EnableDisableDatesControls(SelectedValue,FromDateControlID,ToDateControlID)
{
	//debugger;
 
	var imgFromDateElement = document.getElementById(document.getElementById(FromDateControlID).parentNode.parentNode.childNodes[1].childNodes[0].id);
	 var imgToDateElement = document.getElementById(document.getElementById(ToDateControlID).parentNode.parentNode.childNodes[1].childNodes[0].id);
	if(IsExcellence && IsPostBack)
	{
		
		document.getElementById(FromDateControlID).style.backgroundColor = 'white';
		document.getElementById(FromDateControlID).setAttribute('readonly',false);
		document.getElementById(FromDateControlID).setAttribute('disabled',false);
		document.getElementById(ToDateControlID).style.backgroundColor = 'white';
		document.getElementById(ToDateControlID).setAttribute('readonly',false);
		document.getElementById(ToDateControlID).setAttribute('disabled',false);
		if(imgFromDateElement!=null){
		 
			imgFromDateElement.setAttribute('readonly',false);
			imgFromDateElement.removeAttribute('disabled');
		}
		if (imgToDateElement!=null){
			imgToDateElement.setAttribute('readonly',false);
			imgToDateElement.removeAttribute('disabled');
		}
	}
	else
	{
//		if(SelectedValue == 0 && IsExcellence != "1")
//		{
		
			document.getElementById(FromDateControlID).style.backgroundColor = 'white';
			document.getElementById(FromDateControlID).setAttribute('readonly',false);
			document.getElementById(FromDateControlID).setAttribute('disabled',false);
			document.getElementById(ToDateControlID).style.backgroundColor = 'white';
			document.getElementById(ToDateControlID).setAttribute('readonly',false);
			document.getElementById(ToDateControlID).setAttribute('disabled',false);
			if (imgFromDateElement!=null){
				imgFromDateElement.setAttribute('readonly',false);
				imgFromDateElement.removeAttribute('disabled');
			}
			if (imgToDateElement!=null){
				imgToDateElement.setAttribute('readonly',false);
				imgToDateElement.removeAttribute('disabled');
			}
//		}
//		else
//		{
//			document.getElementById(FromDateControlID).style.backgroundColor = 'gainsboro';
//			document.getElementById(FromDateControlID).setAttribute('readonly',true);
//			document.getElementById(FromDateControlID).setAttribute('disabled',true);
//			document.getElementById(ToDateControlID).style.backgroundColor = 'gainsboro';
//			document.getElementById(ToDateControlID).setAttribute('readonly',true);
//			document.getElementById(ToDateControlID).setAttribute('disabled',true);
//			imgFromDateElement.setAttribute('readonly',true);
//			imgFromDateElement.setAttribute('disabled',true);
//			imgToDateElement.setAttribute('readonly',true);
//			imgToDateElement.setAttribute('disabled',true);
//		}
	}
}
function PopulateSearchBar()
{
	//debugger;
	var searchbar = document.getElementById("searchbar");
	if(searchbar != null)
	{
	    var dropdown = searchbar.getElementsByTagName('select');
	    var fromtodate = searchbar.getElementsByTagName('input');
	    if(dropdown[0].selectedIndex != -1)
	    {
	        var selected = dropdown[0].options[dropdown[0].selectedIndex].value;
	        EnableDisableDatesControls(selected,fromtodate[0].id,fromtodate[1].id);
	    }
	}
}
//Calculators Step2 - Fund Box JS
function EnableIndexesComparison(me,DropDownID)
{
	if(me.checked==true)
	{
		document.getElementById(DropDownID).disabled=false;
	}
	else
	{
		document.getElementById(DropDownID).disabled=true;
	}
}
function EnableIndexesComparisons()
{
	var i;
	var ProceedComparisonBoxes = document.getElementById("ProceedComparisonBoxes");
	var boxes = ProceedComparisonBoxes.getElementsByTagName("div");
	for(i=0;i<boxes.length;i++)
	{
		var dropdown = boxes[i].getElementsByTagName('select');
		var checkbox = boxes[i].getElementsByTagName('input');
		if(checkbox.length>0)
		{
			if(checkbox[0].checked==true)
			{
				dropdown[0].disabled = false;
			}
			else
			{
				dropdown[0].disabled = true;
			}
		}
	}
}

function ClearServerErrorMessage()
{
	var ServerErrorMessagesTag = document.getElementById('ServerErrorMessages');
	var ServerErrorMessagesValue = ServerErrorMessagesTag.getElementsByTagName('span');
	if(ServerErrorMessagesValue.length>0)
		ServerErrorMessagesValue[0].innerHTML = '';
}
function CheckSearchFields2(FromDate_ID,ToDate_ID,Periods_ID,ErrorMSG_ID,DepositCB_ID,Deposit_ID)
{
// Client ID Objects
var DepositCB = document.getElementById(DepositCB_ID)
var Deposit = document.getElementById(Deposit_ID)
var Periods = document.getElementById(Periods_ID);
var FromDate = document.getElementById(FromDate_ID);
var ToDate = document.getElementById(ToDate_ID);
var tdErrorMSG  = document.getElementById(ErrorMSG_ID);
var oServerErrorMessages = document.getElementById('ServerErrorMessages');
ClearServerErrorMessage();
//tdErrorMSG.innerHTML = "";


	if (DepositCB.checked && Deposit.value=="")
	{
		tdErrorMSG.innerHTML = "<span><li/> יש להזין ערך בשדה הפקדה</span>";
		oServerErrorMessages.style.visibility = "visible";
		return false;
	}
		
	// if the periods combo is empty	
	if(Periods.value == "0")
	{
		//checked if the textbox is empty
		if(FromDate.value == "")
		{
			tdErrorMSG.innerHTML = "<span><li/> יש לבחור תאריך בשדה מ:</span>";
			oServerErrorMessages.style.visibility = "visible";
			HidePage3Results();
			return false;
		}
		//checked if the textbox is empty
		else if(ToDate.value == "")	
		{
			tdErrorMSG.innerHTML = "<span><li/> יש לבחור תאריך בשדה עד:</span>";
			oServerErrorMessages.style.visibility = "visible";
			HidePage3Results();
			return false;
		}
		
		
		// set the date values
		var ToDateValue = ToDate.value;
		var FromDateValue = FromDate.value;

		// START ******* Change the date format and set a new date 
		var strFromDate = new String(FromDateValue)
		var FromDateArray = strFromDate.split('/');

		var strToDate = new String(ToDateValue)
		var ToDateArray = strToDate.split('/');

		var ToDateValue = new Date(ToDateArray[2] + "/" + ToDateArray[1] + "/" +ToDateArray[0]);
		var FromDateValue = new Date(FromDateArray[2] + "/" + FromDateArray[1] + "/" +FromDateArray[0]);

		// set today date 
		var today = new Date();

		// END ******* Change the date format and set a new date 
		
		
				
		//checked if the textbox value is biger then today date
		
		if(Math.round((FromDateValue - today)/(1000*60*60*24)) >= 0)
		{
			tdErrorMSG.innerHTML = "<span><li/> אין לבחור תאריך עתידי</span>";
			oServerErrorMessages.style.visibility = "visible";
			HidePage3Results();
			return false;
		}
		
		//checked if the textbox value is biger then today date
		else if (Math.round((ToDateValue - today)/(1000*60*60*24))> 0)
		{
			tdErrorMSG.innerHTML = "<span><li/> תאריך עד צריך להיות קטן או שווה לתאריך הנוכחי</span>";
			oServerErrorMessages.style.visibility = "visible";
			HidePage3Results();
			return false;
		}
				
		//checked if the between the dates ther is at least 3 mounth
		if(!IsExcellence)
		{
			if(Math.round((ToDateValue - FromDateValue)/(1000*60*60*24)) <= 90)
			{
				tdErrorMSG.innerHTML = "<span><li/> יש לבחור הפרש של 3 חודשים לפחות בין התאריכים</span>";
				oServerErrorMessages.style.visibility = "visible";
				HidePage3Results();
				return false;
			}
		}
	}
	FromDate.removeAttribute('disabled');
	ToDate.removeAttribute('disabled');
	FromDate.style.color = '#a9a9a9';
	ToDate.style.color = '#a9a9a9';
	
	
	CreatePopup();
}


	function EnableDisableDepositField(CheckBox,DepositBoxID)
	{
		if(CheckBox.checked == true)
		{
			document.getElementById(DepositBoxID).removeAttribute('disabled');
			document.getElementById(DepositBoxID).style.backgroundColor = 'white';
		}
		else
		{
			
			document.getElementById(DepositBoxID).style.backgroundColor = 'gainsboro';
			document.getElementById(DepositBoxID).setAttribute('disabled',true);
		}
		
	}
function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
  for (i = 0; i < sText.length && IsNumber == true; i++) 
  { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
  }
   return IsNumber;
   
   }

	
//olga new exellance 26-08-2008
function CheckSearchFields3(FromDate_ID,ToDate_ID, ErrorMSG_ID, Deposit_ID)
{
//debugger;
// Client ID Objects
//var DepositCB = document.getElementById(DepositCB_ID)
var Deposit = document.getElementById(Deposit_ID)
//var Periods = document.getElementById(Periods_ID);
var FromDate = document.getElementById(FromDate_ID);
var ToDate = document.getElementById(ToDate_ID);

var tdErrorMSG  = document.getElementById(ErrorMSG_ID);
ClearServerErrorMessage();
//tdErrorMSG.innerHTML = "";

	if (Deposit.value=="")
	{
		tdErrorMSG.innerHTML = "יש להזין ערך בשדה הפקדה";
		return false;
	}
	
	if(!IsNumeric(Deposit.value))
	{
	    tdErrorMSG.innerHTML = "ניתן להקליד ספרות בלבד בשדה ההפקדה";
		return false;
	}
		
	// if the periods combo is empty	
	//if(Periods.value == "0")
	//{
		//checked if the textbox is empty
		if(FromDate.value == "")
		{
			tdErrorMSG.innerHTML = "<span><li/> יש לבחור תאריך בשדה מ:</span>";
			HidePage3Results();
			return false;
		}
		//checked if the textbox is empty
		else if(ToDate.value == "")	
		{
			tdErrorMSG.innerHTML = "<span><li/> יש לבחור תאריך בשדה עד:</span>";
			HidePage3Results();
			return false;
		}
		
		
		// set the date values
		var ToDateValue = ToDate.value;
		var FromDateValue = FromDate.value;

		// START ******* Change the date format and set a new date 
		var strFromDate = new String(FromDateValue)
		var FromDateArray = strFromDate.split('/');

		var strToDate = new String(ToDateValue)
		var ToDateArray = strToDate.split('/');

		var ToDateValue = new Date(ToDateArray[2] + "/" + ToDateArray[1] + "/" +ToDateArray[0]);
		var FromDateValue = new Date(FromDateArray[2] + "/" + FromDateArray[1] + "/" +FromDateArray[0]);

		// set today date 
		var today = new Date();

		// END ******* Change the date format and set a new date 
		
		
				
		//checked if the textbox value is biger then today date
		
		if(Math.round((FromDateValue - today)/(1000*60*60*24)) >= 0)
		{
			tdErrorMSG.innerHTML = "<span><li/> אין לבחור תאריך עתידי</span>";
			HidePage3Results();
			return false;
		}
		
		//checked if the textbox value is biger then today date
		else if (Math.round((ToDateValue - today)/(1000*60*60*24))> 0)
		{
			tdErrorMSG.innerHTML = "<span><li/> תאריך עד צריך להיות קטן או שווה לתאריך הנוכחי</span>";
			HidePage3Results();
			return false;
		}
				
		//checked if the between the dates ther is at least 3 mounth
		if(!IsExcellence)
		{
			if(Math.round((ToDateValue - FromDateValue)/(1000*60*60*24)) <= 90)
			{
				tdErrorMSG.innerHTML = "<span><li/> יש לבחור הפרש של 3 חודשים לפחות בין התאריכים</span>";
				HidePage3Results();
				return false;
			}
		}
//	}

	FromDate.removeAttribute('disabled');
	ToDate.removeAttribute('disabled');
	FromDate.style.color = '#a9a9a9';
	ToDate.style.color = '#a9a9a9';
	
	CreatePopup();
}
function DatesValidation(FromDate_ID,ToDate_ID,Periods_ID,ErrorMSG_ID)
	{
	// Client ID Objects
	var Periods = document.getElementById(Periods_ID);
	var FromDate = document.getElementById(FromDate_ID);
	var ToDate = document.getElementById(ToDate_ID);
	var tdErrorMSG  = document.getElementById(ErrorMSG_ID);
	var ServerErrorMessages = document.getElementById("ServerErrorMessages");
	ServerErrorMessages.innerHTML = "";	

	tdErrorMSG.innerHTML = "";

	if(Periods.value == "0")
	{
		//checked if the textbox is empty
		if(FromDate.value == "")
		{
			tdErrorMSG.innerHTML = "<span><li/> יש לבחור תאריך בשדה מ:</span>";
			return false;
		}
		//checked if the textbox is empty
		else if(ToDate.value == "")	
		{
			tdErrorMSG.innerHTML = "<span><li/> יש לבחור תאריך בשדה עד:</span>";
			return false;
		}
		
		
		// set the date values
		var ToDateValue = ToDate.value;
		var FromDateValue = FromDate.value;

		// START ******* Change the date format and set a new date 
		var strFromDate = new String(FromDateValue)
		var FromDateArray = strFromDate.split('/');

		var strToDate = new String(ToDateValue)
		var ToDateArray = strToDate.split('/');

		var ToDateValue = new Date(ToDateArray[2] + "/" + ToDateArray[1] + "/" +ToDateArray[0]);
		var FromDateValue = new Date(FromDateArray[2] + "/" + FromDateArray[1] + "/" +FromDateArray[0]);

		// set today date 
		var today = new Date();

		// END ******* Change the date format and set a new date 
		
		
				
		//checked if the textbox value is biger then today date
		if(Math.round((FromDateValue - today)/(1000*60*60*24)) >= 0)
		{
			tdErrorMSG.innerHTML = "<span><li/>אין לבחור תאריך עתידי</span>";
			HidePage2Results();
			return false;
		}
		
		//checked if the textbox value is biger then today date
		else if (Math.round((ToDateValue - today)/(1000*60*60*24))> 0)
		{
			tdErrorMSG.innerHTML = "<span><li/> תאריך עד צריך להיות קטן או שווה לתאריך הנוכחי</span>";
			HidePage2Results();
			return false;
		}
		
		//checked if the between the dates ther is at least 3 mounth
		if(ToDateValue < FromDateValue)
		{
			tdErrorMSG.innerHTML = "<span><li/> תאריך מ- צריך להיות קטן מתאריך עד</span>";
			HidePage2Results();
			return false;
		}
				
		//checked if the between the dates ther is at least 3 mounth
		if(!IsExcellence)
		{
			if(Math.round((ToDateValue - FromDateValue)/(1000*60*60*24)) <= 90)
			{
				tdErrorMSG.innerHTML = "<span><li/> יש לבחור הפרש של 3 חודשים לפחות בין התאריכים</span>";
				HidePage2Results();
				return false;
			}
		}		
		
	}	
	FromDate.removeAttribute('disabled');
	ToDate.removeAttribute('disabled');
	FromDate.style.color = '#a9a9a9';
	ToDate.style.color = '#a9a9a9';
	CreatePopup();
}
function HidePage1Results()
{
	var DetailsTable = document.getElementById("DetailsTable");
	var ProfitCompareChart = document.getElementById("ProfitCompareChart");
	var ProfitVersChart = document.getElementById("ProfitVersChart");
	if(DetailsTable!=null)
		DetailsTable.style.display = "none";
	if(ProfitCompareChart!=null)
		ProfitCompareChart.style.display = "none";
	if(ProfitVersChart!=null)
		ProfitVersChart.style.display = "none";
}
function HidePage2Results()
{
	var ProceedComparisonBoxesTable = document.getElementById("ProceedComparisonBoxesTable");
	if(ProceedComparisonBoxesTable!=null)
		ProceedComparisonBoxesTable.style.display = "none";
}
function HidePage3Results()
{
	var ResultsArea = document.getElementById("ResultsArea");
	var TablesResultsArea = document.getElementById("TablesResultsArea");
	var GridReslutsArea = document.getElementById("GridReslutsArea");
	
	if(ResultsArea!=null)
		ResultsArea.style.display = "none";
	if(TablesResultsArea!=null)
		TablesResultsArea.style.display = "none";
	if(GridReslutsArea!=null)
		GridReslutsArea.style.display = "none";
}

function ClearExPage (depositBox, ErrorMSG_ID, ValidadorID)
{
    HidePage3Results();
    ClearServerErrorMessage();
    ClearWeight();
    
    var tdErrorMSG  = document.getElementById(ErrorMSG_ID);
    if(tdErrorMSG!=null)
        tdErrorMSG.style.display = "none";
    
	var ServerErrorMessages = document.getElementById("ServerErrorMessages");
	if(ServerErrorMessages!=null)
	    ServerErrorMessages.style.display = "none";
	    
	var txtDepositBox  = document.getElementById(depositBox);
    if(txtDepositBox!=null)
        txtDepositBox.value = "";
        
    var Validador  = document.getElementById(ValidadorID);
    if(Validador!=null)
        Validador.style.display = "none";
    
}