//fill quicklinks innerHTML
var sitePath = "http://www.fellowshiponline.com/";
/*
<div class=\"top-srh\"><form id=\"cse-search-box\" action=\"http://www.fellowshiponline.com/search.php\" target=\"_self\"><div class=\"top-srh-col-1\"> <input type=\"hidden\" name=\"cx\" value=\"005712862868921170640:apetduf2pba\" /> <input type=\"hidden\" name=\"cof\" value=\"FORID:10\" />  <input type=\"hidden\" name=\"ie\" value=\"UTF-8\" />  <input type=\"text\" name=\"q\" size=\"20\" class=\"txt-fld-srh\"/></div><div class=\"top-srh-col-2\"><input type=\"button\" name=\"sa\" style=\"border:0px;background:url('"+sitePath+"images/search-btn.gif') no-repeat; width:53px; height:21px; cursor:pointer;\" onClick=\"javascript:this.form.submit();\"/></div> <script type=\"text/javascript\">google.load(\"elements\", \"1\", {packages: \"transliteration\"});</script> <script type=\"text/javascript\" src=\"http://www.google.com/coop/cse/t13n?form=cse-search-box&t13n_langs=en\"> </script> <script type=\"text/javascript\" src=\"http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en&sitesearch=true\"></script></form></div><div class=\"top-ql\" id=\"qlButton\"><a href=\"javascript:void(0);\">
*/
var content = "<div id=\"quicklinks\"></div><div id=\"outerdiv\"><table><tr><td style=\"width:60%;\">&nbsp;</td><td style=\"width:40%; text-align:right;\"><div id=\"toolbartbl\"><div class=\"top-ql\" id=\"qlButton\"><a href=\"javascript:void(0);\"><img src=\""+sitePath+"images/quick-links-btn.gif\" width=\"70\" height=\"21\" border=\"0\" alt=\"QUICK LINKS\" title=\"QUICK LINKS\"/></a></div></div></div></td></tr></table></div>";
//<li><a href=\"http://www.connectionpower.com/pwsite/memberLogin2.php?churchID=6191\" target=\"_blank\" class=\"menu_headerlink\" id=\"headerMenu2\">MY FELLOWSHIP</a></li><li><a href=\"#\" class=\"menu_headerlink\" id=\"headerMenu6\">REGISTER</a></li>
document.getElementById('quicklinkstoolbar').innerHTML = content;

//for kwicks li
$(document).ready(function() {
    $('#qlButton').click(function() {
        $('#quicklinks').slideToggle();
    });
  
    

    $('#quicklinks').bind("mouseleave",function(){$('#quicklinks').slideUp();$('#qlButton').css({'background-color':'','color':''});});

    $.ajax({
            type: "GET",
            url: "wp-content/themes/blog/get_fellowship_quicklinks.php",
            dataType: "xml",
            success: function(xml) {
                var finalmenu = "";
                var menulisting = "";
                var endiv = "";
                var mainlisting = "";
                var outerul = "<ul class=\"kwicks horizontal\" id=\"kwickUL\">";

                $(xml).find('menu').each(function () {
                    var head = $(this).find('menuhead').text();
                    var id = $(this).attr('id');

                    mainlisting = "<li id='kwick_"+id+"'><div id=\"wrap\" class=\"wrapper\" ><div id=\"c1\" class=\"col1\"><h3>"+head+"</h3><ul id=\"m2\" class=\"menu2\">";

                    menulisting = "";
                    $(this).find('menuitems').each(function () {

                        var url = $(this).find('url').text();
                        var nam = $(this).find('name').text();
                        var tle = $(this).find('title').text();

                        menulisting += "<li><a href='"+url+"' title='"+tle+"'>"+nam+"</a></li>";
                    });
                    endiv = "</ul></div><div id='info_"+id+"' class='col2' style='display: none;'>This is an info area.</div></div></li>";

                    finaltxt = mainlisting + menulisting + endiv;
                    finalmenu = finalmenu + finaltxt;
                });
                finalmenu = outerul + finalmenu + "</ul>";
                $("#quicklinks").html(finalmenu);


                $('.kwicks li').each(
                    function(i){
                        var qlCol =$(this);
                        qlCol.css('width', '110px');
                        qlCol.css('height','auto');
                    }

                );

                $('.kwicks').kwicks({
                        max : 290,
                        spacing : 5 
                });

                $("li[id^='kwick_']").each(
                    function(idx){
                        idx = idx + 1;
                        $('#kwick_' + idx + ' a').hover(
                                function() {
                                        if (this.title != ''){
                                                $('#info_' + idx).html(this.title).show();
                                                this.title = '';
                                        }else{
                                                $('#info_' + idx).html('').hide();
                                        }
                                },

                                function() {
                                        $('#info_' + idx).hide();
                                        this.title = $('#info_' + idx).html();
                                }
                        );
                    }
                );

              $("#kwickUL li").each(
                 function(i){
                    var qlCol =$(this);
                        $(qlCol).mouseover( 
                            function () { 
                              qlCol.css('background-color', '#f9a286');
                              $(this).find('a').css('color', '#707070');
                              $(this).find('h3').css('color', '#707070');
                             }
                        );
                        $(qlCol).mouseout( 
                            function () { 
                              qlCol.css('background-color', '');
                              $(this).find('a').css('color', '');
                              $(this).find('h3').css('color', '');
                             }
                        );
                 }
              );
            }
    });

    (function() {
        var f = document.getElementById('cse-search-box');
        if (f && f.q) {
            var q = f.q;
            var b = function(){
                    if (q.value == '') {
                        q.style.background = "url("+sitePath+"images/google.gif) left no-repeat";}
                    };
                    var f = function() {
                        q.style.background = '#ffffff';
                    };
                q.onfocus = f;q.onblur = b;b();
            }
        })();
});



var menu_header=function(){
	var t=15,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();
