var mstrBioCookie = 'biotrans';

function changeTransect(transectId, sender)
{
    var blnDoLocation = true;
    
    if(transectId)
    {
        Cookie.set(mstrBioCookie, transectId, 365);

        if ((typeof sender == 'undefined') || (sender == null))
        {
            sender = 'flash';
        }

        if(typeof bioSelectAreaDash != 'undefined')
        {
            if (sender != 'SelectArea')
            {
                bioSelectAreaDash(null, transectId);
            }
        }

        if ((typeof BioDocGrid != 'undefined') && (BioDocGrid != null) && (BioDocGrid.mCheck == true))
        {
            BioDocGrid.mArgs.TransectGuid = transectId;
            BioDocGrid.doGridLoad();
            blnDoLocation = false;
        }
        
        if (typeof newDoc_selArea_change != 'undefined')
        {
            if (sender != 'NewDocument')
            {
                newDoc_selArea_change(null, transectId);

            }
            blnDoLocation = false;
        }
		
        if (blnDoLocation == true)
        {
            document.location.href = mstrAppPath + "transect-results.ashx?Transect=" + transectId;
        }
        else if (sender != 'flash')
        {
            loadTransect(transectId);
        }
    }
}
function loadTransect(transectId)
{
    var map = document.getElementById('flashmap');
    if(map && transectId)
    {
        map.gotoTransectId(transectId);
    }
}
function getTransect()
{	
    var transectId = Cookie.get(mstrBioCookie);
    if (typeof (transectId) != 'undefined' && transectId != null)
    {
        return transectId;
    }
    return '';
}
function restoreTransect() 
{
    var transectId = null; //Cookie.get(mstrBioCookie);
    if(typeof (transectId) != 'undefined' && transectId != null)
    {
		loadTransect(transectId);
    }
}
function clearTransect()
{
	Cookie.set(mstrBioCookie, '', 365);
}

Event.observe(document, 'dom:loaded', function() {
	if(document.location.href.match(/Transect=/))
	{
		loadTransect(getTransect());
	}
});

