/****************************************
| ** Global.js
|
| Created by: Rob Hayward
| Date Created: 2008-18-06
| Copyright 2008 Lightmaker Manchester
|
****************************************/
jQuery.noConflict();
var $j = jQuery;
var isIE6 = false; var isIE7 = false; var isSafari = false; appPath = ''; var colorScheme;
$j(document).ready(function() {
	//Add javascript enabled hook
	$j('body').addClass('js');
	/* Browser Detection: IE6/IE7/IE8/Safari apply bug fixes */
	if( ($j.browser.msie) && (parseInt($j.browser.version) == "6" )) { isIE6 = true; try { document.execCommand('BackgroundImageCache', false, true); } catch(e) { } }
	if( ($j.browser.msie) && (parseInt($j.browser.version) == "7" )) { isIE7 = true; }
	if( ($j.browser.msie) && (parseInt($j.browser.version) == "8" )) { isIE8 = true; }
	/* Browser Detection: Safari */
	if($j.browser.safari) { isSafari = true; }
	//Run global functionality
	inputValueReplace();
	dropdowns();
	var siteSearch = new siteSearchInstance(); siteSearch.init();
	colorScheme = new colorSchemeInstance();
	
});
function inputValueReplace() {
	//From fields default value replace
  $j('input.value-replace').each(function() { var o = new valueReplace($j(this)); });
	function valueReplace(e) {
		var o = {
		  init : function() {
				o.field = $j(e); 
				o.isSet = false;
				o.defaultValue = o.field.val();
				o.monitor();
			},
			monitor : function() {
				o.field.focus(function(){
					if( $j(this)[0].value == o.defaultValue) { $j(this)[0].value = ''; }
				});
				o.field.blur(function(){
					if($j(this)[0].value == '') { $j(this)[0].value = o.defaultValue;}
				});
			}
		}
		o.init();
		return o;
	}
}
function colorSchemeInstance(){};
colorSchemeInstance.prototype = {
		group : { base : '#ffa800', highlight : '#ffeecc'},
		rail : { base : '#d26e02', highlight : '#f6e2cc'},
		power : { base : '#80c901', highlight : '#e6f4cc'},
		technology : { base : '#00b4ff', highlight : '#ccf0ff'},
		training : { base : '#990000', highlight : '#ebcccc'},
		solutions : { base : '#8010af', highlight : '#e6cfef'},
		resources : { base : '#ffa800', highlight : '#ffeecc'}		
}
function pixelTrim(str){
	var length = str.length;
	var temp = str.substring(0,(length-2));
	return temp;
}
function pixelAdd(str){
	var temp = str + 'px';
	return temp;
}
function siteSearchInstance(){}; 
siteSearchInstance.prototype = {
	init : function() {
		var o = this;
		o.component = $j('#SiteSearch');
		o.fieldRow = $j('.frow', o.component);
		o.form = $j('form', o.component);
		o.submitTrigger = $j('#Submit', o.component);
		o.render();
	},
	render : function(){
		var o = this;
		
		o.events();
	},
	events : function() {
		var o = this;
		o.fieldRow.hover(
			function() { 
				$j(this).addClass('frow-hover');
			},
			function() { 
				$j(this).removeClass('frow-hover');
			}
		);
		o.submitTrigger.click(function(){
			o.form.submit();
		});
	}
}
function fetchValue(r,c) {
	var a = c.split(' ');
	var result;
	$j(a).each(function(i){
		var t = $j(this)[0];
		t = t.split('-');
		if(t[0] == r) { result = t[1]; }
	});
	return result;
}
			

