var $j = jQuery,
	$tb = tbelt;

var Page = {};	

//sets the rollover/rollout image for a nav item
function navRollOver(navImage, rollTo){
	var navImage;
	
	if(navImage){
		
		if(rollTo=="over"){
			basePath = navImage.src.substr(0,navImage.src.lastIndexOf(".gif"));
			navImage.src=basePath+"-over.gif";
		}else{
			
			basePath = navImage.src.substr(0,navImage.src.lastIndexOf("-over"));
			navImage.src=basePath+".gif";
		}
		//alert(navImage.src);
	}
}

//search site from header input
function searchSite(){
	searchInput = document.getElementById('siteSearchInput');
	
	if(searchInput && searchInput.value!="" && searchInput.value!="Search"){
		window.location="http://www.weingarten.com/search/?q="+searchInput.value;
	}else{
		alert('Please enter a valid search criteria.');
	}
}


//set the style for the Marketing Package on property detail pages
function marketingPackageStyle(){
	
	var linkMP = $j("#siteLeftNav a.menuLink:contains('Marketing Package')");
	if(linkMP.length>0){
		//add the style to the <li/>
		linkMP.closest("li").addClass("divider");
		//redirect the user to the detail page
		linkMP.click(function(evt){
			window.location='info.aspx';
		});
		
	}
}

// sets a cookie
function SetCookie( cookieName, cookieValue ) 
{
    document.cookie = cookieName + "=" + escape( cookieValue ) + ";path=/;";
}

// deletes a cookie
function DeleteCookie ( cookieName )
{
    document.cookie = cookieName + "=;expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

// reads a cookie
function ReadCookie( cookieName ) 
{
    var theCookie = "" + document.cookie;
    var ind = theCookie.indexOf( cookieName );
    
    if( ind == -1 || cookieName == "" ) 
        return ""; 
        
    var ind1 = theCookie.indexOf( ';' ,ind );
    
    if( ind1 == -1 ) 
        ind1 = theCookie.length; 
        
    return unescape( theCookie.substring( ind+cookieName.length+1, ind1 ) );
}

