//iframe bust
//if my.clickdensity.com, let site be iframed
/*if (document.location.host !== 'my.clickdensity.com'){
	if (top !== self) top.location.replace(self.location.href);
	if (parent.frames.length > 0) top.location.replace(document.location);
	}*/

	/*This code is required for the dart adServer*/
	<!--
	var axel = Math.random() + "";
	var ord = axel * 1000000000000000000;
	//-->
	var fadeDivcount = 1;
	var solveDivcount = 1;

	function ShowHideDiv(div){
		var wDiv=document.getElementById(div);
		if (wDiv.style.display==''|'block'){wDiv.style.display='none';}
		else if (wDiv.style.display=='none'){wDiv.style.display='';}
	}

/*
	function arrowswitch(div){
		var wDiv=document.getElementById(div);
		alert(wDiv.style.background.background-image);
		if (wDiv.style.background=="background-image: url(../images/arrow_orange_over.jpg)"){wDiv.style.background="background-image: url('images/arrow_orange_up.jpg'"}
		else if (wDiv.style.background="background-image: url(images/arrow_orange_over.jpg)"){wDiv.style.background="background-image: url('images/arrow_orange_up.jpg')"}
	}
*/

String.prototype.count=function(s1) {
	return (this.length - this.replace(new RegExp(s1,"g"), '').length) / s1.length;
}

	function fadeIt(ele,url,div){
	var n = new Spry.Utils.Notifier();
	// Turn off any notifications, until we
	// are ready.
	n.disableNotifications();

	//Spry.Utils.updateContent(ele, url);
	try{
	t=document.getElementById(div).innerHTML;
	Spry.Effect.DoFade(div,{ duration: 1000, from: 100, to: 0, finish: function() {
		//document.getElementById(div).style.display='none';
		Spry.Utils.updateContent(ele, url, function() {
			Spry.Effect.DoFade(div,{ duration: 1000, from: 0, to: 100 });
			t1=setTimeout("fadeIt('QuestionSolve','ajax/solve.cfm','"+div+"');",7000);
		});
	  }
	 });
	}
	 catch(err){
	 	alert(err);

	 	//window.location.reload(true);

	 }


	 	 /*
	  //Spry.Utils.updateContent(ele, url);
	Spry.Effect.Slide(div, {horizontal: true, finish: function() {
		Spry.Utils.updateContent(ele, url, function() {
			Spry.Effect.Slide(div, {horizontal: true});
		});
	  }
	 });
	  */
	}

	function fadeItSolve(){
		if (solveDivcount == 5){solveDivcount=0;}
		solveDivcount=solveDivcount+1;

		var div = 'SolveQuestion' + solveDivcount;
		var newHREF = 'solveHREF' + solveDivcount;

		Spry.Effect.DoFade('AskFindSolveQuestion', {duration: 1000, from: 100, to: 0, finish: function(){

		var newText = document.getElementById(div).innerHTML;
		document.getElementById('AskFindSolveQuestion').innerHTML = newText;

		document.getElementById('solveHREF').href = document.getElementById(newHREF).href;

		Spry.Effect.DoFade('AskFindSolveQuestion', {duration: 1000, from: 0, to: 100});

		}});

		t2=setTimeout("fadeItSolve();",7000);

	}

	function fadeItFeaturedMedia(){
		if (fadeDivcount == 5){fadeDivcount=0;}
		fadeDivcount=fadeDivcount+1;

		var div = 'mediacenter_leftcolumn' + fadeDivcount;

		Spry.Effect.DoFade('mediacenter_leftcolumn', {duration: 1000, from: 100, to: 0, finish: function(){

		var newText = document.getElementById(div).innerHTML;
		document.getElementById('mediacenter_leftcolumn').innerHTML = newText;

		Spry.Effect.DoFade('mediacenter_leftcolumn', {duration: 1000, from: 0, to: 100});

		}});

		t2=setTimeout("fadeItFeaturedMedia();",7000);

	}

	function fadeItFeaturedMedia3(){
		if (fadeDivcount == 3){fadeDivcount=0;}
		fadeDivcount=fadeDivcount+1;

		var div = 'mediacenter_leftcolumn' + fadeDivcount;

		Spry.Effect.DoFade('mediacenter_leftcolumn', {duration: 1000, from: 100, to: 0, finish: function(){

		var newText = document.getElementById(div).innerHTML;
		document.getElementById('mediacenter_leftcolumn').innerHTML = newText;

		Spry.Effect.DoFade('mediacenter_leftcolumn', {duration: 1000, from: 0, to: 100});

		}});

		t2=setTimeout("fadeItFeaturedMedia3();",7000);

	}

	function fadeItFeaturedMedia2(){
		if (fadeDivcount == 2){fadeDivcount=0;}
		fadeDivcount=fadeDivcount+1;

		var div = 'mediacenter_leftcolumn' + fadeDivcount;

		Spry.Effect.DoFade('mediacenter_leftcolumn', {duration: 1000, from: 100, to: 0, finish: function(){

		var newText = document.getElementById(div).innerHTML;
		document.getElementById('mediacenter_leftcolumn').innerHTML = newText;

		Spry.Effect.DoFade('mediacenter_leftcolumn', {duration: 1000, from: 0, to: 100});

		}});

		t2=setTimeout("fadeItFeaturedMedia2();",7000);

	}

	function checkUncheck(field,ctrl){
		//alert(field);
		if (ctrl.checked==true) checkAll(field);
		else uncheckAll(field);

	}



	function checkAll(field)
	{
	for (i = 0; i < field.length; i++)
		field[i].checked = true ;
	}

	function uncheckAll(field)
	{
	for (i = 0; i < field.length; i++)
		field[i].checked = false ;
	}

	function clear(CleartextBox)
	{
	if (CleartextBox.defaultValue == CleartextBox.value)
	CleartextBox.value = ""
	}


	/*Universal Function to clear text box from the default text
	ctrl is the object that is to be cleared and txt is the default txt
	if the the value = the default they the txt is cleared
	*/
	function CleartextBox(ctrl, txt){
	if (ctrl.value==txt){
			ctrl.value='';
		}
	}
	//PrintArticle
	function PrintArticle(id,typeid)
	{
		window.open('/printer_friendly.cfm?externalID='+id+'&externaltypeid='+typeid);
		//ColdFusion.Window.create('ArticlePrint', 'Print','printer_friendly.cfm?externalID='+id,{x:100,y:100,height:600,width:1000,modal:false,closable:true,draggable:true,resizable:true,center:true,initshow:true,minheight:200,minwidth:200})

	}

	//Function that allows the system to see if the user is logged in
	//Function requires: CFAJAxproxy cfc="org.Controller.LoginController" jsclassname="LoginController"
	function isLoggedIn(){
		
		var loggedin= new LoginController();
		loggedin.setReturnFormat('plain');
		var check=loggedin.isLoggedIn();
		return check;
	}

	// same function as above, but returns "true" or "false" for use in submitting forms.
	function isLoggedIn2(){
		var loggedin= new LoginController();
		loggedin.setReturnFormat('plain');
		var check=loggedin.isLoggedIn();

		if(check==0){
			alert('Please Sign In to report possible abuse.');
			return false;
			}
		else
			return true;
	}


	//Login Functions called from CFWIndow
	function JSLogin(){
		var loginFlag = true;
		var LoginJS = new LoginController();
	    var VoidLg=LoginJS.Main('Login',document.getElementById("LoginForm").MemberTypeID.value,document.getElementById("LoginForm").Username.value,document.getElementById("LoginForm").Password.value);
		if (VoidLg == 0){
			alert("Your Username or Password are incorrect or you are not an Admin User.");
			window.document.LoginForm.Username.focus();
			loginFlag = false;
			}
		else{
			if (VoidLg == -1){
				// show update profile page.
				window.location.href="updateProfile.cfm";
				}
			else{
				//window.location.href=window.location.href;
				window.location.reload(true);
				}
		}
		return loginFlag;
	}
	
	function JSLoginDefault(){
		var loginFlag = true;
		var LoginJS = new LoginController();
	    var VoidLg=LoginJS.Main('Login',document.getElementById("LoginFormDefault").MemberTypeID.value,document.getElementById("LoginFormDefault").Username.value,document.getElementById("LoginFormDefault").Password.value);
		if (VoidLg == 0){
			alert("Your Username or Password are incorrect or you are not an Admin User.");
			document.getElementById("LoginFormDefault").Username.focus();
			loginFlag = false;
			}
		else{
			if (VoidLg == -1){
				// show update profile page.
				window.location.href="updateProfile.cfm";
				}
			else{
				//window.location.href=window.location.href;
				window.location.reload(true);
				}
		}
		return loginFlag;
	}
	
	function JSLoginAjax(){
		$.ajax({
			type: "post",
			url: "org/controller/LoginController.cfc",
			data: {
				method: "Main",
				Action: "Login",
				MemberTypeID: 1,
				UserName: $("#UsernameGigya").val(),
				Password: $("#PasswordGigya").val()
				},
			dataType: "html",
			// AJAX response handler.
			success: function( objResponse ){
				//alert(objResponse);
				if(objResponse.search("<string>1</string>") > 0) {
					window.location.reload(true);
				} else {
					alert("Your Username or Password are incorrect.");
				}
			},
			error: function( objResponse ){
				//alert("error");
			}	
		});
	}


   //End Login Functions called from CFWIndow


   // Logout Function
   function JSLogout(){
   		var LoginJS = new LoginController();
   		LoginJS.Logout();

   		// if user is on messages.cfm and has guid, removed guid before refreshing the page.
   		if(window.location.href.search(/messages.cfm/i) > -1 && window.location.href.search(/guid=/i) > -1){
   			var url = new String(window.location);
			url = url.replace(/\?.*$/, "");
   			window.location = url;
   		}
   		else{
			window.location.reload(true);
		}

   }

   // Email User Password
	function JSEmailPassword(){
		// set email address.
		var jsstatus = null;
		var email = document.ForgotPassword.Email.value;

		// Validate email address first, then process.
		if(validate_email(email)){
			var LoginJS = new LoginController();
	   		jsstatus = LoginJS.EmailPassword(email);

	   		if(jsstatus == 0){
				alert("We were unable to either find your customer record OR we were unable to email you.  Please contact us for assistance.");
				window.document.ForgotPassword.Email.focus();
	   		}
	   		else{
	   			alert("Your username and password have been emailed to you.  If you need additional assistance, feel free to contact us.");
	   			SwitchFormsBack();
	   			document.LoginForm.Username.focus();
	   		}
   		}
   		else{
   			window.document.ForgotPassword.Email.focus();
   		}
	}

   //Start Register Functions
   function validate_email(email) {
   	/* NB ErrorEmail:Attribute validation error for tag CFMAIL on 17-08-2011 START */
	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    if(email.length == 0) {
      alert("Please enter your email address.");
      return false;
      }
	if(!emailReg.test(email)) {
           alert('Please enter a valid email address.');
           return false; 
        }  
	return true; 
    /* if(email.length == 0) {
      alert("Please enter your email address.");
      return false;
      }
    if(-1 == email.indexOf("@") || email.count('@') > 1) {
       alert("Your email address must have 1 '@' in it.");
       return false;
       }
    if(-1 != email.indexOf(",")) {
       alert("Your email address must not have a ',' in it");
       return false;
       }
    if(-1 != email.indexOf("#")) {
       alert("Your email must not have an '#' in it." );
       return false;
       }
    if(-1 != email.indexOf("!")) {
       alert("Your email address must not have a '!' in it." );
       return false;
       }
    if(-1 != email.indexOf(" ")) {
        alert("Your email address must not have a space in it." );
       return false;
       }
    if(email.length ==
         (email.indexOf("@")+1) ) {
            alert("Your email address must have a domain name after the '@'.");
       return false;
       }

    return true; */
	/* NB ErrorEmail:Attribute validation error for tag CFMAIL on 17-08-2011 END */
  }

