﻿//Global Navigation
$(function() {
		$('ul#navContainer li').hover(function(){
		   $(this).find('a.mainNav').addClass('overMainItem');
		}, function(){
		   $(this).find('a.mainNav').removeClass('overMainItem');
		});
		$('li.hasSubNav').hover(function(){
				$(this).find('a.mainNav').removeClass('normalSubNav').addClass('overmouseSubNav');
				$(this).find('ul.subNav').css('display', 'block');
		}, function() {
				$(this).find('a.mainNav').removeClass('overmouseSubNav').addClass('normalSubNav');
				$(this).find('ul.subNav').css('display', 'none');
		});
});
	
// This functionality is necessary to trigger the search.
var search = (function(){
	var okURIcharsCopy = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ \"-", hexcharsCopy = "0123456789ABCDEF",result=false;
	function encodeURIComponentNewCopy(s){
		var enc = "", s;
		if (s == null || s.length <= 0) {
			return s;
		}
		s = utf8Copy(s);
		for (var i = 0; i < s.length; i++) {
			if (okURIcharsCopy.indexOf(s.charAt(i)) == -1) 
				enc += "%" + toHexCopy(s.charCodeAt(i));
			else 
				enc += s.charAt(i);
		}
		return enc;
	}
	function utf8Copy(wide){
		var c, s, enc = "", i = 0;
		while (i < wide.length) {
			c = wide.charCodeAt(i++);
			if (c >= 0xDC00 && c < 0xE000) 
				continue;
			if (c >= 0xD800 && c < 0xDC00) {
				if (i >= wide.length) 
					continue;
				s = wide.charCodeAt(i++);
				if (s < 0xDC00 || c >= 0xDE00) 
					continue;
				c = ((c - 0xD800) << 10) + (s - 0xDC00) + 0x10000;
			}
			if (c < 0x80) 
				enc += String.fromCharCode(c);
			else 
				if (c < 0x800) 
					enc += String.fromCharCode(0xC0 + (c >> 6), 0x80 + (c & 0x3F));
				else 
					if (c < 0x10000) 
						enc += String.fromCharCode(0xE0 + (c >> 12), 0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F));
					else 
						enc += String.fromCharCode(0xF0 + (c >> 18), 0x80 + (c >> 12 & 0x3F), 0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F));
		}
		return enc;
	}
	function toHexCopy(n){
		return hexcharsCopy.charAt(n >> 4) + hexcharsCopy.charAt(n & 0xF);
	}
	function validateBox(txt){
		return (txt !== "") ? txt : "";
	}
	return {
		about: function(){
			return {
				author: "Damian Martinez",
				ssoId: "501438407",
				nameFile: "Search Functionality"
			}
		},
		submitSearch: function(formsId){
			var stringToSearch = document.getElementById(formsId).textToSearch.value;
			if (stringToSearch !== "") {				
				$(".globalInput").removeAttr("name").attr( "name", "homeSearch" );
				document.getElementById(formsId).innerHTML +='<input type="hidden" title="search" name="textToSearch" id="textToSearch"/>';
				$(".globalInput").val(stringToSearch);
				document.getElementById(formsId).textToSearch.value = encodeURIComponentNewCopy(stringToSearch);
				document.getElementById(formsId).submit();
				result = true;
			}
			else {
				alert("Please enter keyword(s) to search!");
				document.getElementById(formsId).textToSearch.focus();
				return false;
			}
			return result;
		},
		validation:function(formsId){
			return search.submitSearch(formsId);
		},
		startEvents: function(){
			$("img.globalSearchImg").click(
				function(){
					formsId = $(this).parents("form").attr("id");
					search.validation(formsId);
				}
			);
			$("input.globalInput:text").keyup(
				function(e){
					formsId = $(this).parents("form").attr("id");
					var unicode = (e.keyCode ? e.keyCode : e.which);
				 	if(unicode === 13) {search.validation(formsId);}
				}
			);
		}
	}
})();

/* This clousure is for the auto get year for all sites in footer */
var utilsBySite = (function(){
	var date = new Date();
	function getYear(){
		return date.getFullYear();
	}
	return {
		about: function(){
			return {
				author: "Damian Martinez",
				ssoId: "501438407",
				description: "Getyear automatically for footer"
			}
		},
		year: function(){
			document.getElementById("dinamycyear").innerHTML = getYear();
		}
	}
})();

