
my_url 		= 'http://www.visitandroscoggin.com/';
//my_url = "http://localhost/LOFC/";
bpath 		= '/';
d_php 		= bpath + 'ajax.php';
/***************************/
// Runs after page loads.
/***************************/
function load(){
	//setTall();
        $(".alternate").alternateRowColors();
	clearInput();
	
}
function mainfunc (func){
    this[func].apply(this, Array.prototype.slice.call(arguments, 1));
}
$.fn.alternateRowColors = function(){
	$('tr:odd',this).removeClass('even').addClass('odd');
	$('tr:even',this).removeClass('odd').addClass('even');
	return this;
};
/***************************/
// Set Side Column to Height of Main Column.
// If Main Column is less than desired Minimum, set to minimum.
/***************************/
minColHeight = 500;
function setTall() {
	if (document.getElementById) {
		// the divs array contains references to each column's div element.  
		var divs = new Array(document.getElementById('main_column'), document.getElementById('side_column'));
		if(divs[1] != null){
			// Let's determine the maximum height out of all columns specified
			var maxHeight = 0;
			for (var i = 0; i < divs.length; i++) {
			
				if (divs[i].offsetHeight > maxHeight) maxHeight = divs[i].offsetHeight;
			}
			
			if(maxHeight < minColHeight) maxHeight = minColHeight;
			
			// Let's set all columns to that maximum height
			
			for (var i = 1; i < divs.length; i++) {
				divs[i].style.height = maxHeight + 'px';
	
				// Now, if the browser's in standards-compliant mode, the height property
				// sets the height excluding padding, so we figure the padding out by subtracting the
				// old maxHeight from the new offsetHeight, and compensate!  So it works in Safari AND in IE 5.x
				if (divs[i].offsetHeight > maxHeight) {
					divs[i].style.height = (maxHeight - (divs[i].offsetHeight - maxHeight)) + 'px';
				}
			}
		}
	}
}
/***************************/
// Input clear.
/***************************/
function clearInput() {
 var inputs = getElementsByClassName('auto_clear');
 for(var i=0; i < inputs.length; i++) {
  inputs[i].setAttribute('rel',inputs[i].defaultValue);
  inputs[i].onfocus = function() {
   if (this.value == this.getAttribute('rel') && this.getAttribute('type') != 'submit' && this.getAttribute('type') != 'reset') {
    this.value = '';
   } else {
    return false;
   }
  }
  inputs[i].onblur = function() {
   if(this.value=='' && this.getAttribute('type') != 'submit' && this.getAttribute('type') != 'reset') {
    this.value = this.getAttribute('rel');
   } else {
    return false;
   }
  }
  inputs[i].ondblclick = function() {
   this.value = this.getAttribute('rel')
  }
 }
}
function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}
/***************************/
// Transparent PNGs for IE.
/***************************/

jQuery.fn.supersleight = function(settings) {
	settings = jQuery.extend({
		imgs: true,
		backgrounds: true,
		shim: 'x.gif',
		apply_positioning: true
	}, settings);
	
	return this.each(function(){
		if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7 && parseInt(jQuery.browser.version) > 4) {
			jQuery(this).find('*').each(function(i,obj) {
				var self = jQuery(obj);
				// background pngs
				if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
					var bg = self.css('background-image');
					var src = bg.substring(5,bg.length-2);
					var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
					var styles = {
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
						'background-image': 'url('+settings.shim+')'
					};
					self.css(styles);
				};
				// image elements
				if (settings.imgs && self.is('img[src$=png]')){
					var styles = {
						'width': self.width() + 'px',
						'height': self.height() + 'px',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
					};
					self.css(styles).attr('src', settings.shim);
				};
				// apply position to 'active' elements
				if (settings.applyPositioning && self.is('a, input') && self.css('position') === ''){
					self.css('position', 'relative');
				};
			});
		};
	});
};

// limit to part of the page ... pass an ID to limitTo:
// supersleight.limitTo('header');
$(document).ready(function(){
	$('#header').supersleight({shim: bpath+'java/x.gif'});
	load();
        
});

// ===============================
//		Loading Bar
// ===============================
jQuery.fn.display_loader = function(id,msg){
	if (typeof msg == 'undefined' ) msg = 'Loading...';
	$(this).after("<div id='"+id+"' class='loading'><div class='notice_box'><img src='"+bpath+"java/icons/ajax-loader.gif' alt='loading...' style='padding:10px;'/> "+msg+"</div></div>");
	/*$('<img/>')
	.attr({
		'src': bpath + 'java/icons/ajax-loader.gif',
		'alt': 'loading...',
		'style': 'padding:10px;'
	}).wrap("<div style='padding:5px;' id='"+id+"'></div>"));*/
	return this;
}
// ==========================================================
//		OPTIONS_TO_QRY : Converts an array to URL variables.
// ==========================================================
options_to_qry = function(options){
	var qry = "?ajax_module=" + options['ajax_module'];
	for (var val in options){
		if(val != 'ajax_module') qry += "&" + val + "=" + options[val];
	}
	return qry;
};
// ===========================================
//		URLDECODE : PHP urldecode equivalent.
// ===========================================
function urldecode(data){
	return unescape(String(data).replace(/\+/g," "));
}	