function jsRegister()
{

	var reg=1;//reg 1 assumes all is correct, before the user is submitted to the sever they must pass the tests below

	var regForm=document.getElementById("Register");
	//regForm is the form object for the registration form

	//check there are no empty values:
	if (regForm.Fname.value.length =='')
	{var reg=0; alert("You must enter a First Name"); return;}
	if (regForm.Lname.value.length =='')
	{var reg=0; alert("You must enter a Last Name"); return;}
	if (regForm.Username.value.length =='')
	{var reg=0; alert("You must enter a User name"); return;}

	//check email
	var isOkEmail=validate_email(regForm.email.value);
	if (isOkEmail==false){var reg=0; return;}

	//check phone
	//var isOKPhone = ValidatePhone();
	//if (isOKPhone==false){var reg=0; return;}

	//check password
	if (regForm.password.value.length =='')
	{var reg=0; alert("You must enter a password"); return;}

	if (regForm.password.value.length < 5)
	{var reg=0; alert("You must enter a password that is at least 5 characters"); return;}

	if (regForm.password.value!=regForm.ConfirmPass.value)
	{var reg=0; alert("Your passwords don't match"); return;}

	//if the user passes the first two tests- load JS object
	var RegisterJS=new MemberController();
	//RegisterJS.setReturnFormat('plain');

	//Check the server for the same username or email
	var LoginReturnjs=RegisterJS.CheckUserNameEmail(regForm.Username.value,regForm.email.value);
	//var retstring=LoginReturnjs.substring((LoginReturnjs.search('Count=')+6),(LoginReturnjs.search('Count=')+7));
	//alert(retstring);

	if (LoginReturnjs !='0'){var reg=0;alert('The Username or Email is already in use.'); return;}
		//else{alert(LoginReturnjs);}

	//Check the Adobe Connect server for the same username or email
	//var AdobeLoginReturnjs=RegisterJS.AdobeCheckUserNameEmail(regForm.Username.value,regForm.email.value);
	//if (AdobeLoginReturnjs !='0'){var reg=0;alert('The Username or Email is already in use. (Connect)'); return;}

	//If User passes all the tests then register
	if (reg==1){
		regForm.submit();

		//var RegReturnjs=RegisterJS.RegisterAjax(regForm.Fname.value,regForm.Lname.value,regForm.email.value,regForm.Username.value,regForm.password.value,regForm.Country.value,regForm.ZipCode.value,regForm.Company.value	,regForm.Employees.value,regForm.JobTitle.value	,regForm.Industry.value	,regForm.School.value,regForm.Major.value,regForm.Phone.value,regForm.MemberTypeID.value,regForm.tableID.value,regForm.memberID.value);
		//window.location = regForm.referrer.value;
	}

}
	//End Register Functions

