// firebug degradiation
if (! ("console" in window) || !("firebug" in console)) {
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group"
                 , "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
    window.console = {};
    for (var i = 0; i <names.length; ++i) window.console[names[i]] = function() {};
}

var topNavClasses = ["solutions", "training", "support", "resources", "contact-us"];

jQuery.noConflict();
jQuery(document).ready(function($){
	//Selector Children
	$('div:first-child, tr:first-child, td:first-child, th:first-child, li:first-child, a:first-child, label:first-child').addClass('first-child');
	$('div:last-child, tr:last-child, td:last-child, th:last-child, li:last-child, a:last-child, label:last-child').addClass('last-child');
	//$('tr:odd').addClass('odd');
	
	$('label.overlabel').overlabel();
	$('img[@src$=.png]').fixpng();
	$('#country li').mouseover( function() { $('#country li').addClass("hover"); } ).mouseout( function() { $('#country li').removeClass("hover"); } ); 
	$('.sections').box_round('only-bottom');
	$('.gradient-box-white, .shadow-white-box, .shadow-gradient-box').box_round('top-bottom'); /*DANIELAAAAAAAAAAAAAAAAAAAAAAAA*/
	$('.gradient-box').box_round('full-bottom');
	$('.boxWhite, .boxBlue, .line-box-round, .box-round,  .box-green, .box-light-blue').box_round();	/*Luis*/
	$('.row-box').equalizeCols();
	$('.equalize-height').equalizeCols();
	$('.parent-height, .lateral-shadows').fill_height(); /****** daniela ****/
	
	var $paging = $(".green-table .paging");
	if($paging.length > 0) {
		$("<tfoot></tfoot>").appendTo(".green-table");
		$("<tr></tr>").addClass("paging").appendTo(".green-table tfoot");
		$(".green-table tfoot tr").html($paging.html());
		$paging.remove();
	}
	
	$('.green-table tbody tr').box_round('table-cells');
	
	
	//Table Colorize
	if($paging.length == 0) {
		$('table.green-table').colorize({bgColor:'#ffffff',altColor:'#e5e5e5',hoverColor:'#83C6C1',hiliteColor:'#97CECC',oneClick:true});
	} else {
		$('table.green-table > tbody').colorize({bgColor:'#ffffff',altColor:'#e5e5e5',hoverColor:'#83C6C1',hiliteColor:'#97CECC',oneClick:true});
	}
	
	/* updates for h1 tag  */
	//$("h1").appendTo(".path");
	$(".pageContent .boxBlue").each( function(){ 
		if($(this).hasClass("clear")) {
			$(this).removeClass("clear").addClass("clearfix");	
		}
	});
	
	var bdrs = ["bg-left", "bg-right"];

	$(".menu-violet-buttons a, .menu-red-buttons a").each( function(){
		var text = $(this).text();
		var newText = $("<span></span>")
		   .text(text)
		   .addClass("txt");
		$(this).html(newText);

		if($(this).parent().hasClass("first-child")) {
			var $span = $("<span></span>").addClass(bdrs[0]);
			$(this).append($span);
			$(this).parent().addClass("selected");
		}
		else if($(this).parent().hasClass("last-child")) {
			var $span = $("<span></span>").addClass(bdrs[1]);
			$(this).append($span);			
		}   
	});
	
	$(".menu-violet-buttons .txt, .menu-red-buttons .txt").each( function(){
		var height = $(this).height();
		if(height > 15){
			$(this).parent().css({"padding-top": "0px", "padding-bottom": "9px"});	
		}
	});

	if($(".menu-violet-buttons, .menu-red-buttons").length == 1 ) {
		$(".text-block > div:empty").remove();
		$(".text-block div").hide();
		$(".text-block div:first-child").show();
	}

	$(".text-block li + ul").each(function() { 
		var $li = $(this).prev();
		$li.append($(this));
	});
	
	
	/* top menu fix */

	$("#nav-top .support").next().removeClass("margin21").addClass("margin26");
	$("#nav-top .training").next().removeClass("margin21").addClass("margin26");
	$("#nav-top .resources").next().removeClass("margin21").addClass("margin25");
	$("#nav-top .contact-us").next().removeClass("margin21").addClass("margin27");
	$("#nav-top .resources").one("mouseover", function () {
	var $oem = $("#nav-top .resources + ul > .sublevel > a[href$='OEM.aspx']");
	$oem.next().css("margin-top", "-"+216+"px");
	});
	
	
	
	var loc = location;
	//console.debug("%s", loc.pathname);
	//alert(loc.pathname);
	var sectionArr = location.pathname.split("/");
	//console.debug("%s", sectionArr);	
	sectionArr.shift();
	//console.debug("%s", sectionArr);
	var sectionName = sectionArr.shift().toLowerCase();
	for(var i=0, len = topNavClasses.length; i < len; i++){
		if(sectionName.search(topNavClasses[i]) > -1) {
			$("#nav-top ."+	sectionName).parent().addClass("currSection");
		}
	}
	
	var $h1 = $("h1");
	if($h1.text() == "Contact Us") {
		$(".text-block table").addClass("contacts");
		$(".content-center .text-block").css("width", "100%");
		$(".content-center").css("width", "100%");
		$("#nav-top ."+topNavClasses[4]).parent().addClass("currSection");
	//	$("ul.menu-red-buttons li").css("width", "150px");
	}
	
	
	
	/* left menu fix */
	$("ul.left-menu a[href='#']").css("text-decoration", "none");
	
	$(".boxWhite a").not("read-more-blue").addClass("right read-more-blue");
	
	
	/* image map fix */
	$("img + map").each( function() { 
		var id = $(this).attr("id");
		$(this).prev().attr("useMap", "#"+id);
	});
	
	/* Home page */
	$(".homepage .sections > div").slice(0, 2).removeClass("noBg");
	
	if($.browser.msie) {
		$(".contact-us-form	:text, div[id*='form'] :text, div[id*='form'] textarea").focus( function(){ 
			$(this).css("border-color", "#5299c5");
		}).blur( function(){ 
			$(this).css("border-color", "#b8bcbf");
		});
		
		var zIndexNumber = 1000;
		$('div').each(function() {
				$(this).css('zIndex', zIndexNumber);
				zIndexNumber -= (zIndexNumber <= 0) ? 0 : 10;
		});
	}
	
	 
});

