var domTT_styleClass;
var domTT_draggable = true;
var domTT_closeLink = "";
var myInterval;
var msg  = '<p><b>Congratulations!</b> You are one step closer to starting your own renewable energy home based business. In just a moment, you will be submitting your order for <b>The New Energy Entrepreneur Package</b>  using our safe &amp; secure order fulfillment system. Once your payment is received, you will receive an email receipt confirming your transaction which you could print out for your records.</p><div align="center"><img src="http://newenergyentrepreneur.com/toppick/images/newEnergyPackageLarge.png" align="center"></div>';
msg     += '<p>Within one  business day, <b>you will receive a phone call</b> from one of our New Business Processing  Managers who will welcome you the business, verify your account information, and help answer any additional questions you may have about your new business. They will also help you choose and set up your own business domain name and  email account as well as walk you through the entire start-up process, so you know exactly what to expect. </p>';
msg     += '<p>Once your domain name is registered, our talented programers will have your website up and running within three business days.  That means you could be marketing your business, and generating sales your very first week!</p>';
msg     += '<p>Remember, <b>you are not alone in your business</b>, because we have a vested interest in your success. The better you do, the better we do. We want to ensure that you have all the tools to get started at full speed and have the opportunity to make as much money as possible. That includes direct access to our customer support. Our trained staff is available <b>Monday - Friday from 10am - 6pm MST</b> to assist you with virtually any aspect of your business. And you will speak to a real person who knows about your business, not an automated operator.</p>';
msg     += '<p>Congratulations again for taking the next step towards running your own business. We look forward to working together to help you <b>reach your goals</b> in business and in life.</p>';
msg     += '<p>Please click on the &quot;Take Me to the Next Step&quot; icon below to continue placing your order.</p>';
msg     += '<p align="center"><a href="#void" onclick="domTT_close(\'popup2\'); domTT_close(this); clearInterval(myInterval); window.scrollBy(0,-1000);"><img src="http://newenergyentrepreneur.com/toppick/images/nextStepArrow.png" border="0"></a></p>';
		
window.onload = function(in_event) {
	openInfo();
	glowArrow();
}
function openInfo() {
	var viewPort  = getViewPort();
	var b = detect();
	var winWidth  = 500;
	var winHeight = (b.ie) ? 1044 : 1034;
	var x = Math.floor((viewPort[0]/2))-Math.floor((winWidth/2));
	
    domTT_addPredefined('popup', 'caption', 'IMPORTANT: Please Read First <div style="position:relative; top:-30px; left:215px;"><a onClick="domTT_close(\'popup2\'); domTT_close(this); clearInterval(myInterval); window.scrollBy(0,-500);" style="cursor:pointer"><img src="http://newenergyentrepreneur.com/toppick/images/close.png" border="0" /></a></div>', 'content', '<div style="text-align: justify; padding: 2px 5px; font-size: 13px; font-family: Arial; background-color: #EEEEEE;">'+msg, 'type', '');
	domTT_addPredefined('bottom', 'caption', '&nbsp;', 'content', '&nbsp;', 'type', '');
	
	domTT_styleClass = 'bottom';
	domTT_activate('popup2', null, 'predefined', 'bottom', 'x', 0, 'y', 0, 'width', viewPort[0], 'height', viewPort[1], 'delay', 1000);
    
	domTT_styleClass = 'niceTitle';
	domTT_activate('popup1', null, 'predefined', 'popup', 'x', x, 'y', 0, 'width', winWidth,'height', winHeight, 'delay', 1000);
	
	myInterval = self.setInterval("updateBottom()",100);

}

function updateBottom() {
	var d = document.getElementById("[domTT]popup2");
	
	var viewPort   = getViewPort();
	var scrollAmt  = getScrollXY();
	var limiter    = 780;
	
	d.style.height = viewPort[1];
	d.style.width  = viewPort[0]; 
	if (scrollAmt[1] <= limiter) {
		d.style.top = (scrollAmt[1])+"px";
	}
}

function submitForm() {
	var d = document.getElementById("TOS");
	if (d.checked == true) {
		window.location.href = "https://bluehorizons.infusionsoft.com/cart/?update=true&l=n&product_id=42&cart_skin=3";
	} else {
		alert("Please read and accept the Terms of Service Agreement to continue");
	}
}

function glowArrow() {
	var d = document.getElementById("TOS");
	var a = document.getElementById("next");
	if (d.checked == true) {
		a.src="http://newenergyentrepreneur.com/toppick/images/nextStepArrowSmall.gif";
	} else {
		a.src="http://newenergyentrepreneur.com/toppick/images/nextStepArrowSmall.png";
	}
}

/*-----------------------------------------------------------------------------------------------------------------------------------
--- AJAX PROMO CODE HANDLER
------------------------------------------------------------------------------------------------------------------------------------*/

var xmlHttp;
function GetXmlHttpObject() {
   xmlHttp=null;
   try{
       // Firefox, Opera 8.0+, Safari
       xmlHttp=new XMLHttpRequest();
   }
   catch(e){
       //IE
           try{
               xmlHttp=new ActiveXObject("Msxml2.xmlHttp");
           }
           catch(e){
               xmlHttp=new ActiveXObject("Microsoft.xmlHttp");
           }
       }
   if (xmlHttp == null){
       alert("Your Browser does not support AJAX!");
       return;
   }
   return xmlHttp;
}
function promoCode(){
   xmlHttp=GetXmlHttpObject();
   var c=document.getElementById("promo").value;
   
   var url  = "promocode.php";
   	   url += "?c="+c;
   
   xmlHttp.onreadystatechange=StateChanged;
   xmlHttp.open("Get",url,true);
   xmlHttp.send(null);
}
function StateChanged(){
	if (xmlHttp.readyState==4){
		var d = document.theForm;
		if (xmlHttp.responseText != "false" ) {
			var qty = parseInt(d.itemquant.value);  
			var info = xmlHttp.responseText.split("|");  
			
			document.getElementById("promos").innerHTML = "<p>"+info[1]+"</p>";                         
			var price = (qty*info[0]).toString(); 
			price = (price.indexOf(".") > -1) ? price : price+".00";
			document.getElementById("total").innerHTML = "$"+price;
			d.itemprice.value = info[0];
			
			var c = document.getElementById("promo").value;
			c = c.substr(c.length-1,1).toUpperCase();
			d.itemid.value = "NEE169"+c;
		} else {
			d.itemprice.value = "349.00";
			d.itemid.value = "NEE169"
			document.getElementById("promos").innerHTML = ""; 
			document.getElementById("total").innerHTML = "$349.00";
		}
	}
}

