// JavaScript Document
function PreloadImages()
{
	var viewportheight, blanket_height;
	var viewportwidth, blanket_width;
	
	if (typeof window.innerHeight != 'undefined') 
	{
		viewportheight = window.innerHeight;
	} 
	else 
	{
		viewportheight = document.documentElement.clientHeight;
	}
	
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) 
	{
		blanket_height = viewportheight;
	} 
	
	else 
	{
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) 
		{
			blanket_height = document.body.parentNode.clientHeight;
		} 
		
		else 
		{
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	
	if (typeof window.innerWidth != 'undefined') 
	{
		viewportwidth = window.innerHeight;
	} 
	
	else 
	{
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) 
	{
		blanket_width = viewportwidth;
	} 
	
	else 
	{
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) 
		{
			blanket_width = document.body.parentNode.clientWidth;
		} 
		
		else 
		{
			blanket_width = document.body.parentNode.scrollWidth;
		}
	}
	
	//Subtract half the width and height of popup
	document.getElementById("System").style.left = (blanket_width /2) - 100 +"px";  
	document.getElementById("System").style.top = "275px";
	document.getElementById("System").style.display = "block";
	
	imageObj = new Image();
	images = new Array();
	
	//Build Images array
	images[1] = "/images/backgroundgradient.png"
	images[2] = "/images/BenefitsColumn.png"
	images[3] ="/images/ChannelBanner.png"
	images[4] ="/images/ColumnSeparator.png"
	images[5] ="/images/CWLogo.png"
	images[6] ="/images/dimmerBG.png"
	images[7] ="/images/DropDownBG.png"
	images[8] ="/images/FlashBackground.png"
	images[9] ="/images/FlashBackgroundHome.png"
	images[10] ="/images/FlashBottomLeftBackground.png"
	images[11] ="/images/FlashRepeatBackground.gif"
	images[12] ="/images/FlashRepeatBackground.png"
	images[13] ="/images/FlashRightBackground.png"
	images[14] ="/images/getmorebanner.jpg"
	images[15] ="/images/InputBackground.png"
	images[16] ="/images/InsideBackground.png"
	images[17] ="/images/kellyolson.png"
	images[18] ="/images/LeftTextWealthHR.png"
	images[19] ="/images/ListDash.png"
	images[20] ="/images/LoginButton.png"
	images[21] ="/images/MainBottomLeft.png"
	images[22] ="/images/MainBottomRepeat.png"
	images[23] ="/images/MainBottomRight.png"
	images[24] ="/images/MainLeftRepeat.png"
	images[25] ="/images/MainRightRepeat.png"
	images[26] ="/images/MainUpperLeft.png"
	images[27] ="/images/MainUpperRepeat.png"
	images[28] ="/images/MainUpperRight.png"
	images[29] ="/images/NavBarBackground.png"
	images[30] ="/images/popupbg.png"
	images[31] ="/images/popuplargebg.png"
	images[32] ="/images/SearchBackground.png"
	images[33] ="/images/TitleHR.png"

//Iterage through all images
	for(var i=0; i <= images.length; i++)
	{
		//Make a call to image to load into cache
		imageObj.src=images[i];
		
		if (i = images.length)
		{
			//After iterating run the function
			imageObj.onLoad = imagesLoaded();
		}
	}
	

}

function imagesLoaded()
{
	//Display the Main Container
	document.getElementById("MainContainer").style.display = "block";
	
	//Hide the loading screen
	document.getElementById("System").style.display = "none";

}

function WealthPopup()
{
	var viewportheight, blanket_height;
	var viewportwidth, blanket_width;
	
	if (typeof window.innerHeight != 'undefined') 
	{
		viewportheight = window.innerHeight;
	} 
	else 
	{
		viewportheight = document.documentElement.clientHeight;
	}
	
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) 
	{
		blanket_height = viewportheight;
	} 
	
	else 
	{
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) 
		{
			blanket_height = document.body.parentNode.clientHeight;
		} 
		
		else 
		{
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	
	if (typeof window.innerWidth != 'undefined') 
	{
		viewportwidth = window.innerHeight;
	} 
	
	else 
	{
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) 
	{
		blanket_width = viewportwidth;
	} 
	
	else 
	{
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) 
		{
			blanket_width = document.body.parentNode.clientWidth;
		} 
		
		else 
		{
			blanket_width = document.body.parentNode.scrollWidth;
		}
	}
	
	document.getElementById("Dimmer").style.height = blanket_height +"px";
	document.getElementById("Dimmer").style.width = blanket_width +"px";
	document.getElementById("Dimmer").style.display = "block";
	
	//Subtract half the width and height of popup
	document.getElementById("WealthPopup").style.left = (blanket_width / 2) - 150 +"px";  
	document.getElementById("WealthPopup").style.top = "275px";
	document.getElementById("WealthPopup").innerHTML = "<div style=\"font-size:14px\; font-weight:bold\; padding-top:25px\;\">You are now leaving Channel Financial</div><br/><br/>Click <b>OK</b> to continue to Channel Wealth<br/>or<br/>Click <b>BACK</b> to return to Channel Financial<p><br/><form><input type=\"button\" value=\"OK\" style=\"width:75px\;\" onclick=\"GoToWealth()\; return false\;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\"BACK\" style=\"width:75px\;\" onclick=\"HidePopup()\; return false\;\"></form>";
	document.getElementById("WealthPopup").style.display = "block";
	
	
}