/* =jQuery Plugins*/
(function($){
	/* = plug-in : overlabel */
	$.fn.overlabel = function(options){
		var opts = $.extend( {},$.fn.overlabel.defaults, options );
		var selection = this.filter('label[for]').map(function(){
				var label = $(this);
				var id = label.attr('for');
				var field = $("input[id$='"+id+"']");
				if(!field) return;
				var o = $.meta ? $.extend( {}, opts, label.data() ) : opts;
				label.addClass(o.label_class);
				var hide_label = function(){ label.css(o.hide_css) };
				var show_label = function(){ this.value || label.css(o.show_css) };
				$(field)
					.parent().addClass(o.wrapper_class).end()
					.focus(hide_label).blur(show_label).each(hide_label).each(show_label);
				return this;
		});
		return opts.filter ? selection : selection.end();
	};
	$.fn.overlabel.defaults = {
		label_class: 'overlabel-apply',
		wrapper_class: 'overlabel-wrapper',
		hide_css: { 'display': 'none' },
		show_css: { 'display': 'block' },
		filter: false
	};
	/* =plug-in : fix-png */
	$.fn.fixpng = function(){
		var hack = {
			isOldIE: $.browser.msie && $.browser.version < 7,
			filter: function(src){ return "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale',src='"+src+"');"; }
		};
		return this.each(function(){
			if(hack.isOldIE){
				var $$=$(this);
				if($$.attr('src')){
					var span = document.createElement('span');
					$(span).attr({
						id: $$.attr('id'), className: $$.attr('class')
					});
					$(span).css({
						display: 'inline-block', width: $$.width(), height: $$.height(), filter: hack.filter($$.attr('src')), float: $$.attr('align')=='left'?'left':($$.attr('align')=='right'?'right':'none')
					});
					this.outerHTML = span.outerHTML;
				}
			}
		});
	};
	/* = plug-in : box rounded */
	$.fn.box_round = function(options){
		var type=options?options:'default';/*default, only-top, only-bottom*/
		return this.each(function(){
			if(type=='default' || type=='only-top' ){
				var _tleft = document.createElement("span");_tleft.className="br-tleft corner";
				$(this).append(_tleft);
		  	}
			if(type=='default' || type=='only-top' ){
				var _tright= document.createElement("span");_tright.className="br-tright  corner";
				$(this).append(_tright);
			}
			if(type=='default' || type=='only-bottom' ){
				var _bleft = document.createElement("span");_bleft.className="br-bleft  corner";
				$(this).append(_bleft);
			}
			if(type=='default' || type=='only-bottom' ){
				var _bright = document.createElement("span");_bright.className="br-bright  corner";
				$(this).append(_bright);
			}
			if(type=='top-bottom' || type=='full-bottom'){
				var _bright = document.createElement("span");_bright.className="full-bottom";
				$(this).append(_bright);
			}
			if(type=='top-bottom' || type=='full-top' ){
				var _tright = document.createElement("span");_tright.className="full-top";
				$(this).append(_tright);
			}
			if(type=='table-cells'){			 
				 //var heighth= ($(this).find('th:first-child').height())-26;
				 //var heightd= ($(this).find('td:first-child').height())-26;			 
				
				 var _tleft = document.createElement("span");_tleft.className="br-tleft corner";
				 var _tright = document.createElement("span");_tright.className="br-tright corner";
				 
				$(this).find('th:first-child').append(_tleft);
				$(this).find('th:last-child').append(_tright);
				
				$(this).find('td:first-child').append(_tleft);			
				$(this).find('td:last-child').append(_tright);
				
				
				$(this).find('th:first-child').wrapInner("<div></div>");
				$(this).find('th:last-child').wrapInner("<div></div>");
				$(this).find('td:first-child').wrapInner("<div></div>");
				$(this).find('td:last-child').wrapInner("<div></div>");
				
			}
			
		});
	};
	
	/* =plug-in : equal-heights */
	$.fn.equalizeCols = function(){
		var height = 0,
			reset = $.browser.msie ? "1%" : "auto";
  
		return this
			.css("height", reset)
			.each(function() {
				height = Math.max(height, $(this).outerHeight(true));
			})
			.css("height", height)
			.each(function() {
				var h = $(this).outerHeight(true);
				if (h > height) {
					$(this).css("height", height - (h - height));
				};
			});
			
	};
	/*fill height to container**/
	$.fn.fill_height = function(){
		return this.each(function(){
			var children=$(this).children();
			var lastchild=$(children[children.length-1]);
			var lastchildPadd=lastchild.outerHeight()-lastchild.height();
			lastchild.css( { height:($(this).outerHeight()-lastchildPadd)} );
		});
	};
	/*Table Colorize*/
	$.fn.colorize = function(params) {
		options = {
			altColor: '#ECF6FC',
			bgColor: '#fff',
			hoverColor: '#BCD4EC',
			hiliteColor: 'yellow',
			oneClick: false,
			columns: false,
			banColumns: []
		};
		jQuery.extend(options, params);
	
		var colorHandler = {
			checkHover: function() {
				if (!this.onfire) {
					this.origColor = $(this).find('td').css('background-color');
					$(this).find('td').css({'background-color':options.hoverColor});
				}
			},
			checkHoverOut: function() {
				if (!this.onfire) {
					$(this).find('td').css({'background-color':this.origColor});
				}
			},
			highlight: function() {
				if (options.hiliteColor != 'none') {
					$(this).find('td').css({'background-color':options.hiliteColor});
					this.onfire = true;
				}
			},
			stopHighlight: function() {
				this.onfire = false;
				$(this).find('td').css({'background-color':this.origColor});
			}
		}
	
		function getColCells(cells, idx) {
			var arr = [];
			for (var i = 0; i < cells.length; i++) {
				if (cells[i].cellIndex == idx)
					arr.push(cells[i]);
			}
			return arr;
		}
	
		function processCells(cells, idx, func) {
			var colCells = getColCells(cells, idx);
			jQuery.each(colCells, function(index, cell2) {
				func.call(cell2);
			});
		}
	
		function processAdapter(cells, cell, func) {
			processCells(cells, cell.cellIndex, func);
		}
	
		function toggleColumnClick(cells) {
			var func = (!this.onfire) ? colorHandler.highlight : colorHandler.stopHighlight;
			processAdapter(cells, this, func);
		}
	
		function toggleRowClick(cells) {
			row = $(this).parent().get(0);
			if (!row.onfire)
				colorHandler.highlight.call(row);
			else
				colorHandler.stopHighlight.call(row);
		}
	
		function oneColumnClick(cells) {
			processAdapter(cells, this, colorHandler.highlight);
			if (cells.clicked > -1) {
				processCells(cells, cells.clicked, colorHandler.stopHighlight);
			}
			cells.clicked  = this.cellIndex;
		}
	
		function oneRowClick(cells) {
			row = jQuery(this).parent().get(0);
			colorHandler.highlight.call(row);
			if (cells.clicked) {
				colorHandler.stopHighlight.call(jQuery(cells.clicked).parent().get(0));
			}
			cells.clicked = this;
		}
	
		function checkBan() {
			return (jQuery.inArray(this.cellIndex, options.banColumns) != -1) ;
		}
	
		return this.each(function() {
	
			$(this).find('tr:odd>td').css({'background-color':options.bgColor});
			$(this).find('tr:even>td').css({'background-color': options.altColor});
	
			var cells = jQuery(this).find('td,th');
			cells.clicked = null;
	
			if (options.columns) {
				jQuery.each(cells, function(i, cell) {
					cell.onmouseover = function() {
						processAdapter(cells, this, colorHandler.checkHover);
					}
					cell.onmouseout = function() {
						processAdapter(cells, this, colorHandler.checkHoverOut);
					}
					cell.onclick = function() {
						if (checkBan.call(this))
							return;
						if (options.oneClick)
							oneColumnClick.call(this, cells);
						else
							toggleColumnClick.call(this, cells);
					}
				});
			}
			else {
				jQuery.each(cells, function(i, cell) {
					row = jQuery(cell).parent().get(0);
					row.onmouseover = colorHandler.checkHover ;
					row.onmouseout = colorHandler.checkHoverOut ;
					cell.onclick = function () {
							if (checkBan.call(this))
								return;
							if (options.oneClick)
								oneRowClick.call(this, cells);
							else
								toggleRowClick.call(this, cells);
					}
				});
			}
		});
	 };
	
})(jQuery);
/* flyout menu - rool over */