function jsRegisterNoLogin()
{
	//This is similar to jsRegister but does not require UserName or Password
	//For use with Webinars that do not have IQs (SSON)

	var reg=1;//reg 1 assumes all is correct, before the user is submitted to the sever they must pass the tests below

	var regForm=document.getElementById("Register");
	//regForm is the form object for the registration form

	//check there are no empty values:
	if (regForm.Fname.value.length =='')
	{var reg=0; alert("You must enter a First Name"); return;}
	if (regForm.Lname.value.length =='')
	{var reg=0; alert("You must enter a Last Name"); return;}

	//check email
	var isOkEmail=validate_email(regForm.email.value);
	if (isOkEmail==false){var reg=0; return;}

	//if the user passes the first two tests- load JS object
	var RegisterJS=new MemberController();

	//Check the server for the same username or email
	var LoginReturnjs=RegisterJS.GetMemberByEmail(regForm.email.value);

	if (LoginReturnjs !=''){
		reg=2;
		//set memberid
		regForm.MemberID.value = LoginReturnjs;

	}



	//If User passes all the tests then register
	if (reg==1){
		regForm.submit();
		//GA tracking
		//var gaRegister = pageTracker._trackEvent("Registration", "Registration", "User registered as a member", "1");
		_gaq.push(['_trackEvent', 'Registration', 'Registration', 'User registered as a member', '1']);

	} else {
		regForm.submit();
	}
}
	//End Register Functions

	//Start Ranking Function
	//Requires CFAjaxProxy: cfajaxproxy cfc="org.content.Ranking" jsclassname="Proxy_Rank"

	function js_updateranking(rank,ExternalTypeID,externalID)
			{
				//alert(externalID);
				var up = new Proxy_Rank();
				//up.setHTTPmethod='post';
				var e=up.UpdateRanking(rank,ExternalTypeID,externalID);
				alert(e);
				//alert(externalID);
	}

	//Question Functions
	function AddSolution(){
		var checkLogin=isLoggedIn();
		if (checkLogin !=0)
		{
			document.getElementById('solutionForm').style.display='';
			window.location.hash = 'SolForm';
		}
		else{
			alert ('You are not Signed In...Please Sign In above');
			}
	}

	function AddSolution2(){
		alert ('You are not Signed In...Please Sign In above');
	}

	function JSFeedback(){
		var feedbackJS = new FeedBackController();
		//e.setErrorHandler(myErrorHandler);
	    var VoidLg=feedbackJS.AddFeedback(document.getElementById('feedbackForm').feedback.value,document.getElementById('feedbackForm').ExternalTypeID.value,document.getElementById('feedbackForm').ExternalID.value);
		alert('Thank You!');
		//results.innerHTML=ret;
		ColdFusion.Window.hide('Win_Feedback');
		//Win_Feedback

	}

	//Search Javascript
	function SearchBar(dft){
		bxVal=document.getElementById('FRMSearch').searchterms.value;
		if(bxVal==dft){alert('Please Enter Search Words');return;}
		if(bxVal==''){alert('Please Enter Search Words');return;}

		document.getElementById('FRMSearch').submit();
	}
	//Search Javascript
	function Top3SearchBar(dft){
		frmVal=document.getElementById('FRMSearchtop3').searchterms.value;
		//alert(frmVal);
		if(frmVal==' '){alert('Please Enter Search Words');return;}
		if(frmVal==''){alert('Please Enter Search Words');return;}

		document.getElementById('FRMSearchtop3').submit();
	}

