//Delete_Cookie("CCSA_CCS_StepMod2");

function CheckSteps()
{
    if ((Get_Cookie("CCSA_CCS_SKIP")!="true"))
    {
        var Step = Get_Cookie("CCSA_CCS_StepMod2");
        switch (Step)
        {
            case null:
                Set_Cookie("CCSA_CCS_StepMod2", "0", 2000);
                window.location = "cc_search.html";
                break;
            case "1":
                if (window.location.href.indexOf("stepone.html") < 0) window.location = "stepone.html";
                break;
            case "2":
                if (window.location.href.indexOf("steptwo.html") < 0) window.location = "steptwo.html";
                break;
            case "3":
                if (window.location.href.indexOf("stepthree.html") < 0) window.location = "stepthree.html";
                break;
            case "4":
                if (window.location.href.indexOf("stepfour.html") < 0) window.location = "stepfour.html";
                break;
            case "5":
                if (window.location.href.indexOf("stepfive.html") < 0) window.location = "stepfive.html";
                break;
            case "6":
                if (window.location.href.indexOf("stepsix.html") < 0) window.location = "stepsix.html";
                break;
            case "7":
                if (window.location.href.indexOf("stepseven.html") < 0) window.location = "stepseven.html";
                break;
            case "8":
                if (window.location.href.indexOf("conclusion.html") < 0) window.location = "conclusion.html";
                break;
                
        }
    }
    Set_Cookie("CCSA_CCS_SKIP", "false");
}

function PreviousStep(CurrentStep)
{
    if (CurrentStep=="0")
    {
        Set_Cookie("CCSA_CCS_SKIP", "true");
        window.location = "cc_search.html";
    }
}

function NextStep(CurrentStep)
{
    var Step = Get_Cookie("CCSA_CCS_StepMod2");
    switch (CurrentStep)
    {
        case "0":
            if (parseInt(Step) <= 0) Set_Cookie("CCSA_CCS_StepMod2", "1", 2000);
            window.location = "stepone.html";
            break;
        case "1":
            if (parseInt(Step) <= 1) Set_Cookie("CCSA_CCS_StepMod2", "2", 2000);
            window.location = "steptwo.html";
            break;
        case "2":
            if (parseInt(Step) <= 2) Set_Cookie("CCSA_CCS_StepMod2", "3", 2000);
            window.location = "stepthree.html";
            break;
        case "3":
            if (parseInt(Step) <= 3) Set_Cookie("CCSA_CCS_StepMod2", "4", 2000);
            window.location = "stepfour.html";
            break;
        case "4":
            if (parseInt(Step) <= 4) Set_Cookie("CCSA_CCS_StepMod2", "5", 2000);
            window.location = "stepfive.html";
            break;
        case "5":
            if (parseInt(Step) <= 5) Set_Cookie("CCSA_CCS_StepMod2", "6", 2000);
            window.location = "stepsix.html";
            break;
        case "6":
            if (parseInt(Step) <= 6) Set_Cookie("CCSA_CCS_StepMod2", "7", 2000);
            window.location = "stepseven.html";
            break;
        case "7":
            if (parseInt(Step) <= 7) Set_Cookie("CCSA_CCS_StepMod2", "8", 2000);
            window.location = "conclusion.html";
            break;
    }
}

function setIframeHeight(iframeName) 
{
    var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
    if (iframeEl) 
    {
        iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
        var h = alertSize();
        var new_h = (h-148);
        iframeEl.style.height = new_h + "px";
    }
}

function setIframeFocus(iframeName)
{
    var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
    if (iframeEl) 
    {
        iframeE1.setFocus();
    }
}

function setIframeLocation(iframeName)
{
    var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
    iframeEl.src = "http://naccrraware.childcareservices.org/naccrrajsp/servlet/naccrra.servlets.MaskSearchServlet?pid=2lsa8epq8s7yylf";
}

function alertSize() {
		  var myHeight = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myHeight = window.innerHeight;
		  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		    //IE 6+ in 'standards compliant mode'
		    myHeight = document.documentElement.clientHeight;
		  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		    //IE 4 compatible
		    myHeight = document.body.clientHeight;
		  }
		  //window.alert( 'Height = ' + myHeight );
		  return myHeight;
		}


function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

// this fixes an issue with the old method, ambiguous values 
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}				
						
// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
	


