/**********        RIGHT SLIDE   START  **********/
        text_array = new Array();
        text_array[0] = "Subscribe to our newsletter";
        text_array[1] = "The Right Click";
        var SLIDE_TIMER;
        function do_slide(){
            obj = document.getElementById("slide_div");
	   
            cur_left = parseInt(obj.style.left);
            if(cur_left > 0){
                obj.style.left = (cur_left - 22 ) + "px" ;
                document.getElementById("slide_div_b").style.left = (cur_left - 250) + "px";
                setTimeout("do_slide()",20);
            }else{
                obj.style.left = 251 + "px" ;
                document.getElementById("slide_div_b").style.left = 0 + "px";
                document.getElementById("slide_div_b").innerHTML = obj.innerHTML;
                if(obj.innerHTML == text_array[0]){
                    obj.innerHTML = text_array[1];
                }else{obj.innerHTML = text_array[0];}
                SLIDE_TIMER = setTimeout("do_slide()",4000);
            }
        }
        function pause_right_slide(){
	    document.getElementById("slide_div").style.color = "red";
	    document.getElementById("slide_div_b").style.color = "red";
            clearTimeout(SLIDE_TIMER);
        }
        function continue_right_slide(){
	    document.getElementById("slide_div").style.color = "#667da1";
	    document.getElementById("slide_div_b").style.color = "#667da1";
            SLIDE_TIMER = setTimeout("do_slide()",4000);
        }
/**********        RIGHT SLIDE   END  **********/

the_box = "";
function newsletter_click(obj){
    the_box = document.getElementById("n_box");
    the_box.style.display = "block";
}
function close_the_box(){
    the_box.style.display = "none";
}
function testInput() {
var Email =  new String(document.inputForm.Email.value); 
var Correct = true; 
CharCount=1; 
strLength=Email.length; 
while ((CharCount < strLength) && (Email.charAt(CharCount) != '@')) 
{ 
	CharCount++ 
} 
if ((CharCount>= strLength) || (Email.charAt(CharCount) != '@'))  
{  
	alert ('Email address not valid.') 
	Correct = false; 
} 
else 
{ 
	CharCount += 2; 
} 
while ((CharCount < strLength) && (Email.charAt(CharCount) != '.')) 
{ 
	CharCount++ 
} 
if ((CharCount>= strLength - 1) || (Email.charAt(CharCount) != '.')) 
{ 
	alert ('Email address not valid.') 
	Correct = false; 
}
/*
if(Correct){
    document.getElementById("msg_n_box").innerHTML = "Thx" +
	    '<div style="position:absolute;top:220px;left:197px"><span style="text-decoration:underline;cursor:pointer;color:#667da1" onclick="close_the_box()">Close</span></div>';
    setTimeout("close_the_box()", 2000);
}
*/
return Correct 
}
function nl_submit(){
    var form_obj = document.inputForm;
    var list_str = "";
    var email_str = form_obj.Email.value;
    var param_str = "";
    /*
    if(form_obj.is.checked){list_str += "8a";}
    if(form_obj.dub.checked){list_str += "7a";}
    if(form_obj.hc.checked){list_str += "6a";}
    if(form_obj.bpbs.checked){list_str += "9";}
    */
    param_str = "email=" + email_str 
    do_subscribe(param_str);
}
function check_enter(e){

  if( !e ) {
    //if the browser did not pass the event information to the
    //function, we will have to obtain it from the event register
    if( window.event ) {
      //Internet Explorer
      e = window.event;
    } else {
      //total failure, we have no way of referencing the event
      return;
    }
  }
  if( typeof( e.keyCode ) == 'number'  ) {
    //DOM
    e = e.keyCode;
  } else if( typeof( e.which ) == 'number' ) {
    //NS 4 compatible
    e = e.which;
  } else if( typeof( e.charCode ) == 'number'  ) {
    //also NS 6+, Mozilla 0.9+
    e = e.charCode;
  } else {
    //total failure, we have no way of obtaining the key code
    return;
  }
  if(e == 13){
    nl_submit();
  }
  /*window.alert('The key pressed has keycode ' + e +
    ' and is key ' + String.fromCharCode( e ) );
  */
}

