﻿// When document first loads
$("document").ready(function(){
	$("ul.navbar li").hoverIntent({
		over: showIt, 
		out: hideIt
	});
});

function showIt() {
	var liMenu = $(this);
	var divMenu = $(liMenu).find('div.menushow');
	if (divMenu == null) return;
	
	// Get parent object
	var pst = $(liMenu).position();
	
	// Set a.img.src attribute
	var imgObject = $(liMenu).find('a img');
	imgObject.attr('src', '/Images/CarrotDark.png');
	
	// Calculate new position
	pst.top += 22;
	var wdt = divMenu.width();
	if (divMenu.width() > 800)
		pst.left -= 540;
	else if (divMenu.width() > 400)
		pst.left -= 200;
	else
		pst.left -= 10;
	
	// Show the div.menushow object
	$(divMenu).css({top: pst.top, left: pst.left});
	$(divMenu).slideToggle("fast");
}

function hideIt() {
	var liMenu = $(this);
	var divMenu = $(liMenu).find('div.menushow');
	if (divMenu == null) return;
	
	// Set a.img.src attribute
	var imgObject = liMenu.find('a img');
	imgObject.attr('src', '/Images/CarrotLight.png');
	
	// Hide the div.menushow object
	$(divMenu).slideToggle("fast");
}

function setSizeOfIFrame(frameName, divName, extraHeight) {
	var iFrame = window.frames[frameName];
	var iFrameHeight = iFrame.document.body.scrollHeight;
	if (extraHeight != null) {
		iFrameHeight += extraHeight;
	}
	var newDivHeight = iFrameHeight + 20;
	iFrame.frameElement.height = iFrameHeight;
	
	$(divName).height(newDivHeight);
}

function setHeightWidthOfIFrame(frameName, divName) {
	var iFrame = window.frames[frameName];

	var docWidth = window.document.body.scrollWidth;
	$(frameName).width = docWidth - 40;
}


function setSizeOfIFrame2(frameName, divName, extraHeight) {
	//var iFrame = document.getElementById(frameName);
	//var iFrameHeight = iFrame.document.body.scrollHeight;
	
	//var 
	//var iFrameHeight = $(frameName).height;
	//if (extraHeight != null) {
	//	iFrameHeight += extraHeight;
	//}
	//var newDivHeight = iFrameHeight + 20;
	//iFrame.frameElement.height = iFrameHeight;
	//$(frameName).height(iFrameHeight);
	
	//$(divName).height(newDivHeight);
	
	var theFrame = $("#blogspot", parent.document.body);
	theFrame.height($(document.body).height() + 20);
}