function SendMessage(Type,RecipientID,ctrlSub,ctrlMess,reply,user){
	var check=isLoggedIn();

		if (check !=0)
		{
			var crfm=confirm('You are about to send a message to '+user);
			if (crfm==true){
				//alert(Type);
				var MessageJS=new MessageController();
				var check=MessageJS.SendMessageAjax(Type,ctrlMess.value,RecipientID,ctrlSub.value,reply);
				alert ('You message was sent!');
				ColdFusion.Window.hide(''+RecipientID+'');
			}
		}
		else{
			alert ('You are not Signed In...Please Sign In above');
			}

}
function UpdateProfile()
{

	var reg=1;//reg 1 assumes all is correct, before the user is submitted to the sever they must pass the tests below

	var regForm=document.getElementById("UpDateProfile");
	//alert(regForm.MemberID.value);
	//regForm is the form object for the registration form
	//alert(regForm.Fname.value);
	//check there are no empty values:
	if (regForm.Fname.value.length =='')
	{var reg=0; alert("You must enter a First Name"); return;}
	if (regForm.Lname.value.length =='')
	{var reg=0; alert("You must enter a Last Name"); return;}

	/*
	if (regForm.Country.value.length =='')
	{var reg=0; alert("You must enter a Country"); return;}
	*/

	//check email
	var isOkEmail=validate_email(regForm.email.value);
	if (isOkEmail==false){var reg=0; return;}

	//if the user passes the first two tests- load JS object
	var RegisterJS=new MemberController();

	/*
	//Check the server for the same username or email
	var LoginReturnjs=RegisterJS.CheckUserNameEmail(regForm.Username.value,regForm.email.value);
	if (LoginReturnjs !='0'){var reg=0;alert('The Username or Email is already in use'); return;}
	*/
	//If User passes all the tests then register
	if (reg==1){
		var RegReturnjs=RegisterJS.UpdateProfileAjax(regForm.MemberID.value,regForm.Fname.value,regForm.Lname.value,regForm.email.value,regForm.Company.value,regForm.JobTitle.value,regForm.description.value,regForm.website.value);
		window.location.reload(true);
	}

}

