

//  vars to hold mouse pos
//var mousex = 0;
//var mousey = 0;

var thisdoc = window.document;
// Detect if the browser is IE or not.
var DHTML = (thisdoc.getElementById || thisdoc.all || thisdoc.layers);
var IE = thisdoc.all ? true : false;

var viewportwidth;
var viewportheight;




function load_item (ilink, alink, i_cat)
	{
	img_obj = document.getElementById("detailed_img");
	img_a_obj = document.getElementById("detailed_a");
	i_cat_obj = document.getElementById("div_cat");
	img_obj.src = ilink;
//	alert (i_cat_obj.innerHTML);
	i_cat_obj.innerHTML = i_cat;
//	img_a_obj.href = "javascript:popup_image(\""+alink+"\");";
	img_a_obj.href = alink;
//	thumbnailviewer.init();
//	thumbnailviewer.cleanup();
	}



function resize_page ()
	{
	var rez_height;

	switch (pagelayout) {
		case "1":
		break;
		case "2":
			$("#cell_leftcolumn_bottom").show();
		break;
		case "3":
			$("#cell_main_bottom").show();
		break;
		}


	rez_height_1 = $(window).height() - ($("#cell_header").outerHeight(true) + $("#cell_menu").outerHeight(true) + $("#cell_footer").outerHeight(true) + 5)
	rez_height_2 = $(window).height() - ($("#cell_header").outerHeight(true) + $("#cell_footer").outerHeight(true) + 5)

//	$("#cell_leftcolumn_bottom:visible").css({'height': rez_height+'px'});
//	$("#cell_leftcolumn_bottom:visible").attr('height', rez_height);

//	$("#debug_div").html(rez_height_1);

	if ($("#cell_leftcolumn_bottom").css("display") != "none") {
		$("#cell_leftcolumn_bottom").css({"height":rez_height_1+"px"});
		$("#cell_leftcolumn_bottom_div").css({"height":rez_height_1+"px"});

		content_height = $("#cell_menu").outerHeight(true)+$("#cell_leftcolumn_bottom").outerHeight()-8;
		$("#cframe").css({'height': content_height+"px"});

		$("#thumbs_masterbox").css({'height': (content_height-8)+"px", 'width': ($("#cframe").width()-8)+"px"});
		$("#thumbs_box").css({'height': (content_height-8)+"px", 'width': ($("#cframe").width()-8)+"px"});
//		$("#promo_div").css({'height': (content_height-  (8+$("#promo_pages").height())  )+"px", 'width': ($("#cframe").innerWidth()-  (8+parseInt($("#promo_div").css("borderLeftWidth"), 10) + parseInt($("#promo_div").css("borderRightWidth"), 10))  )+"px"});
		$("#promo_div").css({'height': (content_height-  (8+$("#promo_pages").height()+parseInt($("#promo_div").css("borderTopWidth"), 10) + parseInt($("#promo_div").css("borderBottomWidth"), 10))  )+"px", 'width': '544px'});
		}
	else {
		$("#cell_main").css({'height': rez_height_2});
		}

//	$("#cell_leftcolumn_bottom_div").css({"background-color":"#0F0"});
	}



function chksearch (formobj)
	{
	if (formobj.searchkey.value == "") { formobj.searchkey.focus(); alert("You must enter a search key in the search box."); return(false); }
	//return(true);
	}




// ---------- image preloading ----------

function preloadImages()
	{
	if (document.images)
    	{
	    this.imageArray = new Array();

    	for (i=0; i<preloadImages.arguments.length; i++)
	        {
    	    this.imageArray[i] = new Image();
        	this.imageArray[i].src = preloadImages.arguments[i];
	        }
    	}

//	togglediv ("thumbs_loader", 0);
	}

$.preloadImages = function() {
	for(var i = 0; i<preload_array.length; i++) {
		$("<img>").attr("src", preload_array[i]);
		}
	}

$.preloadImages_big = function() {
	for(var i = 0; i<preload_array_big.length; i++) {
		jQuery("<img>").attr("src", preload_array_big[i]);
	}}



// ---------- init ----------


$(document).ready(function(){

//	$(document).mousemove(getmousexy);  
	$(window).resize(resize_page);

	$("div.div-menu").children("div.div-submenu").animate({"opacity": "0"}, 1 );
	$("div.div-menu").children("div.div-submenu").css ({"visibility": "visible"});
	$("div.div-menu").children("div.div-submenu").animate({"opacity": "0.4"}, 100 );

	$("div.div-menu").bind("mouseenter", function(event){
//		$(this).children("div.div-submenu").css ({"visibility": "visible"});

////		$(this).children("div.div-submenu").css ({"opacity": "1", "filter": "alpha(opacity = 100)"});
		$(this).children("div.div-submenu").animate({"opacity": "1"}, 100 );

		});
	$("div.div-menu").bind("mouseleave", function(event){
//		$(this).children("div.div-submenu").css ({"visibility": "hidden"});

////		$(this).children("div.div-submenu").css ({"opacity": "0.20", "filter": "alpha(opacity = 20)"});
		$(this).children("div.div-submenu").animate({"opacity": "0.4"}, 100 );
		});

	$("div.div-menulink-sel").parents("div.div-menu").children("div.div-menutitle").addClass("div-menutitle-sel");

	jQuery(window).load(function(){
		});

	});



