// JavaScript Document

var needs = new Array();
needs['reduce'] = new Array();
needs['disaster'] = new Array();
needs['control'] = new Array();
needs['automation'] = new Array();
					
needs['reduce']["VMware Infrastructure 3"] = new Array("Enterprise-Class Virtualization", "Create a self-optimizing infrastructure with the most widely deployed virtual infrastructure suite.", "/products/vi/", "Learn More", "http://www.vmware.com/a/buylink/1", "Buy Now");
needs['reduce']["VMware vCenter Server"] = new Array("Manage and Automate your IT Infrastructure", "Optimize resources and high availability by provisioning and monitoring performance of physical servers and virtual machines.", "/products/vi/vc/", "Learn More", "http://www.vmware.com/a/buylink/1", "Buy Now");
needs['reduce']["VMware VMotion"] = new Array("Migrate Virtual Machines with Zero Downtime", "Move an entire virtual machine from one physical server to another instantly, with zero downtime. ", "/products/vi/vc/vmotion.html", "Learn More", "http://www.vmware.com/a/buylink/1", "Buy Now");
needs['reduce']["VMware DRS"] = new Array("Dynamic Scheduling of System Resources", "Allocate and balance IT resources dynamically based on business needs.", "/products/vi/vc/drs.html", "Learn More", "http://www.vmware.com/a/buylink/1", "Buy Now");
					
needs['disaster']["VMware VMotion"] = new Array("Migrate Virtual Machines with Zero Downtime", "Move an entire virtual machine from one physical server to another instantly, with zero downtime. ", "/products/vi/vc/vmotion.html", "Learn More", "http://www.vmware.com/a/buylink/1", "Buy Now");
needs['disaster']["VMware DRS"] = new Array("Dynamic Scheduling of System Resources", "Allocate and balance IT resources dynamically based on business needs. ", "/products/vi/vc/drs.html", "Learn More", "http://www.vmware.com/a/buylink/1", "Buy Now");
					
needs['control']["VMware Infrastructure 3"] = new Array("Enterprise-Class Virtualization", "Create a self-optimizing infrastructure with the most widely deployed virtual infrastructure suite.", "/products/vi/", "Learn More", "http://www.vmware.com/a/buylink/1", "Buy Now");
needs['control']["VMware vCenter Server"] = new Array("Manage and Automate your IT Infrastructure", "Optimize resources and high availability by provisioning and monitoring performance of physical servers and virtual machines.", "/products/vi/vc/", "Learn More", "http://www.vmware.com/a/buylink/1", "Buy Now");
needs['control']["VMware View"] = new Array("Simplify Desktop Management", "Manage and deploy virtual desktops from the datacenter. ", "/products/view/", "Learn More", "http://www.vmware.com/a/buylink/65", "Buy Now");
					
needs['automation']["VMware VMotion"] = new Array("Migrate Virtual Machines with Zero Downtime", "Move an entire virtual machine from one physical server to another instantly, with zero downtime. ", "/products/vi/vc/vmotion.html", "Learn More", "http://www.vmware.com/a/buylink/1", "Buy Now");
needs['automation']["VMware DRS"] = new Array("Dynamic Scheduling of System Resources", "Allocate and balance IT resources dynamically based on business needs.", "/products/vi/vc/drs.html", "Learn More", "http://www.vmware.com/a/buylink/1", "Buy Now");
					
jQuery(function() {
	bindCategory();												
});	
					
function bindCategory() {
	tabContainers = "";
						
	var htmlCode = "";
	var liCode = "";	
	var element = "";
						
	htmlCode = "<ul>";						
	liCode = '<li id="reduce">Reduce Costs with Server Consolidation</li>';
	htmlCode += liCode;	
	liCode = '<li id="disaster">Business Continuity & Disaster Recovery</li>';
	htmlCode += liCode;	
	liCode = '<li id="control">Desktop Management & Control</li>';
	htmlCode += liCode;				
	liCode = '<li id="automation">Virtual Lab Automation</li>';
	htmlCode += liCode;	
	htmlCode += "</ul>";
	jQuery("#filter-category").html(htmlCode);

	tabContainers = jQuery('div#filter-category > ul > li');
						
	jQuery("#reduce").bind('click', function(event){
		tabContainers.removeClass("active");
		jQuery("#reduce").addClass("active");							
		bindProduct(jQuery("#reduce").attr("id"));
	});					
						
	jQuery("#disaster").bind('click', function(event){
		tabContainers.removeClass("active");
		jQuery("#disaster").addClass("active");
		bindProduct(jQuery("#disaster").attr("id"));
	});
						
						
	jQuery("#control").bind('click', function(event){
		tabContainers.removeClass("active");
		jQuery("#control").addClass("active");
		bindProduct(jQuery("#control").attr("id"));
	});
						
												
	jQuery("#automation").bind('click', function(event){
		tabContainers.removeClass("active");
		jQuery("#automation").addClass("active");
		bindProduct(jQuery("#automation").attr("id"));						
	});
};
						
function bindProduct(data) {
												
	var htmlCode = "";						
	htmlCode += "<ul>";
	for(var key in needs[data]) {
		htmlCode += "<li>" + key + "</li>";
	}

	htmlCode += "</ul>";
	jQuery("#filter-product").html(htmlCode);
						
	var subTabContainers = jQuery('div#filter-product > ul > li');
						
	jQuery('#filter-product ul li').each(function(){							
		jQuery(this).bind('click', function(event){
			subTabContainers.removeClass("active");
			jQuery(this).addClass("active");
			getProductDetails(needs[data], jQuery(this).html());
		});
	});
};
						
function getProductDetails(dataArray, data) {
	var htmlCode = "<div id='version-content'>\n";
	for(var i = 0; i < dataArray[data].length; i++) {
		htmlCode += '<span id="heading">'+data+"</span>\n";
		htmlCode += "<span id='subheading'>"+dataArray[data][i]+"</span>\n";
		i++;
		htmlCode += "<span id='content-text'>"+dataArray[data][i]+"</span>\n";
		i++;
		htmlCode += "<span id='links'><a href='"+ dataArray[data][i] +"'>";
		i++;
		htmlCode += dataArray[data][i]+"</a>";
		i++;
		if(i < dataArray[data].length) {
			htmlCode += "<a href='"+ dataArray[data][i] +"'>";
			i++;
			htmlCode += dataArray[data][i]+"</a></span>\n</div>\n";
		} else {
			htmlCode += "</span>\n</div>\n";
		}
	}
											
	jQuery("#filter-version").html(htmlCode);
};

