﻿// JScript File


// TEXT RESIZER START

// make new date object
// set it 30 days ahead
var exp = new Date();                                   
exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 30)); 

// This function saves a cookie
// requires name, value and expires
function setCookie(name, value, expires) {
document.cookie = name + "=" + escape(value) + "; path=/" + ((expires == null) ? "" : "; expires=" + expires.toGMTString());
}

// This function retrieves a cookie
// requires name
function getCookie (name) {
    var cname = name + "=";               
    var dc = document.cookie;

    if (dc.length > 0) {              
	    begin = dc.indexOf(cname);       
		    if (begin != -1) {           
		    begin += cname.length;       
		    end = dc.indexOf(";", begin);
			    if (end == -1) end = dc.length;
			    //alert(unescape(dc.substring(begin, end)));
			    return unescape(dc.substring(begin, end));
		    } 
	    }
    return null;
}

// This function sets font to default
// requires saveCookie (true||false)
        function onResizeNormal(saveCookie) {
        try
          {
            var obResize = document.getElementById("Sizable");
                obResize.className = 'ResizeNormal';
                if (saveCookie == true)
                {
                    var text_size = 'normal';
                    setCookie('textSize',text_size, exp);
                }
          }
        catch(err)
          {
          //txt="There was an error on this page.\n\n"
          //txt+="Error description: " + "This page has no resizable text" + "\n\n"
          txt="This page has no resizable text" + "\n\n"
          txt+="Click OK to continue.\n\n"
          alert(txt)
          }
        }

// This function sets font to larger
// requires saveCookie (true||false)
        function onResizeLarger(saveCookie) {
        try
          {
            var obResize = document.getElementById("Sizable");
                obResize.className = 'ResizeLarger';
                if (saveCookie == true)
                {
                    var text_size = 'larger';
                    setCookie('textSize',text_size, exp);
                }
          }
        catch(err)
          {
          //txt="There was an error on this page.\n\n"
          //txt+="Error description: " + "This page has no resizable text" + "\n\n"
          txt="This page has no resizable text" + "\n\n"
          txt+="Click OK to continue.\n\n"
          alert(txt)
          }

        }

// This function toggles font size and control display
// requires resize (true||false)
function ToggleResizerText(resize)
{
	var ob = document.getElementById("resizerlink");
	var obPlus = document.getElementById("plus");
	var obMinus = document.getElementById("minus");
    
	if (ob.innerHTML == "&nbsp;Increase Text Size&nbsp;&nbsp;")
	{
	    if (resize)
	    {
		    onResizeLarger(true);
		}
	    ob.innerHTML = "Display Normal Text&nbsp;";
	    obPlus.style.display = 'none';
	    obMinus.style.display = 'inline';
	}
	else
	{
	    if (resize)
	    {
	        onResizeNormal(true);
	    }
		ob.innerHTML = "&nbsp;Increase Text Size&nbsp;&nbsp;";
		obPlus.style.display = 'inline';
		obMinus.style.display = 'none';
	}
}


// Call after page has loaded 
// reads cookie and resizes accordingly
//window.onload=function()
function TextInit()
{
    if ( getCookie ( "textSize" ) )
    {
    
        var text_size = getCookie ("textSize");
        if ( text_size == 'larger' )
        {
            onResizeLarger(false);
            ToggleResizerText(false);
        }
    }
}


// TEXT RESIZER END

// COLUMN RESIZER START

/*   ------------------------------------------------  PVII Equal CSS Columns scripts -Version 2  Copyright (c) 2005 Project Seven Development  www.projectseven.com  Version: 2.1.0  ------------------------------------------------*/

/* 
  ------------------------------------------------
  PVII Equal CSS Columns scripts -Version 2
  Copyright (c) 2005 Project Seven Development
  www.projectseven.com
  Version: 2.1.0
  ------------------------------------------------
*/
//The onLoad call contains the animation option (1=yes, 0=no) 
//and then lists the target DIVs and the tags we wish to use 
//in parentheses, separated by commas: 'c1','P','c2','P'. 
//These are called the arguments. They are the IDs of the DIVs 
//you want to set to equal height. In this example, you want a 
//DIV with an ID of c1 and another DIV with an ID of c2 to be 
//set to equal height, using paragraph 'P' tags as the object to meaure against.

