jQuery.event.add(window, "load", resizeFrame);
jQuery.event.add(window, "resize", resizeFrame);

function resizeFrame() 
{
    var h = $(window).height();
    var w = $(window).width() - 268;
    
    if (w < 795) { 
    	$("#blogContainer").css('left',795); 
    }
    else {
    	$("#blogContainer").css('left',w);     
    }        
    
    if ($('#blogContainer').hasClass('blogOff')) {    
    	$("#blogContainer").css('height',18);
    }
    else {
    	$("#blogContainer").css('height',h);
    }     
}

$(document).ready(function(){		

	var img_width = $('#exhi_image_nav').width();
	var back_width = img_width - 71;
	$('#exhi_image_nav .nav_back_item').width(back_width);		
	
	$('.hfh_artist_bio table tr td:even').css("text-align", "left");	
	
	$('.changeling').hover(
		function() {
			var src = $(this).attr('src');
			if (src.search('Lachs') == -1) {
				var newSrc = src.replace('.gif','_Lachs.gif');
				$(this).attr('src',newSrc);
			}
			else {
				var newSrc = src.replace('_Lachs.gif','.gif');
				$(this).attr('src',newSrc);
			}
		},
		function() {
			var src = $(this).attr('src');
			if (src.search('Lachs') == -1) {
				var newSrc = src.replace('.gif','_Lachs.gif');
				$(this).attr('src',newSrc);
			}
			else {
				var newSrc = src.replace('_Lachs.gif','.gif');
				$(this).attr('src',newSrc);
			}
		}
	);
	
    var cookieStatus = GetCookie('hideBlog');
    if ((cookieStatus == 1) && ($('#blogContainer').hasClass('blogOn'))) {
    	$('#blogContainer').toggleClass('blogOn').addClass('blogOff');
    }
    
    
   $('#blogToggler').click(function() {    
        $('#blogContainer').toggleClass('blogOn').toggleClass('blogOff');
        var h = $(window).height();
   	if ($('#blogContainer').hasClass('blogOff')) {
   		SetCookie('hideBlog', 1, 4, '/', 'homefromhome-page.com', '');
                $("#blogContainer").css('height',18);
   	}
   	else {
   		SetCookie('hideBlog', 0, 4, '/', 'homefromhome-page.com', '');
                $("#blogContainer").css('height',h);
   	}
   });        
   
   $('#blogContainer .blog_entry:last').addClass('blog_entry_last');	
	

var trans = window.location.href;
var alt = $('#mainNav_2 span:last a img').attr('alt');

if (alt == "English") { trans = trans.concat("&L=2"); }
if (alt == "Deutsch") { trans = trans.replace('&L=2',''); }
$('#mainNav_2 span:last a').attr('href',trans);


});

function roImage(str) {

	$('.imgChange img').attr('src',str);
	
}

function chImage(id,str) {
	$('#'+id+' img').attr('src',str);	
}

function SetCookie( name, value, expires, path, domain, secure )
{
	var today = new Date();
	today.setTime( today.getTime() );

	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" : "" );
}


function GetCookie( check_name ) {
	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++ )
	{		
		a_temp_cookie = a_all_cookies[i].split( '=' );
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}




