function loadTwitterFeed(user, count, sinceString) {
	//new Ajax.PeriodicalUpdater('twitterBlock', 'assets/oscav5/ajax/twitter.php?user=' + user + '&count=' + count + '&sinceString=' + sinceString, {
	//	method: 'get', frequency: 120, decay: 0
	//});
}


// Swaps the content on rollover - Landing Page
function swapLandingPageContent ( id ) {
		
	// Get the images and hide them all
	images = $('content-panel').immediateDescendants();
	images.each( function (k,v) {
		$(k).hide();
	} );
	
	// Show the selected image
	$('image_'+id).show();
	
	// Get all the text areas and hide them all
	textAreas = $('menu-text-content').immediateDescendants();
	textAreas.each( function (k,v) {
		$(k).hide();
	} );
	
	// Show the select content block
	$('menu-text-content_'+id).show();
	

}

// Decoration to the links-rows-panel on the landing page.
function linksRowsPanelDecoration (liPos) {
	
	if ( $('links-rows-panel') ) {
	
		rows = $('links-rows-panel').getElementsBySelector('li');
	
		rows.each ( function (k, v) {
		
			if ( v == 0 ) {
				$(k).down().addClassName('highlight');
			}
		
			if ( liPos != 0 && liPos != null) {
				rows[0].down().removeClassName('highlight');
			}
		
		});
	
	}
	
}

// Menu
if (!window.XMLHttpRequest) {  
	Event.observe(window, 'load', function() {  
		$$('.xMenu ul li').each( function(e) {  
			Event.observe(e, 'mouseover', function() { 
				if(Element.hasClassName(e, 'hasChildren')) {
					Element.addClassName(e, 'has-children-over');
				} else {
					Element.addClassName(e, 'over');  
				}
			});  
			Event.observe(e, 'mouseout', function() {  
				if(Element.hasClassName(e, 'has-children-over')) {
					Element.removeClassName(e, 'has-children-over');  
				} else {
					Element.removeClassName(e, 'over');  
				}
			});  
		});  
	});
}

/* Form Functions [Start] */

function clearField (e) {
	
	if ( e.value == e.id) {
		e.value = '';
	}

}

function populateField (e) {
	
	if ( e.value == e.id) {
		e.value = e.id;
		activateForm(false);
	} else if ( e.value == '') {
		e.value = e.id;
		activateForm(false);
	} else {
		activateForm(true);
	}
	
}

/* Form Functions [End] */

/* Sign-up Form Functions [Start] */

function hitArea () {

	$('sign-up-form-hit-area').toggle();
}

function activateForm (status) {
	if (status == true) {
		buttonObj = document.getElementById('sign-up-submit');
		buttonObj.disabled = false;
		buttonObj.style.backgroundColor = '#000000';
	} else {
		buttonObj = document.getElementById('sign-up-submit');
		buttonObj.disabled = true;
		buttonObj.style.backgroundColor = '#999999';		
	}
	
}

/* Sign-up Form Functions [End] */

var myLightWindow = null;
function lightwindowInit() {
	myLightWindow = new lightwindow();
}

// On Load stuff

Event.observe(window, 'load', function(event) {
									   
	/* Sniff the browser */
	oBrowser = new BrowserDetect();
	oBrowser.checkBrowser();
	
	var oTabSwitch = new Tabswitch();
	
	/* Force this link to launch the lightwindow */
	/*menuElement = $('menu_9').down('a');
	menuElement.writeAttribute('href', 'http://www.sustainable-galvanizing.com');
	menuElement.writeAttribute('params', 'lightwindow_type=external,lightwindow_width=1030,lightwindow_height=912');
	menuElement.writeAttribute('onclick','return false');
	menuElement.writeAttribute('rel','[site]');
	menuElement.addClassName('lightwindow');*/
	
	/* Set up all the panels onLoad */
	var calloutsObj = new Callout();
	
	/* Set up the Text Changer */
	var textchangerObj = new TextChanger();
	
	lightwindowInit();
	
	// Shut the Quick Links Menu
	//new Effect.SlideUp( $('quick-links-menu'), { duration:0, queue: { position: 'end', scope: 'quicklinks' } } );
	
	/* Set the onClick observers */
	Event.observe($('signup-button'),'click', function(e) {

		new Effect.toggle($('signup-form-panel'), 'slide', { duration:0.5, queue: { position: 'end', scope: 'signuppanel' }, afterFinish : textchangerObj.formbutton.bind(this) } );
		
	});
	
	Event.observe($('quick-links-header'),'click', function(e) {

		new Effect.toggle($('quick-links-menu'), 'slide', { duration:0.5, queue: { position: 'end', scope: 'quicklinks' }, afterFinish : textchangerObj.quicklinksheader.bind(this) } );

	});
	
	if( $('back-to-top-button') ) {
		Event.observe($('back-to-top-button'),'click', function(e) {
	
			scrollOffSets = document.viewport.getScrollOffsets();
		
			yPos = scrollOffSets.top;
	
			if(yPos != 0 ) {
				Effect.ScrollTo('top-flag');
			}
			
		});
	}
	
	$$('input').each(function(e) {
		if(e.hasClassName('required')) {
			var prevLabel = e.previousSiblings();
			//prevLabel[0].update(prevLabel[0].innerHTML + "<span class=\"required\">*</span>");
			//	$(label).addClassName('required');						  
		}
	});
	
});

var Popup = {
  open: function(options)
  {
	this.options = {
	  url: '#',
	  width: 620,
	  height: 440
	}
	Object.extend(this.options, options || {});
	window.open(this.options.url, '', 'width='+this.options.width+',height='+this.options.height);
  }
}
