// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var serverpath = "http://www.davidhinchenshouses.com/images/";

function preload_images(dir, width, height, label, total) {
    if (document.images)
    {
      for (var i=1; i<=total; i++) {
        pic1= new Image(width,height); 
        pic1.src=serverpath+dir+"/"+label+"_image_"+i+".jpg";
        // pic1= new Image(width,height); 
        // pic1.src=serverpath+dir+"/"+label+"_thumb_"+i+".jpg";
      }
      // pic1 = new Image(500,375);
      // pic1.src=serverpath+"background.jpg";
    }
}

function select_active_menu_item(item_id) {
    var active_marker_id = item_id + '_active';
    $(item_id).onmouseover = function onmouseover(event) {};
    $(item_id).onmouseout = function onmouseout(event) {};
    Element.show(active_marker_id);
    // $('debug').innerHTML = "active_marker_id = "+active_marker_id;
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function setElementHeight(elementID, pagename) {
    var windowHeight = getWindowHeight();
    var max_height = getMaxHeight(pagename);
    if (max_height > 0) {
        if (windowHeight > max_height) {
            $(elementID).style.height = windowHeight + 'px';
        }
        else {
            $(elementID).style.height = max_height + 'px';
        }
    }
    else if (windowHeight > 0) {
        $(elementID).style.height = windowHeight + 'px';
    }
    // $('debug').innerHTML = 'max_height = '+max_height+', windowHeight = '+windowHeight+', '+elementID+' height = '+$(elementID).style.height;
}

function getMaxHeight(pagename) {
    switch(pagename) {
        case "index": return 700;
        case "about": return 800;
        case "portfolio": return 720;
        case "paintings": return 700;
        case "drawings": return 700;
        case "landscapes": return 700;
        case "profile": return 1500;
        case "order": return 900;
        case "order_commissions": return 900;
        case "prices": return 2000;
        case "order_prints": return 2000;
        case "order_stationery": return 1200;
        case "gallery": return 1000;
        default: return 0;
    }
}