function ViewMessage(ctrl){
	var DivElem=document.getElementById(ctrl);
	//alert(DivElem.style.display);
	if (DivElem.style.display == 'none')
	{
		DivElem.style.display='';
	}
	else{
		DivElem.style.display='none';
	}

}


function ShowLargerImage(image){

	ColdFusion.Window.create('Image', 'Image0','/ShowLargeImageWindow.cfm?image='+image,{x:100,y:100,height:600,width:700,modal:false,closable:true,draggable:true,resizable:true,center:true,initshow:true,minheight:500,minwidth:500});

}

function ShowLargerImageWindowName(windowName, image){

	popitup('/ShowLargeImageWindow.cfm?image='+image);
	//ColdFusion.Window.create(windowName, 'Image0','/ShowLargeImageWindow.cfm?image='+image,{x:100,y:100,height:600,width:700,modal:false,closable:true,draggable:true,resizable:true,center:true,initshow:true,minheight:500,minwidth:500});

}

function ShowLargerImageWindowNameLarger(windowName, image){

	ColdFusion.Window.create(windowName, 'Image0','/ShowLargeImageWindow.cfm?image='+image,{x:100,y:100,height:750,width:850,modal:false,closable:true,draggable:true,resizable:true,center:true,initshow:true,minheight:500,minwidth:500});

}
function YouMightAlsoLike(externalid,externaltypeid,keywords,div){

		//Function that allows the system to search for related content
		//Function requires: CFAJAxproxy cfc="org.Controller.Search" jsclassname="SearchJS"
		//alert(keywords);
		var DivElem=document.getElementById(div);
		var Search= new SearchJS();
		Search.setReturnFormat('plain');
		var results=Search.YouMightAlsoLike(externalid,externaltypeid,keywords);
		DivElem.innerHTML=results;
}

