function rollover(obj, str) {
	$(obj).src = str;
}

function hello(text){
				alert(text);
			}

function imageRotator(arr) {
	arr = $(arr);
	Effect.DefaultOptions.duration = 5;
	Effect.Grow('truckImage');
	
}

function selectedImage(obj, src) {
	img=$(obj);
	img.src = src;
}

function columnSyncMaxHeightArray(arrObj) {
	arrObj=$A(arrObj);
	if(arrObj.size() > 0){
		arrObj.each(function(arr){
			if(arr.size() > 1){
				columnSyncMaxHeight(arr[0], arr[1]);
			}
		})
	}
}

function columnSyncMaxHeight(obj1, obj2) {
	obj1 = $(obj1);
	obj2 = $(obj2);

	if(obj1 != null && obj2 != null) {
		if(obj1.getHeight() < obj2.getHeight()) {
			obj1.setStyle({height:obj2.getHeight()});
		}
		if(obj2.getHeight() < obj1.getHeight()) {
			obj2.setStyle({height:obj1.getHeight()});
		}
	}
}

function rollOverTextMenu(obj) {
	obj=$(obj);
	
	if(obj.hasClassName('leftNavText')){
		obj.toggleClassName('leftNavTextOn');
		obj.toggleClassName('leftNavText');
	} else {
		obj.toggleClassName('leftNavText');
		obj.toggleClassName('leftNavTextOn');
	}
}

function pushImage(obj1, obj2){
	var parentHeight = 0;

	obj1 = $A(obj1);
	obj2 = $A(obj2);

	if(obj1.size() == 0 && obj2.size() == 0){
		return false;
	}
	
	if(obj1.size() > 0){
		parentHeight = obj1.first().up(0).getHeight();
		heightSetter(obj1, obj2, parentHeight, 'pushLeft');
		
	} 
	if(obj2.size() > 0){
		if(parentHeight == 0){
			parentHeight = obj2.first().up(0).getHeight();
		}
		heightSetter(obj2, obj1, parentHeight, 'pushRight');
	}
}

function heightSetter(obj1, obj2, parentHeight, str){
	var h=0;
	var imagesHeight = 0;
	var intCount = 0;


	$A(obj1).each(function(obj) {
		if(obj.getHeight()<5){
			imagesHeight = imagesHeight + heightSetterHelper(obj, obj2, intCount);
		} else {
			imagesHeight = imagesHeight + obj.getHeight();
		}
		intCount++;
	});	


	var h = parentHeight - imagesHeight;

	if(h > 0) {
		var push = $A($$('.'.concat(str)));
		h = h/push.size();
		push.each(function(obj) {
			obj.setStyle({height: h});
		});
	}
}

function heightSetterHelper(obj1, obj2, intCount){
	if(obj2.size() < intCount){
		if(obj1.getHeight() != 0){
			return obj1.getHeight();
		} else {
			return 0;
		}
	} else {
		var h = $(obj2[intCount]).getHeight(); 
		obj1.setStyle({height: h});
		return 	obj1.getHeight()
	}
}

function subjectAppend(obj, obj2) {
	obj = $(obj);
	obj2 = $(obj2);

	if(obj2.selectedIndex == 0){
		obj.value = obj.value + " Hot!";
	}
}


function openNewWindow(url){
	window.open(url);
}

function openNewWindowHttp(url){
	url = "http://" + url;
	window.open(url);
}

function dateReplace(obj){
	obj=$(obj);
	var d = new Date(); 
	
	obj.update(formatDate(d,"EE, MMM dd, yyyy"));
}


/****************************** BEGIN AJAX JS *************************************/

function ajaxFormPost(form, obj){
	form=$(form);
	form.request({
		onSuccess: function(transport){
				obj=$(obj);
				obj.update(transport.responseText);
			}
	});
}

function ajaxRequestUpdate(obj, url, httpMethod){
	obj = $(obj);
	if(httpMethod == null || httpMethod == ''){
		httpMethod = 'get';
	}

//alert(url);
	
	if(obj != null && url != null){
		new Ajax.Request(url, {
			method: httpMethod,

			onCreate: function(){
				//alert("create");
			},

			onComplete: function(){
				//alert("complete");
			},

			onLoaded: function(){
				//alert("Loaded");
			},

			onLoading: function (){
				//alert("Loading");
			},

			onSuccess: function(transport) {
				//alert("success");
				//alert(transport.responseText);
				obj.update(transport.responseText);
			},

			onFailure: function() {
				alert("Error retrieving page");
			},

			onException: function(req, ex){
				//alert("exception");
				//alert(ex.name);
				//alert(ex.number);
				//alert(ex.description);
				//alert(req.transport.responseText);
			}
		});
	}
}

/****************************** END AJAX JS ***************************************/
