﻿PreloadImages();

var preloadFlag = false;

function NewImage(arg)
{
	if (document.images)
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function PreloadImages()
{
	if (document.images)
	{	
		subscribe = NewImage("Resources/System/Images/Button/subscribe.gif.gif");
		subscribe_over = NewImage("Resources/System/Images/Button/subscribe_over.gif.gif");
		subscribe_down = NewImage("Resources/System/Images/Button/subscribe_down.gif.gif");
		
		preloadFlag = true;				
	}
}

function ChangeImages()
{    
	if (document.images && (preloadFlag == true))
	{
		for (var i=0; i<changeImages.arguments.length; i+=2)
		{
			document[ChangeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function ChangeImagesArray(array)
{
	if (preloadFlag == true) 
	{
		var d = document; 
		var img;
		
		for (var i=0; i<array.length; i+=2) 
		{
			var n = array[i];
			
			img = null;
			
			if (d.images) {img = d.images[n];}
			if (!img && d.getElementById) {img = d.getElementById(n);}
			if (img) {img.src = array[i+1];}
		}
	}
}

function GoToInfusionCart()
{
	var lngCartCount = 0;

	if (document.forms["aspnetForm"].financials.checked == true)
	{
		lngCartCount = lngCartCount + 1;
	}
	if (document.forms["aspnetForm"].energies.checked == true)
	{
		lngCartCount = lngCartCount + 1;
	}	
	if (document.forms["aspnetForm"].softs.checked == true)
	{
		lngCartCount = lngCartCount + 1;
	}	
	if (document.forms["aspnetForm"].grains.checked == true)
	{
		lngCartCount = lngCartCount + 1;
	}
	if (document.forms["aspnetForm"].metals.checked == true)
	{
		lngCartCount = lngCartCount + 1;
	}
	if (lngCartCount == 0)
	{
		alert('You must select a sector to subscribe!');
	}
	else
	{
		switch (lngCartCount)
		{
			case 1:
			    if (document.forms["aspnetForm"].financials.checked == true)
				    document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nirhnat";
				else if (document.forms["aspnetForm"].energies.checked == true) 
				    document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nilrhnat";
				else if (document.forms["aspnetForm"].softs.checked == true) 
				    document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/niewhnat";
				else if (document.forms["aspnetForm"].grains.checked == true) 
				    document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nirlhnat";				    
				else if (document.forms["aspnetForm"].metals.checked == true) 
				    document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nirrhnat";				    
				break;
			case 2:
			    if (document.forms["aspnetForm"].financials.checked == true && document.forms["aspnetForm"].energies.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/niihnat";
			    else if (document.forms["aspnetForm"].financials.checked == true && document.forms["aspnetForm"].softs.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nifwhnat";			    
			    else if (document.forms["aspnetForm"].financials.checked == true && document.forms["aspnetForm"].grains.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nifihnat";			        
			    else if (document.forms["aspnetForm"].financials.checked == true && document.forms["aspnetForm"].metals.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/niufhnat";			        
			    else if (document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].softs.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/niefhnat";			        
			    else if (document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].grains.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nillhnat";			        
			    else if (document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].metals.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nilihnat";			        
			    else if (document.forms["aspnetForm"].softs.checked == true && document.forms["aspnetForm"].grains.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nieihnat";
			    else if (document.forms["aspnetForm"].softs.checked == true && document.forms["aspnetForm"].metals.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nierhnat";
			    else if (document.forms["aspnetForm"].grains.checked == true && document.forms["aspnetForm"].metals.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nirfhnat";			        
				break;
			case 3:
			    if (document.forms["aspnetForm"].financials.checked == true && document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].softs.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/niffhnat";			        
			    else if (document.forms["aspnetForm"].financials.checked == true && document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].grains.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/niulhnat";			        			
			    else if (document.forms["aspnetForm"].financials.checked == true && document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].metals.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/niurhnat";			        
			    else if (document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].softs.checked == true && document.forms["aspnetForm"].grains.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nilfhnat";			
			    else if (document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].softs.checked == true && document.forms["aspnetForm"].metals.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nilwhnat";			
			    else if (document.forms["aspnetForm"].softs.checked == true && document.forms["aspnetForm"].grains.checked == true && document.forms["aspnetForm"].metals.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nielhnat";			
				break;
			case 4:
			    if (document.forms["aspnetForm"].financials.checked == true && document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].softs.checked == true && document.forms["aspnetForm"].grains.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/niflhnat";
			    else if (document.forms["aspnetForm"].financials.checked == true && document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].softs.checked == true && document.forms["aspnetForm"].metals.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/niuwhnat";
			    else if (document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].softs.checked == true && document.forms["aspnetForm"].grains.checked == true && document.forms["aspnetForm"].metals.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/niuihnat";			
				break;
			case 5:
			    if (document.forms["aspnetForm"].financials.checked == true && document.forms["aspnetForm"].energies.checked == true && document.forms["aspnetForm"].softs.checked == true && document.forms["aspnetForm"].grains.checked == true && document.forms["aspnetForm"].metals.checked == true)
			        document.forms["aspnetForm"].action = "https://dynamic.infusionsoft.com/saleform/nifrhnat";			        						        			        						        			        						        			        						
				break;
		}
		document.forms.aspnetForm.submit();
	}
}