function do_subscribe(key_str){
    var result;

    var xmlHttp=null;
	try{    xmlHttp=new XMLHttpRequest();  }// Firefox, Opera 8.0+, Safari
	catch (e) { 														// Internet Explorer
	    try {	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
		catch (e){	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
  		}
	if (xmlHttp==null){ alert("Your browser does not support AJAX!"); exit; } 
    else {
        myurl = 'http://pillarcc.com/newsletter_for_pillar.php?' + key_str;
	xmlHttp.open("GET", myurl, true);
        xmlHttp.onreadystatechange =  function (){ 
            if (xmlHttp.readyState==4 && xmlHttp.status == 200){ 
                result_dn =  xmlHttp.responseText;
		if(result_dn == "ok"){
		    document.getElementById("msg_n_box").innerHTML = "<div style='position:absolute;font:14px arial;top:35px;left:65px;'>Thank you!</div>" +
			    '<div style="position:absolute;top:96px;left:197px"><span style="text-decoration:underline;cursor:pointer;color:#667da1" onclick="close_the_box()">Close</span></div>';
		    setTimeout("close_the_box()", 2000);
		}else{
		    if(result_dn == "exist"){
			document.getElementById("msg_n_box").innerHTML = "<div style='position:absolute;font:14px arial;top:35px;left:25px;'>You are already subscribed.</div>" +
				'<div style="position:absolute;top:96px;left:197px"><span style="text-decoration:underline;cursor:pointer;color:#667da1" onclick="close_the_box()">Close</span></div>';
			setTimeout("close_the_box()", 2000);
		    }
		}
                
            }
        }
        xmlHttp.send(null);
    }
}
function box_checked(){
    var Correct = true;
    var form_obj = document.inputForm;
    if(!(form_obj.is.checked || form_obj.bpbs.checked || form_obj.dub.checked || form_obj.hc.checked )){
	alert("Please select an newsletter category");
	Correct = false;
    }
    return Correct;
}


var about_menu_pulldown = false;
var trouble_menu_pulldown = false;
var trans=80;
function do_do(){
    var base = document.getElementById("nav_menu");
    var divs = base.getElementsByTagName("div");
    for(i = 0; i< divs.length;i++){
        if(divs.item(i).style.color == "rgb(190, 6, 6)"){;}
        else{
            var object = divs.item(i);
            if(window.addEventListener){ // Mozilla, Netscape, Firefox
                object.addEventListener('mouseover', testevent_over, false);
                object.addEventListener('mouseout', testevent_out, false);
                object.myid = object.id;
            } else { // IE
                object.attachEvent('onmouseover', testevent_over);
                object.attachEvent('onmouseout', testevent_out);
                object.myid = object.id;
            }   
        }
    }
}
window.onload = do_do;

function testevent_over(evt){
    	var e_out;
	var ie_var = "srcElement";
	var moz_var = "target";
	var prop_var = "myid";
	evt[moz_var] ? e_out = evt[moz_var][prop_var] : e_out = evt[ie_var][prop_var];
	document.getElementById(e_out).style.color = "rgb(190, 6, 6)";
}
function testevent_out(evt){
    	var e_out;
	var ie_var = "srcElement";
	var moz_var = "target";
	var prop_var = "myid";
	evt[moz_var] ? e_out = evt[moz_var][prop_var] : e_out = evt[ie_var][prop_var];
	document.getElementById(e_out).style.color = "#667da1";
}
function fh_get_started_open()
{
 fh_get_started.style.visibility="visible";	
 fh_testimonials.style.visibility="hidden";
}


function fh_get_started_close()
{
 fh_get_started.style.visibility="hidden";	
}


function fh_testimonials_open()
{
 fh_testimonials.style.visibility="visible";
 fh_get_started.style.visibility="hidden";	
}


function fh_testimonials_close()
{
 fh_testimonials.style.visibility="hidden";	
}




function about_menu_click()
{
    var t;
    var obj=document.getElementById("about_menu_1");
   
    if(trouble_menu_pulldown == true)
    {
     trouble_menu_click();	
 }
 
 
 
 if(about_menu_pulldown == false)
 {
  t=obj.offsetTop + 5;
  obj.style.top= t + "px";
  about_menu_pulldown = true;

  t=obj.offsetLeft+"px";
  document.getElementById("about_pillar_1").style.left=t;
  document.getElementById("about_bfd_1").style.left=t;
  document.getElementById("about_richard_1").style.left=t;
  document.getElementById("about_michael_1").style.left=t;
  
  t=obj.offsetTop+54 ;
  document.getElementById("about_pillar_1").style.top=t+"px";
  t=t+30;
  document.getElementById("about_bfd_1").style.top=t+"px";
  t=t+30;
  document.getElementById("about_richard_1").style.top=t+"px";
  t=t+30;
  document.getElementById("about_michael_1").style.top=t+"px";
  

  change_opacity(trans,"about_pillar_bg_1");
  change_opacity(trans,"about_bfd_bg_1");
  change_opacity(trans,"about_richard_bg_1");
  change_opacity(trans,"about_michael_bg_1");


  document.getElementById("about_pillar_1").style.visibility="visible";
  document.getElementById("about_bfd_1").style.visibility="visible";
  document.getElementById("about_richard_1").style.visibility="visible";
  document.getElementById("about_michael_1").style.visibility="visible";
  

 }
 else
 {
  t=obj.offsetTop - 5;
  obj.style.top= t + "px";
  about_menu_pulldown = false;

  document.getElementById("about_pillar_1").style.visibility="hidden";
  document.getElementById("about_bfd_1").style.visibility="hidden";
  document.getElementById("about_richard_1").style.visibility="hidden";
  document.getElementById("about_michael_1").style.visibility="hidden";

 }	

}





function trouble_menu_click()
{
 var t;
 var obj=document.getElementById("trouble_menu_1");

 if(about_menu_pulldown == true)
 {
  about_menu_click();	
 }


 if(trouble_menu_pulldown == false)
 {
  t=obj.offsetTop + 5;
  obj.style.top= t + "px";
  trouble_menu_pulldown = true;

  t=obj.offsetLeft+"px";
  document.getElementById("trouble_knowledge_1").style.left=t;
  document.getElementById("trouble_recommended_1").style.left=t;
  document.getElementById("trouble_newsletter_1").style.left=t;
  
  t=obj.offsetTop+54 ;
  document.getElementById("trouble_knowledge_1").style.top=t+"px";
  t=t+30;
  document.getElementById("trouble_recommended_1").style.top=t+"px";
  t=t+30;
  document.getElementById("trouble_newsletter_1").style.top=t+"px";
  

  change_opacity(trans,"trouble_knowledge_bg_1");
  change_opacity(trans,"trouble_recommended_bg_1");
  change_opacity(trans,"trouble_newsletter_bg_1");


  document.getElementById("trouble_knowledge_1").style.visibility="visible";
  document.getElementById("trouble_recommended_1").style.visibility="visible";
  document.getElementById("trouble_newsletter_1").style.visibility="visible";
  

 }
 else
 {
  t=obj.offsetTop - 5;
  obj.style.top= t + "px";
  trouble_menu_pulldown = false;

  document.getElementById("trouble_knowledge_1").style.visibility="hidden";
  document.getElementById("trouble_recommended_1").style.visibility="hidden";
  document.getElementById("trouble_newsletter_1").style.visibility="hidden";

 }	

}







function go_url(address)
{

 if(about_menu_pulldown == true)
 {
  about_menu_click();	
 }
	
 if(trouble_menu_pulldown == true)
 {
  trouble_menu_click();	
 }


 window.location=address;
 
	
}

function highlight_m2(obj,flag)
{
 if(flag)
 {
  change_opacity(100,obj.childNodes[0].id)
 }
 else
 {
  change_opacity(trans,obj.childNodes[0].id)
 }
}





function change_opacity(opacity,obj_id)
{
 obj = document.getElementById(obj_id).style;
 obj.opacity = (opacity / 100);
 obj.MozOpacity = (opacity / 100);
 obj.KhtmlOpacity = (opacity / 100);
 obj.filter = "alpha(opacity=" + opacity + ")";
}










































/**************************************************
 * dom-drag.js
 * 09.25.2001
 * www.youngpup.net
 **************************************************
 * 10.28.2001 - fixed minor bug where events
 * sometimes fired off the handle, not the root.
 **************************************************/

var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};


var scroller = {
  init:   function() {

    //collect the variables
    scroller.docH = document.getElementById("content").offsetHeight;
    scroller.contH = document.getElementById("container").offsetHeight;
    scroller.scrollAreaH = document.getElementById("scrollArea").offsetHeight;
      
    //calculate height of scroller and resize the scroller div
    //(however, we make sure that it isn't to small for long pages)
    scroller.scrollH = (scroller.contH * scroller.scrollAreaH) / scroller.docH;
    //if(scroller.scrollH < 15) scroller.scrollH = 15;
    document.getElementById("scroller").style.height = Math.round(scroller.scrollH) + "px";
    
    //what is the effective scroll distance once the scoller's height has been taken into account
    scroller.scrollDist = Math.round(scroller.scrollAreaH-scroller.scrollH);
    
    //make the scroller div draggable
    Drag.init(document.getElementById("scroller"),null,0,0,-1,scroller.scrollDist);
    
    //add ondrag function
    document.getElementById("scroller").onDrag = function (x,y) {
      var scrollY = parseInt(document.getElementById("scroller").style.top);
      var docY = 0 - (scrollY * (scroller.docH - scroller.contH) / scroller.scrollDist);
      document.getElementById("content").style.top = docY + "px";
    }

  }
}

//onload = scroller.init;

