
// Drop-in content box- By Dynamic Drive
// For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
// This credit MUST stay intact for use

var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"

var bouncelimit=32 //(must be divisible by 8)
var direction="up"

var doNotDrop;

function initbox(){
	if (!dom&&!ie&&!ns4){return;}
	//crossobj=(dom)?document.getElementById("dropinDiv").style : ie? document.all.dropinDiv : document.dropinDiv
	//use findDOM instead, it's better. MWarner
	crossobj=findDOM("dropinDiv",1);
	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
	crossobj.top=scroll_top-250+calunits
	crossobj.visibility="visible";
	dropstart=setInterval("dropin()",50)
}

function dropin(){
	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
	if (parseInt(crossobj.top)<100+scroll_top)
	crossobj.top=parseInt(crossobj.top)+40+calunits
	else{
	clearInterval(dropstart)
	bouncestart=setInterval("bouncein()",50)
	}
}

function bouncein(){
	crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
	if (bouncelimit<0)
	bouncelimit+=8
	bouncelimit=bouncelimit*-1
	if (bouncelimit==0){
	clearInterval(bouncestart)
	}
}

function dismissbox(){
	if (window.bouncestart) clearInterval(bouncestart)
	crossobj.visibility="hidden"
}

function truebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function get_cookie(Name) {
	var search = Name + "="
	var returnvalue = ""
	if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search)
			if (offset != -1) {
			offset += search.length
			end = document.cookie.indexOf(";", offset)
			if (end == -1)
			end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}

function dropornot(){
	return;//don't show it MWarner 7/7/09
	if (get_cookie("droppedin")==""||fromDifferentSite()){
		writeBoxToPage();
		window.onload=initbox
		document.cookie="droppedin=yes"
	}
}


//new functions MWarner

function writeBoxToPage(){
	//code to alternate between the 2 freebie courses
	currentTime = new Date();
	secs=currentTime.getSeconds();
	courseTitle=(secs%2)?"Interviewing Effectively":"Personal Creativity";
	doWhat=(secs%2)?"Advance your career":"Sharpen your creative skills";
	courseID=(secs%2)?3797:3832;
	bgColor=(secs%2)?"FFFFCC":"EFF5FF";//yellow:blue
	
	txt='<div id="dropinDiv" class="program" style="z-index=1000;border:5px double navy;position:absolute;visibility:hidden;left:200px;top:100px;width:420px;height:';
	txt+=(navigator.appName.indexOf("Explorer")>-1)?"200":"230";
	txt+='px;background-color:#'+bgColor+';padding:3px;">';
	if(location.href.indexOf("execlearn.com")>-1){
		txt+='<img src="http://www.execlearn.com/images/wcenter_logo_sm_trans2.gif" align=left style="margin:0px;">';
	}else{
		txt+='<img src="http://crm.mindedge.com/themes/Sugar/images/company_logo.png" align=left style="margin:0px;">';
	}
	txt+='<div align="right" class="program" style="margin-bottom:20px;"><a href="#" onClick="dismissbox();return false" style="color:blue;"><font size="1">[Close Box]</font></a></div>';
	txt+='<center><br><h2 class="bubba">Free Trial Course:</h2><h3><font color="navy">"'+courseTitle+'"</font></h3><strong>'+doWhat+' with this MindEdge online course<p>Enroll here:</strong><p class="program">';
	txt+='<form name="freebieForm" method=get style="margin:0px;" action="http://wcenter.mindedge.com/p/onlineEd/checkLogin.php" onSubmit="return checkFreebieForm()">';
	txt+='<input type=hidden name="c" value="ME:'+courseID+'">';
	txt+='<input type=hidden name="r" value="43">';
	txt+='<input type=hidden name="t" value="3531d595fe5d">';
	txt+='<input type=hidden name="ref" value="">';
	txt+='First Name:<input class="proghram" type=text size=15 maxlength=50 name="firstName" style="height:20px;width:70px;font-size:11px;" onBlur="this.value=freebie_formatName(this.value)">&nbsp;';
	txt+='Last Name:<input class="proghram" type=text size=15 maxlength=50 name="lastName" style="height:20px;width:70px;font-size:11px;" onBlur="this.value=freebie_formatName(this.value)">&nbsp;';
	txt+='Email:<input class="proghram" type=text size=15 maxlength=50 name="email" style="height:20px;width:70px;font-size:11px;" onBlur="this.value=this.value.toLowerCase()"><p class="program">';
	txt+='<input type=submit value="Sign me up!" style="height:20px;width:65px;font-size:11px;">';
	txt+='</form></center>';
	txt+='</div>';
	document.open();
	document.write(txt);
	document.close();
	var theFreebieForm=document.forms["freebieForm"];
	theFreebieForm.ref.value=freebie_getQueryStringValue("ref");
}

function checkFreebieForm(){
	theFreebieForm=document.forms["freebieForm"];
	if(!freebie_validData(theFreebieForm.firstName.value)||!freebie_validData(theFreebieForm.lastName.value)||!freebie_isValidEmail(theFreebieForm.email.value)){
		alert("Please fill in all fields with valid data");
		return false;
	}
	alert("Thank you.\n\nYou will now be sent to the course page.\n\nYou will also receive a confirmation email with login instructions momentarily.")
	return true;
}

function freebie_getQueryStringValue(which){
	tmp = window.location.search.substring(1);
	args = tmp.split("&");
	for (g=0;g<args.length;g++) {
		thisArg = args[g].split("=");
		if (thisArg[0] == which) {
			return thisArg[1];
		}
	}
	return "";//for the times when it's not there, otherwise "undefined" will be the value
}

function freebie_validData(before){
	var reg = new RegExp(/[". "]/g);
	var after=before.replace(reg,'');
	rtnVal=(after=='')?false:true;
	return rtnVal;
}

function freebie_isValidEmail(emailAddress) {
   return (emailAddress.indexOf(".") > 2) && (emailAddress.indexOf("@") > 0);
 }

function fromDifferentSite(){
	//if referrer is not same site as this one, then show it
	returnVal=true;
	if(document.referrer&&document.referrer!=""){
		referrerBits=document.referrer.split("/");
		currentLocBits=document.location.href.split("/");
		if(referrerBits[2]==currentLocBits[2]){
			//alert(referrerBits[2]+"\n"+currentLocBits[2]);
			returnVal=false;
		}
	}else{
		//alert("no referrer")
	}
	
	return returnVal;
}

function freebie_formatName(whichName){
	if(whichName!=whichName.toLowerCase()&&whichName!=whichName.toUpperCase()){return whichName;}
	whichName=whichName.toLowerCase();
	whichNameBits=whichName.split(" ");
	for(g=0;g<whichNameBits.length;g++){
		whichNameBits[g]=whichNameBits[g].substring(0,1).toUpperCase()+whichNameBits[g].substring(1,whichNameBits[g].length);
		if(whichNameBits[g].indexOf("'")>-1){
			whichNameBits[g]=freebie_checkForApostrophe(whichNameBits[g]);
		}
	}
	return whichNameBits.join(" ");

}

function freebie_checkForApostrophe(namePart){
	namePartBits=namePart.split("'");
	for(g=0;g<namePartBits.length;g++){
		namePartBits[g]=namePartBits[g].substring(0,1).toUpperCase()+namePartBits[g].substring(1,namePartBits[g].length);		
	}
	return namePartBits.join("'");
}

if(!doNotDrop){
	//kick it off
	dropornot();
}