$(document).ready(function(){
	//set up the lightbox on the portfolio page
	$('#lightboxOverlay').hide();
	$('#lightboxContentWrap').hide();

	$('#showPortfolio').click(function() {
		_showLightbox();
		return false;
	});

	$('#lightboxOverlay').click(function() {
		log("OverlayClicked");
		_closeLightbox()
	});
	$('#lightboxContentWrap').click(function() {
		log("WrapClicked");
		_closeLightbox()
	});
	
	$('#lightboxContentWrap').css('top', ($(window).height()-$('#lightboxContentWrap').height())/2);
	
});  


// ------------------------------------------------------------------------------------
$(document).ready(function() {
    $('#contactForm input, #contactForm textarea').each(function() {

        if ($(this).val() == "" || $(this).val() == $(this).parent('label').find('span').text()) {
            $(this).val($(this).parent('label').find('span').text()).addClass('defaultText');
        }

        $(this).focus(function() {
            if ($(this).val() == $(this).parent('label').find('span').text()) {
                $(this).val("").removeClass('defaultText');
            }
			$(this).toggleClass('focus');
        });
        $(this).blur(function() {
            if ($(this).val() == "") {
                $(this).val($(this).parent('label').find('span').text()).addClass('defaultText');
            }
			$(this).toggleClass('focus');
        });
    });

    $('#contactForm p.contactSubmit a').click(function() {
        $('#contactForm input, #contactForm textarea').each(function() {
            if ($(this).val() == $(this).parent('label').find('span').text()) {
                $(this).val("")
            }
        });
    });
});


// javascript calls to the flash
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return document.getElementById(movieName); //window[movieName];
    }
    else {
        return document[movieName];
    }
};

// ------------------------------------------------------------------------------------
$(document).ready(function() {

    $('#prevButton').click(function() {
        thisMovie("flashReplace").prevTrack();
        return false;
    });
    $('#nextButton').click(function() {
        thisMovie("flashReplace").nextTrack();
        return false;
    });
});

// ------------------------------------------------------------------------------------
function _showLightbox() {
	log("_showlightbox()");
	
	$('#lightboxOverlay').show();
	$('#lightboxContentWrap').show();

};

// ------------------------------------------------------------------------------------
function _closeLightbox() {
	log("_closeLightbox()");
	$('#lightboxOverlay').hide();
	$('#lightboxContentWrap').hide();
};
// ------------------------------------------------------------------------------------
function log(logText) {
	try {
		console.log(logText)
		}
	catch(err) {
		//alert(logText);
		}
	};

// ------------------------------------------------------------------------------------
	$(document).ready(function() {
	    resizeText();
	    $(window).resize(function() {
	        resizeText();
	    });
	});


	// ------------------------------------------------------------------------------------
	function resizeText() {
	    var height = $(this).height();
	    var width = $(this).width();

	    // these define the border between small and medium
	    var heightLimit = 800;
	    var widthLimit = 1024;
	    // these define the border between medium and large
	    var heightMidLimit = 800;
	    var widthMidLimit = 1400;


	    if (height < heightLimit || width < widthLimit) {
	        //small
	        //$('#TextDebug').html('small<br />H: ' + height + '<br />W: ' + width);
	        $('div.primaryNav a').css('font-size', '24px').css('line-height', '19px');
	        $('#home div.primaryNav a, div.primaryNav .active, p.contactResponse, #home p.artist, #home p.artist a').css('font-size', '42px').css('line-height', '34px').css('letter-spacing', '-3pt');
	        $('#home p.artist').css('font-size', '42px').css('line-height', '34px');
	        $('h2, #home p.intro').css('font-size', '18px').css('line-height', '19px').css('letter-spacing','0.1pt');
	        $('#home h1, h1 a').css('background', 'url(../images/ui/logoSmall.gif) 0px 0px no-repeat');

	    }
	    else if (height < heightMidLimit || width < widthMidLimit) {
	        //medium
	        //$('#TextDebug').html('medium<br />H: ' + height + '<br />W: ' + width);
	        $('div.primaryNav a').css('font-size', '24px').css('line-height', '19px');
	        $('#home div.primaryNav a, div.primaryNav .active, p.contactResponse, #home p.artist, #home p.artist a').css('font-size', '60px').css('line-height', '45px').css('letter-spacing', '-4pt');
	        $('#home p.artist').css('font-size', '60px').css('line-height', '45px');
	        $('h2, #home p.intro').css('font-size', '24px').css('line-height', '19px').css('letter-spacing', '0.02pt');
	        $('#home h1, h1 a').css('background', 'url(../images/ui/logoSmall.gif) 0px 0px no-repeat');

	    }
	    else {
	        //large
	        //$('#TextDebug').html('large<br />H: ' + height + '<br />W: ' + width);
	        $('div.primaryNav a').css('font-size', '30px').css('line-height', '24px');
	        $('#home div.primaryNav a, div.primaryNav .active, p.contactResponse, #home p.artist, #home p.artist a').css('font-size', '75px').css('line-height', '59px').css('letter-spacing', '-4pt');
	        $('h2, #home p.intro').css('font-size', '30px').css('line-height', '26px').css('letter-spacing', '0.01pt');
	        $('#home h1, h1 a').css('background', 'url(../images/ui/logo.gif) 0px 0px no-repeat');
	        }
	    };

	    // ------------------------------------------------------------------------------------
	    $(document).ready(function() {
	        //$('body').append('<div id="TextDebug" style="position:absolute;width:200px;height:100px;z-index:800;background:#999;border:1px solid #000;top:0px;right:0px;text-align:center;"></div>');
	        //	$('body').append('<div id="TextDebug" style="position:absolute;width:200px;height:100px;z-index:800;background:#999;border:1px solid #000;top:0px;right:0px;text-align:center;"><input type="text" id="textDebugInput" style="margin:10px;" /><br /><input type="submit" value="Change Font" id="textDebugSubmit" /></div>');
	        //  $('#textDebugSubmit').click(function() {
	        //		$('html').css('font-family', $('#textDebugInput').val());
	        //		$('body').css('font-family', $('#textDebugInput').val());
	        //		$('#contactForm textarea').css('font-family', $('#textDebugInput').val());
	        //		$('#contactForm div.errorMessages li').css('font-family', $('#textDebugInput').val());
	        //	});
	    });