function P7_colH2()
{ //v2.1.0 by PVII-www.projectseven.com
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;
 if(dA&&dA.length)
 {
    for(i=1;i<dA.length;i+=2)
    {
        dA[i+1].style.paddingBottom='';
    }
    for(i=1;i<dA.length;i+=2)
    {
        oh=dA[i].offsetHeight;
        h=(oh>h)?oh:h;
    }
    for(i=1;i<dA.length;i+=2)
    {
        oh=dA[i].offsetHeight;
        if(oh<h)
        {
            np=h-oh;
            if(!an&&dA[0]==1)
            {
            
                if (dA[i].id == "main_banner")
                {
                    
                    var topMainBanner = findPos(dA[i])[1];
                    var topWelcome = findPos(document.getElementById('welcome'))[1];
                    
                    P7_eqA2(dA[i+1].id,0,np-(topMainBanner-topWelcome));
                }
                else                
                    P7_eqA2(dA[i+1].id,0,np);
            }
            else
            {
                dA[i+1].style.paddingBottom=np+"px";
            }
        }
    }
    document.p7eqa=1;
    document.p7eqth=document.body.offsetHeight;
    document.p7eqtw=document.body.offsetWidth;
  }
}
function P7_eqT2()
{ //v2.1.0 by PVII-www.projectseven.com
    if( document.p7eqth != document.body.offsetHeight || 
        document.p7eqtw != document.body.offsetWidth )
        {
            P7_colH2();
        }
}
function P7_equalCols2()
{ 
 //v2.1.0 by PVII-www.projectseven.com
 var c,e,el;
 if(document.getElementById)
 {
    document.p7eqc=new Array();
    document.p7eqc[0] = arguments[0];
    for(i=1;i<arguments.length;i+=2)
    {
        el=null;
        c=document.getElementById(arguments[i]);
        
        if(c)
        {            
            e=c.getElementsByTagName(arguments[i+1]);
            if(e)
            {
                el=e[e.length-1];
                if(!el.id)
                {
                    el.id="p7eq"+i;
                }
            }
        }
        if(c&&el)
        {
            document.p7eqc[document.p7eqc.length] = c;
            document.p7eqc[document.p7eqc.length] = el
        }
    }
    setInterval("P7_eqT2()",10);
  }
}
function P7_eqA2(el,p,pt)
{ //v2.1.0 by PVII-www.projectseven.com
 var sp=10, inc=20, g=document.getElementById(el);
 np = (p>=pt) ? pt : p;
 g.style.paddingBottom = np+"px";
 if(np<pt)
    {
        np+=inc;
        setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);
    }
}

// COLUMN RESIZER END

// OBJECT POSITIONING

function rePos(obj,obj2) 
{
    try
    {
	    var obj1 = document.getElementById(obj);
	    var obj2 = document.getElementById(obj2);
	    var curleft = curtop = 0;
	    if (obj1.offsetParent) {
			    curleft = obj1.offsetLeft
			    curtop = obj1.offsetTop
			    while (obj1 = obj1.offsetParent) {
					    curleft += obj1.offsetLeft
					    curtop += obj1.offsetTop
			    }
	    }

	    obj2.style.left = curleft + 520;
	    obj2.style.top = curtop + 180;
    }
    catch(err)
    {return false;}
}

window.onresize = function () 
{
    rePos('int_main_content','ctl00_CallToActionButton_btnCallToAction');
}

// OBJECT POSITIONING END

// DESTINATIONS REDIRECTION

function redirectCity()
{
    var objCity = document.getElementById("city_dropdown");
    var fileName = objCity.value.toLowerCase();

    //window.location.href = "/destinations/cities/" + fileName + ".aspx";
    window.location.href = "/destinations/destination-results.aspx?type=city&id=" + fileName;
}

function redirectState()
{
    var objState = document.getElementById("state_dropdown");
    var fileName = objState.value.toLowerCase();
    
    //window.location.href = "/destinations/states/" + fileName + ".aspx";
    window.location.href = "/destinations/destination-results.aspx?type=state&id=" + fileName;

}

// DESTINATIONS REDIRECTION END

function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) 
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) 
		{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