jQuery(document).ready(function($){
	if($.browser.msie && parseInt($.browser.version) == 6) {
		$("#nav-top > li > a").addClass("majorSections");
		$("#nav-top li").hover( function () {
			$(this).addClass("hover");
			//alert("hover on");
		 },
			function () {
			$(this).removeClass("hover");
			//alert("hover off");
		 }							   
		);
		$("#nav-top li ul").hover( function () {
			$(this).addClass("hover");
			//alert("hover on");
		 },
			function () {
			$(this).removeClass("hover");
			//alert("hover off");
		 }							   
		);
	}
});


jQuery(document).ready(function($) {
								/* left menu jquery */

function initMenu() {
	  $(".left-menu >li").addClass("topLevel");
	  $('.left-menu ul:empty').remove();
	  $('.left-menu ul').hide();
	  $('.left-menu .selected > ul').show();
	  
	  $('.left-menu li.topLevel > a').toggle(
			function() {
			  //var checkElement = $(this).next();
			  	var returnVal = true;
		  		if($(this).siblings("ul").length == 1 && $(this).siblings("ul:hidden").length == 1) {
					$(".left-menu > li.selected > ul").slideToggle("normal");
					$(".left-menu > li").removeClass("selected");

					var $next = $(this).next();
					$next.slideToggle("normal");
					$(this).parent().toggleClass("selected");
					returnVal = false
				}
				else {
					window.location = $(this).attr("href");	
				}
				
				return returnVal;
				
		  }
		  , function () {
			  $(".left-menu > li.selected > ul").slideToggle("normal");
				$(".left-menu > li").removeClass("selected");
				
				$(this).siblings("ul").slideToggle("normal");
				$(this).parent().toggleClass("selected");
				return false;
		  });
	  $('.left-menu li.topLevel  li > a').click(
			function() {
			  //var checkElement = $(this).next();
		  		/*
				if(!$(this).parent().hasClass("selected")) {
					if($(this).siblings("ul").length == 1) {
					$(".left-menu li.topLevel li.selected > ul").slideUp("normal");
					$(".left-menu li.topLevel li").removeClass("selected");
					
					$(this).siblings("ul").slideDown("normal");
					}
					$(this).parent().addClass("selected");
				}
				else {
					window.location = $(this).attr("href");
					$('.left-menu ul').stop();
				}
				*/
				//var returnVal = ($(this).siblings("ul").length != 1) ? true: false;
				//console.debug("%s %b", $(this).text(), returnVal);
				//if(returnVal) {
					window.location = $(this).attr("href");
					//$(".left-menu li.topLevel li.selected > ul").stop();
				//}
				//return returnVal;
				//return false;
		  } /*
		  , function () {
				if(!$(this).parent().hasClass("selected")) {
					if($(this).siblings("ul").length == 1) {
					$(".left-menu li.topLevel li.selected > ul").slideUp("normal");
					$(".left-menu li.topLevel li").removeClass("selected");
					
					$(this).siblings("ul").slideDown("normal");
					}
					$(this).parent().addClass("selected");
				}
				else {
					window.location = $(this).attr("href");
					$(".left-menu li.topLevel li.selected > ul").stop();
				}
				var returnVal = ($(this).siblings("ul").length != 1) ? true: false;
				//console.debug("%s %b", $(this).text(), returnVal);
				if(returnVal) {
					window.location = $(this).attr("href");
					$('.left-menu ul').stop();
				}
				return returnVal;
				//return false;
		  } */);
	 
}
								initMenu();});

