function getInternetExplorerVersion() {
        var re,ua,rv = -1; // Return value assumes failure.
        if (navigator.appName == 'Microsoft Internet Explorer') {
                ua = navigator.userAgent;
                re = new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})");
                        if (re.exec(ua) != null){
                                rv = parseFloat(RegExp.$1);
                        }
        return rv;
        }
}
function browser(){
        var Browser = "unknown",
        userAgent = navigator.userAgent.toLowerCase();

        if (userAgent.indexOf("opera") > -1){
                Browser="Opera";
        }else if (userAgent.indexOf("konqueror") > -1){
                Browser="Konqueror";
        }else if (userAgent.indexOf("firefox") > -1){
                Browser="firefox";
        }else if (userAgent.indexOf("netscape") > -1){
                Browser="Netscape";
        }else if (userAgent.indexOf("msie") > -1){
                Browser="IE "+ getInternetExplorerVersion();
        }else if (userAgent.indexOf("chrome") > -1){
                Browser="Chrome";
        }else if (userAgent.indexOf("safari") > -1){
                Browser="Safari";
        }
        return Browser;
}

$(document).ready(function(){
	vpHeight = $(window).height();
	vpWidth = $(window).width();
	/*if(vpHeight <= 400 || vpWidth <= 500){
		//window.location='/milkcratemedia/m/m/';
		//show mobile site link
		//alert('view mobile');
	}*/
	$('.wormy').click(function(){
		window.location='http://thelengthofmyday.com/photos/';
	});
/**some layout stuff**/
	//$('.wrapper').css({'margin-top' : '-' + 900 + 0 +'px'});
	$('.imgHolder').css({'height' : vpHeight + 60 +'px'});
	$('.imgWrapper').height(vpHeight - 50 + 'px');
/**/
	$('.thumb').live('click',function(){
		var id = $(this).attr('id');
		$('.imgHolder').load('ajax/ajax.php?id=' + id + '&h=' + vpHeight + '&w=' + vpWidth + '&load=true');//when this is finished loading
		$('.wrapper').animate({'margin-top' : '0px'},'slow');
	});
/**/
	$('.back').live('click',function(){
		//console.log(vpHeight);
		$('.wrapper').animate({'margin-top' : '-' + vpHeight - 60 + 'px'},'slow');
	});
/**/	
	$('.nav').live('click', function(){
		var	pn = $(this).hasClass('next') ? 1 : -1,
		id = parseInt($('.imgHolder').children('img').attr('id'),10) + pn,
		fade = 300;
		
		$('.imgHolder').fadeOut(fade);
		setTimeout(function(){
		$('.imgHolder').load('ajax/ajax.php?id=' + id + '&h=' + vpHeight + '&w=' + vpWidth + '&np=true');//when this is finished loading
			$('.imgHolder').fadeIn(fade);
		},fade);		
	});
/**/	
	//preloader in hrr....
	$(window).load(function(){
		//bring up the photos;
		$('.subWrapper').hide();
		$('.wrapper').show();
	});
	$('.logo').click(function(){
		$('.inLogo').toggle(300);
		$('.headTitle').toggle(300);		
	});
	$('.nav, .back, .thumb').click(function(){
		$('.inLogo').hide(300);
	});
	//some shitty ie stuff
	if(browser()=='IE 7'){
		$('.thumb').css({'display':'inline','zoom':'1'});
	}else{
		$('.thumb').css({'display':'inline-block'});
	}
});

