/* 
jquery and javascript for AngloINFO National Site
*/


jQuery.fn.initMenu = function() {  
    return this.each(function(){
        var theMenu = $(this).get(0);
        $('.acitem', this).hide();
        $('li.expand > .acitem', this).show();
        $('li.expand > .acitem', this).prev().addClass('active');
        $('li a', this).click(
            function(e) {
                e.stopImmediatePropagation();
                var theElement = $(this).next();
                var parent = this.parentNode.parentNode;
                if($(parent).hasClass('noaccordion')) {
                    if(theElement[0] === undefined) {
                        window.location.href = this.href;
                    }
                    $(theElement).slideToggle('normal', function() {
                        if ($(this).is(':visible')) {
                            $(this).prev().addClass('active');
                        }
                        else {
                            $(this).prev().removeClass('active');
                        }    
                    });
                    return false;
                }
                else {
                    if(theElement.hasClass('acitem') && theElement.is(':visible')) {
                        if($(parent).hasClass('collapsible')) {
                            $('.acitem:visible', parent).first().slideUp('normal', 
                            function() {
                                $(this).prev().removeClass('active');
                            }
                        );
                        return false;  
                    }
                    return false;
                }
                if(theElement.hasClass('acitem') && !theElement.is(':visible')) {         
                    $('.acitem:visible', parent).first().slideUp('normal', function() {
                        $(this).prev().removeClass('active');
                    });
                    theElement.slideDown('normal', function() {
                        $(this).prev().addClass('active');
                    });
                    return false;
                }
            }
        }
    );
});
};

$(document).ready(function() {$('.menu').initMenu();});



<!--
    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
	  
       else
          e.style.display = 'block';
    }

//-->
    function toggle_expand(id) {
       var e = document.getElementById(id);
	          var b = document.getElementById('mainContent');
			  if(e.style.display == 'block'){
          e.style.display = 'none';
         b.style.width = '800px';
	 changefontsize('plus');
	
		 }else{
	   e.style.display = 'block';
           b.style.width = '500px';
		changefontsize('minus');
			  }
    } 
	
	
	function changefontsize(size)
		{
			var fs = '18px';
			if (size != 'plus'){
				var fs = '12px';
			}
				
		var i = "";
		var paragraphs = "";
		paragraphs = document.getElementsByTagName("p");
		for(i=0; i<paragraphs.length; i++)
		{
			paragraphs[i].style.fontSize = fs;
		}
		var i = "";
		var ul = "";
		list = document.getElementsByTagName("ul");
		for(i=0; i<list.length; i++)
		{
			list[i].style.fontSize = fs;
		}

}


$(function(){
$("input#searchField").focus(function(){
   if($(this).val() === "Keywords..."){
     $(this).val("");
   }
});	
});


$(function(){
$("input#amountbox").focus(function(){
   if($(this).val() === "Amount..."){
     $(this).val("");
   }
});	
});


// function to control the show/hide in left menu
function toggle_sites(el,id) {

 var e = document.getElementById(id);
if(e.style.display === 'block' || e.style.display === '')
 {
 
  el.innerHTML = "Show";
  e.style.display = 'none';
  
 } else {
 
  el.innerHTML = "Hide";
  e.style.display = 'block';
  
 }
 return false;
}



// function to control the show/hide in left menu
function toggle_map(el,id) {

 var e = document.getElementById(id);
if(e.style.display === 'block' || e.style.display === '')
 {
 
  el.innerHTML = "Show +";
  e.style.display = 'none';
  
 } else {
 
  el.innerHTML = "Hide -";
  e.style.display = 'block';
  
 }
 return false;
}


var currencyhostname = window.location.hostname;


// Currency Converter
$(function(){
	$("form#currencyform").submit(function(){
	 $("#output").remove();
	 $("#mci").remove();
	$("#cbox").append('<p id="output"><img src="/currency/currency-loader.gif" alt="Loading" /></p>');
		$.ajax({
			type	: "POST",
			url		: "http://" + currencyhostname + "/currency/default.php",
			data	: $("form#currencyform").serialize()+"&ajax=1",
			success	: function(str){
				$("#output").remove();
				$("#cbox").append('<p id="output">'+str+'</p>');
			}
		});
		return false;
	});
});




// Currency Converter (Forex Page)
$(function(){
	$("form#currencypageform").submit(function(){
	 $("#output").remove();
	 $("#mci").remove();
	$("#cbox").append('<p id="output"><img src="/currency/currency-loader.gif" alt="Loading" /></p>');
		$.ajax({
			type	: "POST",
			url		: "http://" + currencyhostname + "/currency/default.php",
			data	: $("form#currencypageform").serialize()+"&ajax=1",
			success	: function(str){
				$("#output").remove();
				$("#cbox").append('<p id="output">'+str+'</p>');
				$("#mci").remove();
			}
		});
		return false;
	});
});