function YouMightAlsoLikeEventSessions(externalid,externaltypeid,keywords,div,page){
		//Function that allows the system to search for related content
		//Function requires: CFAJAxproxy cfc="org.Controller.Search" jsclassname="SearchJS"
		var DivElem=document.getElementById(div);
		var Search= new SearchJS();
		Search.setReturnFormat('plain');
		var results=Search.YouMightAlsoLikeEventSessions(externalid,externaltypeid,keywords,'false',page);
		DivElem.innerHTML=results;
}

function RecentActivity(div){

	//Function that allows the system to search for related content
	//Function requires: CFAJAxproxy cfc="org.Controller.RecentActvityController" jsclassname="RecentActvityJS"
		//alert(keywords);
		var DivElem=document.getElementById(div);
		var RecentActvity= new RecentActvityJS();
		RecentActvity.setReturnFormat('plain');
		var results=RecentActvity.GetRecentActivity();
		DivElem.innerHTML=results;
}

function SwitchForms(){
	document.LoginForm.style.display = "none";
	document.ForgotPassword.style.display = "block";
	document.ForgotPassword.Email.focus();
	}

function SwitchFormsBack(){
	document.LoginForm.style.display = "block";
	document.ForgotPassword.style.display = "none";
	document.LoginForm.Username.focus();
	}

function popitup(url) {
newwindow=window.open(url,'_blank','height=700,width=700,left=300,top=100,scrollbars=yes');

if (window.focus) {newwindow.focus()}

return false;

}

function NewsletterSignupFunction(){
	//alert('here');
	
	var str = document.NewsletterSignup.newsletter_email.value;
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	var validEmail = true;
	if (str.indexOf(at)==-1){
	   //alert("Invalid E-mail ID")
	   validEmail = false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   //alert("Invalid E-mail ID")
	   validEmail = false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    //alert("Invalid E-mail ID")
	    validEmail = false;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    //alert("Invalid E-mail ID")
	    validEmail = false;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    //alert("Invalid E-mail ID")
	   	validEmail = false;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    //alert("Invalid E-mail ID")
	    validEmail = false;
	 }
	
	 if (str.indexOf(" ")!=-1){
	    //alert("Invalid E-mai")
	    validEmail = false;
	 }

	//alert(validEmail);
	if (validEmail == false) {
		alert("Invalid E-mail");
	} else {
	
		var Newsletter = new NewsletterController();
		var sc = Newsletter.NewsletterSignup(document.NewsletterSignup.newsletter_email.value,document.NewsletterSignup.verticleID.value,document.NewsletterSignup.verticleID.value,document.NewsletterSignup.source.value);
	
		if(sc == 0){
			document.NewsletterSignup.newsletter_email.value = '';
			document.getElementById('newsletter').style.backgroundImage = "none";
			document.getElementById('NewsletterSignup').style.display = "none";
			document.getElementById('NewsletterThankYou').style.display = "block";
	
			//GA tracking
			//pageTracker._trackEvent("Newsletter", "SignUp", "User successfully Signed Up for our newsletter", 1);
			_gaq.push(['_trackEvent', 'Newsletter', 'SignUp', 'User successfully Signed Up for our newsletter', 1]);
		}
		else{
			if(sc == 1){
				document.NewsletterSignup.newsletter_email.value = '';
				document.getElementById('newsletter').style.backgroundImage = "none";
				document.getElementById('NewsletterSignup').style.display = "none";
				document.getElementById('NewsletterThankYou').innerHTML = "Thank you.";
				document.getElementById('NewsletterThankYou').style.display = "block";
	
				//GA tracking
				//pageTracker._trackEvent("Newsletter", "Existing", "User already exists in db", 1);
				_gaq.push(['_trackEvent', 'Newsletter', 'Existing', 'User already exists in db', 1]);
			}
			else{
				document.getElementById('NewsletterThankYou').innerHTML = "An error has occurred.  Please use the Contact Us form to send in your request.";
				document.getElementById('NewsletterThankYou').style.display = "block";
	
				//GA tracking
				//pageTracker._trackEvent("Newsletter", "SignUpError", "Error: User failed to Sign Up for our newsletter", 2);
				_gaq.push(['_trackEvent', 'Newsletter', 'SignUpError', 'Error: User failed to Sign Up for our newsletter', 2]);
				}
		}
	}
}

