﻿$(function(){

	$('.family_a').bind( 'click', getFamily );
	$('.family_a:first').trigger('click');
	
	//getDetailsFamily( $('.family_a:first').attr('FID')  );

	$('.product_a').bind( 'click', getProduct );
	
	$(".outline .root1 li").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over");});
 	
	$(".outline .root1 strong:even").addClass("zebra");
	$(".productChild li:odd").addClass("odd");
	$(".productChild li:even").addClass("even");
	//pid = $.cookie('pid');
	//fid = $.cookie('fid');


});

var getFamily = function(e){

	 itsMe = $(this).hasClass('expanded');
	 if(!itsMe) $('.expanded').removeClass('expanded').siblings('.productChild').slideUp();
	 $(this).toggleClass('expanded').parent('.root1').find('.productChild').slideToggle();
	 $('.clicked').removeClass('clicked');
	 
	 $(this).addClass('clicked').addClass('expanded');
	 getDetailsFamily($(this).attr('SID'),$(this).attr('IID'),$(this).attr('AID'))
	// $.cookie('fid', $(this).attr('FID'));
	/// $.cookie('pid', null);

	 return false;
}

var getProduct = function(e){
	$('.clicked').removeClass('clicked');
	$(this).addClass('clicked');
	getDetails($(this).attr('SID'), $(this).attr('IID'),$(this).attr('AID') ,$(this).attr('PID'));	
//	$.cookie('pid', $(this).attr('PID'));
//	$.cookie('fid', $(this).attr('FID'));

	return false;
}

function getDetailsFamily( sID, iID, aID){
//	$('#loadBuffer').load('load_detail_solution_appl.asp', { SID: sID, IID: iID, AID: aID}, refreshData1 );
	$('#CollapsiblePanel2').css('display', 'none');
	$('#loadBuffer').load('/sgi/load_detail_solution_appl.aspx', { SID: sID, IID: iID, AID: aID, sURL: window.location}, refreshData1 );
	return false;
}

function getDetails( sID, iID, aID, pID ){
//	$('#loadBuffer').load('load_detail_solution_prod.asp', { SID: sID, IID: iID, AID: aID, PID: pID}, refreshData2 );
	$('#CollapsiblePanel2').css('display', 'block');
	$('#loadBuffer').load('/sgi/load_detail_solution_prod.aspx', { SID: sID, IID: iID, AID: aID, PID: pID, sURL: window.location}, refreshData2 );
	return false;
}


var refreshData1 = function(){

	$(document).ready( function(){
			var a = new Array();
			$(".detailAppl").children("p").each(function(x){
					test = false;
					b = a[x] = $(this).html();
					for (i=0;i<a.length-1;i++){
							if (b ==a[i]) test =true;
					}
					if (test) $(this).remove();
			})
	}); 

	$('#CollapsiblePanel1 .CollapsiblePanelContent').html( $('.detailAppl').html() ).css('height', 'auto');
	$('#CollapsiblePanel2 .CollapsiblePanelContent').html( '' ).css('height', 'auto');
}

var refreshData2 = function(){

	$(document).ready( function(){
			var a = new Array();
			$(".detailProd").children("p").each(function(x){
					test = false;
					b = a[x] = $(this).html();
					for (i=0;i<a.length-1;i++){
							if (b ==a[i]) test =true;
					}
					if (test) $(this).remove();
			})
	}); 

	//$('#CollapsiblePanel1 .CollapsiblePanelContent').html( $('.detailAppl').html() ).css('height', 'auto');
	$('#CollapsiblePanel2 .CollapsiblePanelContent').html( $('.detailProd').html() ).css('height', 'auto');
	window.scrollBy(0,10000);
}