function LeavingPopup(URL)
{
	var viewportheight, blanket_height;
	var viewportwidth, blanket_width;
	var gotoURL = URL.href;
	
	if (typeof window.innerHeight != 'undefined') 
	{
		viewportheight = window.innerHeight;
	} 
	else 
	{
		viewportheight = document.documentElement.clientHeight;
	}
	
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) 
	{
		blanket_height = viewportheight;
	} 
	
	else 
	{
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) 
		{
			blanket_height = document.body.parentNode.clientHeight;
		} 
		
		else 
		{
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	
	if (typeof window.innerWidth != 'undefined') 
	{
		viewportwidth = window.innerHeight;
	} 
	
	else 
	{
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) 
	{
		blanket_width = viewportwidth;
	} 
	
	else 
	{
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) 
		{
			blanket_width = document.body.parentNode.clientWidth;
		} 
		
		else 
		{
			blanket_width = document.body.parentNode.scrollWidth;
		}
	}
	
	document.getElementById("Dimmer").style.height = blanket_height +"px";
	document.getElementById("Dimmer").style.width = blanket_width +"px";
	document.getElementById("Dimmer").style.display = "block";
	
	//Subtract half the width and height of popup
	document.getElementById("WealthPopup").style.left = (blanket_width / 2) - 150 +"px";  
	document.getElementById("WealthPopup").style.top = "275px";	
	document.getElementById("WealthPopup").innerHTML = "<div style=\"font-size:14px\; font-weight:bold\; padding-top:25px\;\">You are now leaving Channel Wealth</div><br/><br/>Click <b>OK</b> to continue to Channel Financial<br/>or<br/>Click <b>BACK</b> to return to Channel Wealth<p><br/><form><input type=\"button\" value=\"OK\" style=\"width:75px\;\" onclick=\"GoToFinancial(\'" + gotoURL + "\')\; return false\;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\"BACK\" style=\"width:75px\;\" onclick=\"HidePopup()\; return false\;\"></form>";
	document.getElementById("WealthPopup").style.display = "block";
	
}

function SchwabPopup()
{
	var viewportheight, blanket_height;
	var viewportwidth, blanket_width;
	
	if (typeof window.innerHeight != 'undefined') 
	{
		viewportheight = window.innerHeight;
	} 
	else 
	{
		viewportheight = document.documentElement.clientHeight;
	}
	
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) 
	{
		blanket_height = viewportheight;
	} 
	
	else 
	{
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) 
		{
			blanket_height = document.body.parentNode.clientHeight;
		} 
		
		else 
		{
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	
	if (typeof window.innerWidth != 'undefined') 
	{
		viewportwidth = window.innerHeight;
	} 
	
	else 
	{
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) 
	{
		blanket_width = viewportwidth;
	} 
	
	else 
	{
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) 
		{
			blanket_width = document.body.parentNode.clientWidth;
		} 
		
		else 
		{
			blanket_width = document.body.parentNode.scrollWidth;
		}
	}
	
	document.getElementById("Dimmer").style.height = blanket_height +"px";
	document.getElementById("Dimmer").style.width = blanket_width +"px";
	document.getElementById("Dimmer").style.display = "block";
	
	//Subtract half the width and height of popup
	document.getElementById("WealthPopupLarge").style.left = (blanket_width / 2) - 300 +"px";  
	document.getElementById("WealthPopupLarge").style.top = "200px";
	document.getElementById("WealthPopupLarge").innerHTML = "<div style=\"font-size:12pt\; padding-top:30px\;\">You are now leaving the \"Channel Wealth\" website and will be entering the Charles Schwab &amp; Co., Inc. (\"Schwab\") website.<br/><br/>Schwab is a registered broker-dealer, and is not affiliated with \"Channel Wealth\" or any advisor(s) whose name(s) appear(s) on this website.  \"Channel Wealth\" is/are independently owned and operated.  Schwab neither endorses nor recommends \"Channel Wealth\", unless you have been referred to us through the Schwab Advisor Network&reg;.  Regardless of any referral or recommendation, Schwab has agreements with \"Channel Wealth\" under which Schwab provides \"Channel Wealth\" with services related to your account.  Schwab does not review the \"Channel Wealth\" website(s), and makes no representation regarding information contained in the \"Channel Wealth\" website, which should not be considered to be either a recommendation by Schwab or a solicitation of any offer to purchase or sell any securities.</div><p><br/><br/><form><input type=\"button\" value=\"Continue\" style=\"width:75px\;\" onclick=\"GoToSchwab()\; return false\;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\"Go Back\" style=\"width:75px\;\" onclick=\"HideLargePopup()\; return false\;\"></form>";
	document.getElementById("WealthPopupLarge").style.display = "block";
	
	
}


function HidePopup()
{
	document.getElementById("WealthPopup").style.display = "none";
	document.getElementById("Dimmer").style.display = "none";
}
function HideLargePopup()
{
	document.getElementById("WealthPopupLarge").style.display = "none";
	document.getElementById("Dimmer").style.display = "none";
}


function GoToWealth()
{
	window.location.href = 'http://www.channel-wealth.com';	
}

function GoToFinancial(URL)
{
	window.location.href = URL;
}

function GoToSchwab()
{
	window.open('http://www.schwaballiance.com');
	document.getElementById("WealthPopupLarge").style.display = "none";
	document.getElementById("Dimmer").style.display = "none";
}
