$j(function() {
	if (document.getElementById('solutionsDrawer')){
		$j.Avaya.SifrConfig.masterReplace($j.Avaya.SifrConfig.gothamLight,{
		   selector: '#content div.marqueeText p',
		   css: {
				'.sIFR-root': { 
					'color': '#404040', 
					'font-size': 18
				}
		   },
		   selectable: false
		});
		
		$j.Avaya.SifrConfig.masterReplace($j.Avaya.SifrConfig.gothamLight,{
		   selector: '#solutionsDrawer div.header h3',
		   css: {
				'.sIFR-root': { 
					'color': '#cc0000', 
					'font-size': 18
				}
		   },
		   selectable: false
		});
		
		$j.Avaya.SifrConfig.masterReplace($j.Avaya.SifrConfig.gothamLight,{
		   selector: '#toutArea h2',
		   css: {
				'.sIFR-root': { 
					'color': '#404040', 
					'font-size': 20
				}
		   },
		   selectable: false
		});
	} else {
		$j.Avaya.SifrConfig.masterReplace($j.Avaya.SifrConfig.gothamLight,{
		   selector: '#content h2',
		   css: {
				'.sIFR-root': { 
					'color': '#cc0000',
					'letter-spacing': -1,
					'font-size': 30
				}
		   },
		   selectable: false
		});

		$j.Avaya.SifrConfig.masterReplace($j.Avaya.SifrConfig.gothamLight,{
		   selector: '.tout h4',
		   css: {
				'.sIFR-root': { 
					'color': '#404040', 
					'font-size': 20
				}
		   },
		   selectable: false
		});
		$j.Avaya.SifrConfig.masterReplace($j.Avaya.SifrConfig.gothamLight,{
		   selector: '.rightCol .rightCol h4',
		   css: {
				'.sIFR-root': { 
					'color': '#404040', 
					'font-size': 16
				}
		   },
		   selectable: false
		});
	}
	
	$j.Avaya.SifrConfig.masterReplace($j.Avaya.SifrConfig.gothamLight,{
	   selector: '#content h1',
	   css: {
			'.sIFR-root': { 
				'color': '#cc0000',
				'letter-spacing': -1,
				'font-size': 28
			}
	   },
	   selectable: false
	});

	var pullDownParent = $j('li.pullDown');
	pullDownParent.each(function() {
		var pullDownTrigger = $j(this).find('a.arrowOut');
		var list = $j(this).find('ul');
		pullDownTrigger.click(function(e) {
			if(list.css('display') == 'none') {
				$j(this).attr('class','arrowDown');
				list.slideDown(200);				
			}
			else {
				$j(this).attr('class','arrowOut');
				list.slideUp(200);	
			}
		});
	});
	
	if (document.getElementById('finder-mod')){
		if (document.getElementById('solutionsDrawer')){
			$j.Avaya.global.Finder = new $j.Avaya.Finder({
				isOpen: 1, 
				page:'solutions', 
				altDesign : true, 
				submitRefreshes: false, 
				submitCallback: updateResultHeading 
			});
			
			var $wrapper = $j('#results div.wrapper');
			var $items = $wrapper.find('div.item');
			
			if ($items.length%2 == 0){
				$wrapper.addClass('even');
			}
			
			var $resultControls = $j('#listView , #gridView');
			
			var toggler = new $j.Avaya.ResultControls({
				toggleCallback : function(){
					document.getElementById('drawerContainer').style.height = 'auto';
				}
			});
			
		} else {
			$j.Avaya.global.Finder = new $j.Avaya.Finder({isOpen: 1, page:'solutions'});	
		}
	}
});

function updateResultHeading() {
	// figure out which text to use
	var $bizNeed = $j("select[name=need]");
	var $bizIndustry = $j("select[name=industry]");
	
	var resultCopy = "";
	var selectValue = "";
	if(($bizNeed.val() == "default" || $bizNeed.val() == "all") && ($bizIndustry.val() == "default" || $bizIndustry.val() == "all")) {
		//resultCopy = SolutionsText["default"];
		selectValue = "All";
		//return;
	} else if($bizNeed.val() != "default" && $bizNeed.val() != "all") {
		//resultCopy = SolutionsText[$bizNeed.val()];
		$bizNeed.find("option").each(function(index, itm){ 
			if($bizNeed.val() == itm.value) {
				selectValue = itm.innerHTML;			
			}
		});
	} else if($bizIndustry.val() != "default" && $bizIndustry.val() != "all") {
		//resultCopy = SolutionsText[$bizIndustry.val()];
		$bizIndustry.find("option").each(function(index, itm){ 
			if($bizIndustry.val() == itm.value) {
				selectValue = itm.innerHTML;		
			}
		});
	}
	if (selectValue == "") selectValue = $j("#solutionsDrawer div.header h3 SPAN").html();
	if (selectValue == "") selectValue = $j("#solutionsDrawer div.header h3").html();
	var $sifrHeading = $j("#solutionsDrawer div.header h3");
	$sifrHeading.attr("class", "");
	$sifrHeading.html(selectValue);
	//$j("#solutionsDrawer div.header p").html(resultCopy.copy);

	// resifr heading
	$j.Avaya.SifrConfig.masterReplace($j.Avaya.SifrConfig.gothamLight,{
	   selector: '#solutionsDrawer div.header h3',
	   css: {
			'.sIFR-root': { 
				'color': '#cc0000', 
				'font-size': 18
			}
	   },
	   selectable: false
	});	
}