function NewsletterSignupLightJS(){
	if (validate_email(document.lightBoxSignup.lightBoxSignup_email.value)) {
		var Newsletter2 = new NewsletterController();
		var sc1 = Newsletter2.NewsletterSignup(document.NewsletterSignupLight.NewsletterSignupLightNewsletter_email.value, document.NewsletterSignupLight.verticleID.value, document.NewsletterSignupLight.verticleID.value, document.NewsletterSignupLight.source.value);
		ColdFusion.Window.hide('wdw_NewsletterSignup');
		
		if (sc1 == 0) {
			//GA tracking
			//pageTracker._trackEvent("Newsletter", "LightBoxSignUp", "User successfully Signed Up for our newsletter", 1);
			_gaq.push(['_trackEvent', 'Newsletter', 'LightBoxSignUp', 'User successfully Signed Up for our newsletter', 1]);
		}
		else {
			if (sc1 == 1) {
				//GA tracking
				//pageTracker._trackEvent("Newsletter", "LightBoxExisting", "User already exists in db", 1);
				_gaq.push(['_trackEvent', 'Newsletter', 'LightBoxExisting', 'User already exists in db', 1]);
			}
			else {
				//GA tracking
				//pageTracker._trackEvent("Newsletter", "LightBoxSignUpError", "Error: User failed to Sign Up for our newsletter", 2);
				_gaq.push(['_trackEvent', 'Newsletter', 'LightBoxSignUpError', 'Error: User failed to Sign Up for our newsletter', 2]);
			}
		}
		
		return 0;
	}
}

// used for IQ_brief signups
function lightBoxSignupJS(){
	if (validate_email(document.lightBoxSignup.lightBoxSignup_email.value)) {
		//pageTracker._trackEvent("User", "preLightBoxJoin", document.lightBoxSignup.lightBoxSignup_email.value, 1);
		_gaq.push(['_trackEvent', 'User', 'preLightBoxJoin', document.lightBoxSignup.lightBoxSignup_email.value, 1]);
		
		var Member = new MemberController();
		var sc1 = Member.lightBoxRegister(document.lightBoxSignup.lightBoxSignup_email.value, document.lightBoxSignup.source.value, document.lightBoxSignup.MAC.value);
		
		if (sc1 == 0) {
			//GA tracking
			//pageTracker._trackEvent("User", "LightBoxJoin", document.lightBoxSignup.lightBoxSignup_email.value, 1);
			_gaq.push(['_trackEvent', 'User', 'LightBoxJoin', document.lightBoxSignup.lightBoxSignup_email.value, 1]);
		}
		else {
			//GA tracking
			//pageTracker._trackEvent("User", "LightBoxError", document.lightBoxSignup.lightBoxSignup_email.value, 2);
			_gaq.push(['_trackEvent', 'User', 'LightBoxError', document.lightBoxSignup.lightBoxSignup_email.value, 2]);
		}
		
		SwitchMe('lightBoxSignupForm', 'lightBoxSuccess');
	}
}

function lightBoxSignupJSFull(){
	if (validate_email(document.lightBoxSignup.lightBoxSignup_email.value)) {
		//pageTracker._trackEvent("User", "preLightBoxJoin", document.lightBoxSignup.lightBoxSignup_email.value, 1);
		_gaq.push(['_trackEvent', 'User', 'preLightBoxJoin', document.lightBoxSignup.lightBoxSignup_email.value, 1]);
		
		var Member = new MemberController();
		var sc1 = Member.lightBoxRegister(document.lightBoxSignup.lightBoxSignup_email.value, document.lightBoxSignup.source.value, document.lightBoxSignup.MAC.value, document.lightBoxSignup.lightBoxSignup_FName.value, document.lightBoxSignup.lightBoxSignup_LName.value, document.lightBoxSignup.lightBoxSignup_jobTitle.value, document.lightBoxSignup.lightBoxSignup_company.value);
		
		if (sc1 == 0) {
			//GA tracking
			//pageTracker._trackEvent("User", "LightBoxJoin", document.lightBoxSignup.lightBoxSignup_email.value, 1);
			_gaq.push(['_trackEvent', 'User', 'LightBoxJoin', document.lightBoxSignup.lightBoxSignup_email.value, 1]);
		}
		else {
			//GA tracking
			//pageTracker._trackEvent("User", "LightBoxError", document.lightBoxSignup.lightBoxSignup_email.value, 2);
			_gaq.push(['_trackEvent', 'User', 'LightBoxError', document.lightBoxSignup.lightBoxSignup_email.value, 2]);
		}
		
		SwitchMe('lightBoxSignupForm', 'lightBoxSuccess');
	}
}

