// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function select_auxiliary_image_path(target_element, path, selection){
	
	var rows = document.getElementById("auxiliary-options").getElementsByTagName("li");

  document.getElementById(target_element).value = path;
	for (var i=0; i<rows.length; i++) {
		if (Element.hasClassName(rows[i], 'this-thumb')) {
			Element.removeClassName(rows[i], 'this-thumb');
		}
	}
	Element.addClassName(selection, 'this-thumb');
}


function openWindow(url, w, h) {
    if (window.screen) {
			var screenwidth = window.screen.availWidth;
			var screenheight = window.screen.availHeight;
			if (window.attachEvent) {
				screenheight = screenheight - 80;
			};
			
			var widthRatio = screenwidth/w;
			var heightRatio = screenheight/h;
			var ratio = heightRatio;

			if (widthRatio < heightRatio) {
				ratio = widthRatio;
			}

    	if (ratio < 1) {
				h = h * ratio;
				w = w * ratio;
			}
		}
		h = parseInt(h)
		w = parseInt(w)
		url = url + '&window_height=' + h + '&window_width=' + w
    newWindow = window.open (url,'myWindow','status=no,location=no,directories=no,toolbar=no,menubar=no,resizable=no,width='+w+',height='+h);  
}