/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.2, 09.03.2009
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    09.03.2009 Version 1.2
 *    - Update for jQuery 1.3.x, removed @ from selectors
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 * @example $(function(){$(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example $(function(){$('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

(function($){jQuery.fn.pngFix=function(settings){settings=jQuery.extend({blankgif:'blank.gif'},settings);var ie55=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 5.5")!=-1);var ie6=(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 6.0")!=-1);if(jQuery.browser.msie&&(ie55||ie6)){jQuery(this).find("img[src$=.png]").each(function(){jQuery(this).attr('width',jQuery(this).width());jQuery(this).attr('height',jQuery(this).height());var prevStyle='';var strNewHTML='';var imgId=(jQuery(this).attr('id'))?'id="'+jQuery(this).attr('id')+'" ':'';var imgClass=(jQuery(this).attr('class'))?'class="'+jQuery(this).attr('class')+'" ':'';var imgTitle=(jQuery(this).attr('title'))?'title="'+jQuery(this).attr('title')+'" ':'';var imgAlt=(jQuery(this).attr('alt'))?'alt="'+jQuery(this).attr('alt')+'" ':'';var imgAlign=(jQuery(this).attr('align'))?'float:'+jQuery(this).attr('align')+';':'';var imgHand=(jQuery(this).parent().attr('href'))?'cursor:hand;':'';if(this.style.border){prevStyle+='border:'+this.style.border+';';this.style.border=''}if(this.style.padding){prevStyle+='padding:'+this.style.padding+';';this.style.padding=''}if(this.style.margin){prevStyle+='margin:'+this.style.margin+';';this.style.margin=''}var imgStyle=(this.style.cssText);strNewHTML+='<span '+imgId+imgClass+imgTitle+imgAlt;strNewHTML+='style="absolute:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;strNewHTML+='width:'+jQuery(this).width()+'px;'+'height:'+jQuery(this).height()+'px;';strNewHTML+='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader'+'(src=\''+jQuery(this).attr('src')+'\', sizingMethod=\'scale\');';strNewHTML+=imgStyle+'"></span>';if(prevStyle!=''){strNewHTML='<span style="position:absolute;display:inline-block;'+prevStyle+imgHand+'width:'+jQuery(this).width()+'px;'+'height:'+jQuery(this).height()+'px;'+'">'+strNewHTML+'</span>'}jQuery(this).hide();jQuery(this).after(strNewHTML)});jQuery(this).find("*").each(function(){var bgIMG=jQuery(this).css('background-image');if(bgIMG.indexOf(".png")!=-1){var iebg=bgIMG.split('url("')[1].split('")')[0];jQuery(this).css('background-image','none');jQuery(this).get(0).runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+iebg+"',sizingMethod='scale')"}});jQuery(this).find("input[src$=.png]").each(function(){var bgIMG=jQuery(this).attr('src');jQuery(this).get(0).runtimeStyle.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader'+'(src=\''+bgIMG+'\', sizingMethod=\'scale\');';jQuery(this).attr('src',settings.blankgif)})}return jQuery}})(jQuery);

/**
* =======================================================================
* Copyright ? 2009 General Electric. ALL RIGHTS RESERVED. 
* This file contains proprietary and GE CONFIDENTIAL Information.
* Use, disclosure or reproduction is prohibited.
* Filename: view.js
* Created on 26/02/2008
*
* @class sb2.pe.view provide all constants used in the page editor application
* @author Damian Martinez Diaz(501438407)
* @version  0.04052011.1.0
**/
var DBrowserFound=(function(){var aboutBrowser=[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"}],aboutOperatingSystem=[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}],selfObj=this,navApp=navigator.userAgent||navigator.appVersion||"an unknown version",version;function searchString(data){for(var i=0;i<data.length;i++){var dataString=data[i].string;var dataProp=data[i].prop;selfObj.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!=-1)return data[i].identity}else if(dataProp)return data[i].identity}}function searchVersion(dataString){var index=dataString.indexOf(selfObj.versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+selfObj.versionSearchString.length+1),10)}return{isFF:function(){return(DBrowserFound.getBrowser()==='Firefox')?true:false},isIE:function(){return(DBrowserFound.getBrowser()==='Explorer')?true:false},isIE6:function(){return(DBrowserFound.isIE()&&DBrowserFound.getVersion()===6)?true:false},isChrome:function(){return(DBrowserFound.getBrowser()==='Chrome')?true:false},isSafari:function(){return(DBrowserFound.getBrowser()==='Safari')?true:false},getVersion:function(){return searchVersion(navApp)},getBrowser:function(){return searchString(aboutBrowser)||"An unknown browser"},getOperSyst:function(){return searchString(aboutOperatingSystem)||"an unknown Operating System"}}})();

/************************** Calling all the functions needed at start **********************/
$(document).ready(function(){
	search.startEvents();
	if(DBrowserFound.isIE6()){
		$(function(){$('#body_elm').pngFix();});
	}
});

