// JavaScript Core Document

function external(){
	var l = $$('a');
	l.each(function(el){
		if (el.getProperty('rel')=='external'){
			el.setProperty('target', '_blank');
		}
	});
}

function flash(){
	var movies = $$('.flash');
    movies.each(function(el){
		var container = el.id;
		var id = el.id;
		var target = el.get('rel');
		var dims = el.getSize();
		var width = dims.x;
		var height = dims.y;
		var obj = new Swiff('/_lib/flash/' + target + '.swf', {id: id, width: width, height: height, container: container});
	});
}
function forms(){
	var s = $$('form #sort');
	s.each(function(el){
		el.addEvent('change', function(e){
			if (el.value != 'Please select'){
				el.getParent().getParent().submit();
			}
		});
	});
}
function _getmap(){
	var map_exists = $('gmap');
	if (map_exists){
		window.addEvent('load',function(){
			load('gmap');
		});	
		window.addEvent('unload',function(){
			GUnload();
		});	
	}
}

window.addEvent('domready', function(){
	external();
	forms();
	flash();
	_getmap();
});
