function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		
		home1b_27_over = newImage("/images/home1b_27_over.jpg");
		home1b_28_over = newImage("/images/home1b_28_over.jpg");
		home1b_29_over = newImage("/images/home1b_29_over.jpg");
		home1b_30_over = newImage("/images/home1b_30_over.jpg");
		home1b_31_over = newImage("/images/home_test_on.jpg");
		home1b_32_over = newImage("/images/home1b_32_over.jpg");
		home1b_33_over = newImage("/images/home1b_33_over.jpg");
		home_upcoming_over = newImage("/images/nav_book_on.jpg");
		preloadFlag = true;
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


var $j = jQuery.noConflict();
$j(document).ready(function(){

	$j("div.katieIntro").click(function() {
		window.location = "http://glennplaskin.com/katie_up_and_down_the_hall.html"

	});
	$j("a.showVideo").click(function() {
			return hs.htmlExpand(this, { objectType: 'swf', contentId: 'my-video', allowSizeReduction: true, slideshowGroup: null, width: 633, objectWidth: 633, objectHeight: 356, maincontentText: 'You need to upgrade or install your Flash player', swfOptions: { version: '9', flashvars: { file: "/Katie.flv", bufferLength: "5", controlbar: "over", volume: "40", icons: "false", autostart: "true", mute: "false" }, params: { allowfullscreen: "true", allowscriptaccess: "always", wmode: "transparent" } }  } )
			pageTracker._trackPageview("/home/katietrailer/framed");
	 });
	$j("a.showVideo2").click(function() {
			return hs.htmlExpand(this, { objectType: 'swf', contentId: 'my-video2', allowSizeReduction: true, slideshowGroup: null, width: 633, objectWidth: 633, objectHeight: 356, maincontentText: 'You need to upgrade or install your Flash player', swfOptions: { version: '9', flashvars: { file: "/Katie.flv", bufferLength: "5", controlbar: "over", volume: "40", icons: "false", autostart: "true", mute: "false" }, params: { allowfullscreen: "true", allowscriptaccess: "always", wmode: "transparent" } }  } )
			pageTracker._trackPageview("/home/katietrailer/inline");
	 });


	

	$j(".publishedBooks span").hide();
	$j(".publishedBooks a.turningLink").hover( 
		function () {
			$j(".turningTip").css("display", "block");
		}, 
		function () {
			$j(".turningTip").hide();
		}
	);

	$j(".publishedBooks a.horowitzLink").hover( 
		function () {
			$j(".horowitzTip").css("display", "block");
		}, 
		function () {
			$j(".horowitzTip").hide();
		}
	);
	$j(".videoTip").hide();
	$j("#my-video").each(function() {
		$j(this).hover(
			function() {
				$j(".highslide-controls").hide();												
				$j(this).find(".videoTip").show();												
			},
			function() {
				$j(".highslide-controls").hide();														
				$j(this).find(".videoTip").hide();												
			}
		);
	});
	$j("#my-video2").each(function() {
		$j(this).hover(
			function() {
				$j(".highslide-controls").hide();												
				$j(this).find(".videoTip").show();												
			},
			function() {
				$j(".highslide-controls").hide();														
				$j(this).find(".videoTip").hide();												
			}
		);
	});

	
	swfobject.embedSWF("/jim.swf", "homeAdvert", "199", "184", "9.0.0", null, null, {wmode: "transparent", quality: "high"}, null);
	swfobject.embedSWF("/scrolling-fullheadline-black-lg-glow.swf", "replaceHeadlines", "545", "169", "9.0.0", null, null, { wmode: "transparent", quality: "high", pluginspage: 'http://www.adobe.com/go/getflashplayer', align: 'middle', play: 'true', loop: 'false', id: "headlineObj", wmode: 'transparent', bgcolor: '#ffffff', allowFullScreen: 'false', allowScriptAccess: 'sameDomain', headlineText: 'Celebrity Interviews, Biographies, Human Interest, Inspiration' }, null);

	if ( $j("#scrollingHeader").children("span")) {
		$j("#scrollingHeader span").each(function() {
				$j(this).css("opacity", "0.0");
		});

		$j("#scrollingHeader span").eq(0).animate({opacity: "0.0"}, 2000).animate({opacity: "1.0"}, 2000);
		$j("#scrollingHeader span").eq(1).animate({opacity: "0.0"}, 4000).animate({opacity: "1.0"}, 2000);
		$j("#scrollingHeader span").eq(2).animate({opacity: "0.0"}, 6000).animate({opacity: "1.0"}, 2000);
		$j("#scrollingHeader span").eq(3).animate({opacity: "0.0"}, 8000).animate({opacity: "1.0"}, 2000);
	}
	
	//Follow icons
	$j("#followLinks a").hover(
		function() {
			$j("#followLinks > span").css( { opacity: 0, filter: 'alpha(opacity=0)' });
			$j(this).siblings("div").css( { opacity: 0, filter: 'alpha(opacity=0)' } ).stop( ).fadeTo( 500, 1 );												
		},
		function() {
			$j(this).siblings("div").css( { opacity: 1, filter: 'alpha(opacity=100)' } ).fadeTo( 500, 0 );														
			$j("#followLinks > span").css( { opacity: 1, filter: 'alpha(opacity=100)' });

}
	);

	
	preloadImages();
	

});

