/**
 * @author Dream Production
 */

fixOops = function() {}
function operaFixOops() {
	$("#header").css("padding-left","0");
	$("#content-wrap").css("margin-left","37px");
	$("#content-wrap").css("margin-right","38px");
}
function safariFixOops() {
	$("#header").css("padding-left","0");
	$("#content-wrap").css("margin-left","37px");
	$("#content-wrap").css("margin-right","38px");
}
function mozillaFixOops() {
}
function msieFixOops() {
	//$("#menu").css("height","250px");
	$("#photoThumbs").css("width","190px");
	$("#photoThumbs li").css("margin-left","5px");	
	$("#photoThumbs li").css("margin-right","5px");	
	$("#content").css("padding-left","12px");	
	$("#content").css("padding-right","11px");	
}
if ($.browser.safari) fixOops = safariFixOops;
if ($.browser.mozilla) fixOops = mozillaFixOops;
if ($.browser.opera) fixOops = operaFixOops;
if ($.browser.msie) fixOops = msieFixOops;

function size() {
	return;
  var wWidth = 0, wHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    wWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    wWidth = document.documentElement.clientWidth;
    wHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    wWidth = document.body.clientWidth;
    wHeight = document.body.clientHeight;
  }
	
	h = wHeight - $("#header").height() - $("#contentFrame").css("padding-bottom").split("p")[0];
	if (h<440) h = 440;
	if (h < $("#menu").height()) h = $("#menu").height();
	//alert(h);
	if (!$.browser.msie) $("#contentFrame").css("min-height",h+"px");
	else $("#contentFrame").css("height",h+"px");


	h = wHeight;
	h2 = $("#contentFrame").height() + $("#header").height() + $("#contentFrame").css("padding-bottom").split("p")[0]/1;
	if (h < h2) h = h2;
	if (!$.browser.msie) $('#page').css('min-height',h+"px");
	else $('#page').css('height',h+"px");
}

function makeAccordeonMenu() {
	$("#menu > li > ul").css("display","none");
	$("#menu > li:has(ul) > a").click(function(){
		$("#menu > li > ul").css("display","none");
		$("#menu > li > a").removeClass("active");
		$(this).addClass("active");
		$(this).parent().children("ul").css("display","block");
		size();
		return false;
	});
	$("#menu > li > ul:not(#photoThumbs) > li > a").each(function(){
		$(this).attr("href", $(this).attr("href")+"#current-index:"+$(this).parent().parent().parent().attr("id"))
	});
	$("#menu li a").focus(function(){ $(this).blur(); });
}

function makePhotoGallery() {
	$("#photoThumbs a").click(function(){
		imgSrc=$(this).attr("href");
		imgTitle=$(this).attr("title");
		$("#content").html('<img class="galleryImage" src="'+imgSrc+'" alt"'+imgTitle+'"><div class="galleryImageCaption">'+imgTitle+'</div>');
		return false;
	});
}

$(document).ready(function(){
	fixOops();
	makeAccordeonMenu();
	makePhotoGallery();
	size();	
	$("#header").flash({
	    src: 'header.swf',
	    width: 812,
	    height: 243
	});
	var url = window.document.URL.toString();
	urlParts = url.split('#');
	if (urlParts.length) {
		for (i=1; i< urlParts.length; i++) {
		param = urlParts[i].split(':');
			if (param.length) {
				if (param[0] == "current-index") {
					$("#"+param[1]+" > a").addClass("active")
					$("#"+param[1]+" > ul").css("display","block")	
				}
			}
		}
	}	
});

$(window).resize(function(){
	size();
});
