
var about_menu_pulldown = false;
var trouble_menu_pulldown = false;
var trans=60;
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";
}
var update_list = new Array();
update_list = ['get_twitter.php','get_wordpress.php','get_photo_list.php'];
function pillar_update(call_num){
    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 {
	id = parseInt(call_num);
        myurl = update_list[id];
	//alert(myurl);
	xmlHttp.open("GET", myurl, true);
        xmlHttp.onreadystatechange =  function (){ 
            if (xmlHttp.readyState==4 && xmlHttp.status == 200){ 
		    result_dn =  xmlHttp.responseText;
		    if(result_dn){
			if(call_num <= 1){
			    pillar_update(call_num + 1);   
			}else{
			    self.location.href = self.location.href;
			}
		    }
            }
        }
        xmlHttp.send(null);
    }
}

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 = "";
    
    param_str = "email=" + email_str;
    do_subscribe(param_str);
}
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 = '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;
}

function about_menu_click()
{
 var t;
 var obj=document.getElementById("about_menu");

 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").style.left=t;
  document.getElementById("about_bfd").style.left=t;
  document.getElementById("about_richard").style.left=t;
  document.getElementById("about_michael").style.left=t;
  
  t=obj.offsetTop+61 ;
  document.getElementById("about_pillar").style.top=t+"px";
  t=t+30;
  document.getElementById("about_bfd").style.top=t+"px";
  t=t+30;
  document.getElementById("about_richard").style.top=t+"px";
  t=t+30;
  document.getElementById("about_michael").style.top=t+"px";
  

  change_opacity(trans,"about_pillar_bg");
  change_opacity(trans,"about_bfd_bg");
  change_opacity(trans,"about_richard_bg");
  change_opacity(trans,"about_michael_bg");


  document.getElementById("about_pillar").style.visibility="visible";
  document.getElementById("about_bfd").style.visibility="visible";
  document.getElementById("about_richard").style.visibility="visible";
  document.getElementById("about_michael").style.visibility="visible";
  

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

  document.getElementById("about_pillar").style.visibility="hidden";
  document.getElementById("about_bfd").style.visibility="hidden";
  document.getElementById("about_richard").style.visibility="hidden";
  document.getElementById("about_michael").style.visibility="hidden";

 }	

}

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

 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").style.left=t;
  document.getElementById("trouble_recommended").style.left=t;
  document.getElementById("trouble_newsletter").style.left=t;
  
  t=obj.offsetTop+61 ;
  document.getElementById("trouble_knowledge").style.top=t+"px";
  t=t+30;
  document.getElementById("trouble_recommended").style.top=t+"px";
  t=t+30;
  document.getElementById("trouble_newsletter").style.top=t+"px";
  

  change_opacity(trans,"trouble_knowledge_bg");
  change_opacity(trans,"trouble_recommended_bg");
  change_opacity(trans,"trouble_newsletter_bg");


  document.getElementById("trouble_knowledge").style.visibility="visible";
  document.getElementById("trouble_recommended").style.visibility="visible";
  document.getElementById("trouble_newsletter").style.visibility="visible";
  

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

  document.getElementById("trouble_knowledge").style.visibility="hidden";
  document.getElementById("trouble_recommended").style.visibility="hidden";
  document.getElementById("trouble_newsletter").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 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_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_do;
function do_do_do(){
    
do_do();
Custom.init();
}
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 highlight_m2(obj,flag)
{
 if(flag)
 {
  change_opacity(20,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 + ")";
}



/**********        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  **********/