/*********************************************************
This JavaScript file contains all the Functions 
that are used by the application. 
Created By Syntel 0n 07/14/2006
*********************************************************/
/*
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'Modification Log
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'CHG No.	Date			Changed By ID	Description
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'CHG1		10/16/2006		VBV0125			maskKeyPressForZipCode function added to restrict user from entering
'											values other then numbers.
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
//Functions used in index.asp File. Start ---

function refreshControl()
{
	
	document.getElementById('OptionState').value=1
}

function showTheDiv(item,intRecordCount)
{
	var i=1;
	
	// Previous 
	if(item == 0)
	{
		i=1;
		var sval;
		
		if (document.getElementById('OptionState').value == "")
		{document.getElementById('OptionState').value=1}
		
		sval=document.getElementById('OptionState').value;

		
		if (sval == 1)
		{
			for (i == 1; i <= intRecordCount; i++)
			{
					document.getElementById('Item_' + i).src='/images/dotOFF.gif';
					document.getElementById('Div_' + i).style.display = 'none';				
			}
			
			document.getElementById('Item_' + (intRecordCount)).src='/images/dotON.gif';
			document.getElementById('Div_' + (intRecordCount)).style.display = 'block';
			document.getElementById('OptionState').value = intRecordCount;
		}
		else
		{
			for (i == 1; i <= intRecordCount; i++)
			{
					document.getElementById('Item_' + i).src='/images/dotOFF.gif';
					document.getElementById('Div_' + i).style.display = 'none';				
			}
			
			
			
			document.getElementById('Item_' + (sval-1)).src='/images/dotON.gif';
			document.getElementById('Div_' + (sval-1)).style.display = 'block';
			document.getElementById('OptionState').value = sval-1;		
				
		}
		
		
	}
	
	// Next 
	if(item == 100)
	{
		i=1;
		var sval;
		
		if (document.getElementById('OptionState').value == "")
		{document.getElementById('OptionState').value=1}
		
		sval=document.getElementById('OptionState').value;
		
		
		
		if (sval == intRecordCount)
		{
		
			for (i == 1; i <= intRecordCount; i++)
			{
					document.getElementById('Item_' + i).src='/images/dotOFF.gif';
					document.getElementById('Div_' + i).style.display = 'none';		
						
			}
			
			sval= eval(sval)+1;
			
			document.getElementById('Item_' + 1).src='/images/dotON.gif';
			document.getElementById('Div_' + 1).style.display = 'block';
			document.getElementById('OptionState').value = 1;
		}
		else
		{
			for (i == 1; i <= intRecordCount; i++)
			{
					document.getElementById('Item_' + i).src='/images/dotOFF.gif';
					document.getElementById('Div_' + i).style.display = 'none';		
						
			}
			
			sval= eval(sval)+1;
			
			document.getElementById('Item_' + sval).src='/images/dotON.gif';
			document.getElementById('Div_' + sval).style.display = 'block';
			document.getElementById('OptionState').value = sval;	
					
					
		}

		
	}

	
	if(item != 0 && item != 100)
	{
		i=1;
		for (i == 1; i <= intRecordCount; i++)
		{
		document.getElementById('Item_' + i).src='/images/dotOFF.gif';
		document.getElementById('Div_' + i).style.display = 'none';
			
		}
	
		document.getElementById('Item_' + item).src='/images/dotON.gif';
		document.getElementById('Div_' + item).style.display = 'block';
		document.getElementById('OptionState').value = item;	
	}

}


function open_window(url)
{
var win;
//if (win && !win.closed)
//	win.location.replace(url);
//else
	win = window.open(url,"Message","toolbar=1,location=1,directories=0,center=yes, status=1,menubar=1,scrollbars=yes,resizable=yes,left=110,top=30,width=830,height=570");
win.focus();
}
			
function Verify()
{
var msg = "Important information \n\n";
//msg = msg + "Please note, the enrollment period for prescription drug plans ends at midnight local time on May 15, 2006. Your enrollment must be submitted before midnight local time.\n\n";
//msg = msg + "If your completed enrollment is received after midnight local time, the Centers for Medicare & Medicaid Services (CMS) may consider it invalid and reject it.\n\n"
//msg = msg + "Click OK to Continue or click CANCEL to return to the previous page."

msg = msg + "Please note, the enrollment period for Medicare Advantage plans ends at midnight local time on June 30, 2006.\n";
msg = msg + "Your enrollment must be submitted before midnight local time.\n\n";
msg = msg + "If your completed enrollment is received after midnight local time, the Centers for Medicare & Medicaid Services\n";
msg = msg + "(CMS) may consider it invalid and reject it.\n\n";
msg = msg + "Click OK to Continue or click CANCEL to return to the previous page."

return confirm(msg);
}
			
var win1;
var canclick='N';

function ValidateForm_Index()
{	alert('44');
	if (canclick == 'Y') 
	{	alert('55');
		//document.FontSize.submit();
		alert('66');
		return true;
		
	}		
	else
	{  
		return false;
	}
}


function IgnoreEvents(e)
{
  return false;
}
 
function ShowWindow1()
{   
  if (window.showModalDialog)
  {
	//win1 = window.showModalDialog("zipcodePopup1.asp",window,"dialogHeight=22;dialogWidth=43;dialogTop=50;dialogLeft=50;center=yes;resizable=yes;")
	win1 = window.showModalDialog("/includes/zipcodeIncludePopup.asp",window,"dialogHeight=22;dialogWidth=23;center=yes;resizable=yes;")
	//ValidateForm();
  }
  else
  {      
    window.top.captureEvents (Event.CLICK|Event.FOCUS)
    window.top.onclick=IgnoreEvents
    window.top.onfocus=HandleFocus 
     
    win1 = window.open ("/includes/zipcodeIncludePopup.asp","ModalChild",
       "dependent=yes,width=250,height=250,left=0,top=0,location=no,resizable=yes,scrollbars=yes")
    
    if (win1.opener == null) win1.opener = self;   
    
    win1.focus(); 
    
    
   
  }
 if (canclick == 'Y')
		return true;
  else
	return false;
	
  
}



function HandleFocus()
{
  if (win1)
  {
    if (!win1.closed)
    {
      win1.focus()
    }
    else
    {
      window.top.releaseEvents (Event.CLICK|Event.FOCUS)
      window.top.onclick = ""
    }
  }
return false;
} 
//Functions used in index.asp File. -- END



//Functions used in medicare-product-guide.asp File. -- Start

function ValidateForm(form)
{  
	return validateForm(form, false, true, false, true, 25);
	
}

//Functions used in medicare-product-guide.asp File. -- End


//Functions used in optout.asp File. -- Start

function viewStatusWindow(sURL)
{
	var newWindow;
	bg_color="FFFFFF"; // optional background color of the popup window
	bg_img=""; // optional background image for the popup window
	// complete url needed
	newWindow=window.open("https://"+sURL+"/privacy/getStatus.php" + "?bg=" + bg_color + "&im=" + bg_img,"popup1","resizeable,width=500,height=400");
}
function optResultWindow(f,sURL)
{
	// destination_opt_out - url of the page that is displayed in
	// the pop up window after the opt-out cookie is set
	destination_opt_out="https://"+sURL+"/privacy/optout.html";
	// destination_anonymous - url of the page that is displayed in
	// the pop up window after the anonymous cookie is set
	destination_anonymous="https://"+sURL+"/privacy/anonymous.html";
	// destination_cancel - url of the page that is displayed in
	// the pop up window after the cancel cookie is set
	destination_cancel="https://"+sURL+"/privacy/cancel.html";
	if (f.action[0].checked )
	{
		ac = "anonymous";
		destination = destination_anonymous;
	}
	if (f.action[1].checked )
	{
		ac = "opt_out";
		destination = destination_opt_out;
	}
	if (f.action[2].checked )
	{
		ac = "optin";
		destination = destination_cancel;
	}
	newWindow=window.open("https://"+sURL+"/privacy/privacy_handler.php" + "?dest=" + destination + "&act=" + ac,"popup1","resizeable,width=500,height=400");
}
function setStatus(msg)
{
	status = msg;
	return true;
}
	
//Functions used in optout.asp File. -- End


//Functions used in Header_Main.asp

var oeFAQ;
var oeGlossary;
var oeFooterWin;
	

function oeOpenWin(win,url,title)
{
	if (win && !win.closed)
		win.location.replace(url);
	else
		win = window.open(url,title,'dependant=yes,location=no,menubar=false,resizable=yes,scrollbars=yes,status=false,toolbar=false,width=700,height=500,left=100,top=20,screenX=0,screenY=10,outerwidth=800,outerheight=430',true);
		
	win.focus();
	//if win.opener().close() win.close();
	return win;
}
	
function gotoGlossary(glossarySection)
{
	//var url = '<%=Application("URLSecuredRoot")%>/Enroll/Glossary.asp';
	var url = '<%=Application("URLUnSecuredRoot")%>/medicare-plans-glossary.asp';
	if (typeof largeCSS == 'boolean') url += '?largecss=' + largeCSS.toString();
	if (glossarySection!='') url += '#' + glossarySection;
	oeGlossary = oeOpenWin(oeGlossary,url,'Glossary');
}
	
function gotoFAQ(faqSection)
{
	//var url = '<%=Application("URLSecuredRoot")%>/Enroll/FAQ.asp';
	var url = '<%=Application("URLUnSecuredRoot")%>/medicare-supplement-faq.asp';
	if (typeof largeCSS == 'boolean') url += '?largecss=' + largeCSS.toString();
	if (faqSection!='') url += '#' + faqSection;
	oeFAQ = oeOpenWin(oeFAQ,url,'FAQ');
}
	
function gotoFooterWin(url,title)
{
	oeFooterWin = oeOpenWin(oeFooterWin,url,title);
}
	
function oeCloseWin()
{
	if (oeFAQ && !oeFAQ.closed) oeFAQ.close();
	if (oeGlossary && !oeGlossary.closed) oeGlossary.close();
	if (oeFooterWin && !oeFooterWin.closed) oeFooterWin.close();
	return true;
}
//CHG1 - STARTS
function maskKeyPressForZipCode(evt) 
{
  
  var keyCode = evt.which ? evt.which : evt.keyCode;               
  if((keyCode>=48 && keyCode<=57) || keyCode == 8 || keyCode == 13 ) return true;// 8 - backspace, 9 - h tab, 11 - v tab, 46 - Delete, 45 is dash
  return false;
}
//CHG1 - ENDS