function TrackingInfo(externalID,externalTypeID,action,url){
	this.externalID = externalID;
	this.externalTypeID = externalTypeID;
	this.ActionTypeID = action;
	this.keyword = url;
	}

function click_tracking(externalID,externalTypeID,action,url){
	TrackingInfo = new TrackingInfo(externalID,externalTypeID,action,url);

	var tracking = new Tracking();
	var tracking_ = tracking.InsertAction(TrackingInfo);
	}

function closeLightbox(){
	location = location + '&trackLight=1';
	}

function SwitchMe(ele1, ele2){
	document.getElementById(ele1).style.display='none';
	document.getElementById(ele2).style.display='block';
	}

function JSAddEvent(memberID, membershipID){
	var Member = new MemberController();
	var eventObj = AddEventObj(memberID, membershipID);
	var Membership = Member.Main('InsertMemberMembership',eventObj);

	SwitchMe('InterestedDiv','ThanksDiv');
}

function AddEventObj(memberID, membershipID){
	this.memberID = memberID;
	this.membershipID = membershipID;
	alert(this.memberID);
}

function subjectLine(text){
	var subject = text + " is forwarding you this link";
	document.FriendMessage.Subject.value = subject;
}


	var IndexSolveDiv=0;
	var IndexSolveDivt;
	function SetIndexSolveDiv(){
	clearTimeout(IndexSolveDivt);
	if (IndexSolveDiv==0){}
	if (IndexSolveDiv==1){}
	if (IndexSolveDiv==2){}
	if (IndexSolveDiv==3){}
	if (IndexSolveDiv==4){}
	if (IndexSolveDiv==5){}
	if (IndexSolveDiv==5){}
		//CUWeek=CUWeek+1;

	IndexSolveDivt=setTimeout("SetIndexSolveDiv()",4000);
	}
	IndexSolveDivt=setTimeout("SetIndexSolveDiv()",4000);


function rollOn(img,src){
	img.src = src;
}

function rollOff(img,src){
	img.src = src;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function checkAddressCount(){			
	var ok = true;
	var emailAddresses = $("#ToEmail").val();
	emailAddresses = emailAddresses.replace(';',',');
	var emailAddressesArray = emailAddresses.split(',');

	if(emailAddressesArray.length > 50){
		alert('Only 20 email addresses can be supplied at a time');
		ok = false;
	}
	return ok;
}

function removeItem(id){
	document.location.href='removefromcart.cfm?productID=' + id;
}

$(document).ready(function(){
		$(function () {
	
			$('.dropdown').each(function () {
				$(this).parent().eq(0).hoverIntent({
					timeout: 100,
					over: function () {
						var current = $('.dropdown:eq(0)', this);
						current.slideDown(100);
					},
					out: function () {
						var current = $('.dropdown:eq(0)', this);
						current.fadeOut(200);
					}
				});
			});
			
			$('.dropdown a').hover(function () {
				$(this).stop(true).animate({paddingLeft: '0'}, {speed: 100, easing: 'easeOutBack'});
			}, function () {
				$(this).stop(true).animate({paddingLeft: '0'}, {speed: 100, easing: 'easeOutBounce'});
			});
			
			pic1 = new Image(310, 672);
			pic1.src = location.protocol + '//' + location.host + "/images/dropdown.png"; 
			
			pic2 = new Image(4, 40);
			pic2.src = location.protocol + '//' + location.host + "/images/dropselectionleft.png"; 
			
			pic3 = new Image(394, 40);
			pic3.src = location.protocol + '//' + location.host + "/images/dropselectionright.png";
		});
	});
