// JavaScript Document



//Start Dropdown menu function

var timeout         = 200;

var closetimer		= 0;

var ddmenuitem      = 0;



function jsddm_open(){

	jsddm_canceltimer();

	jsddm_close();

	var num = jQuery('#Super').height()

/*	jQuery("#pageMask").height(num);*/

	jQuery("#pageMask").css("visibility","visible");

	//alert(document.getElementById('pageMask').style.width);

}



function jsddm_close(){



	//if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');

	jQuery("#pageMask").css("visibility","hidden");

	ddmenuitem = 0;

}



function jsddm_timer(){	closetimer = window.setTimeout(jsddm_close, timeout);}



function jsddm_canceltimer(){if(closetimer)

	{	window.clearTimeout(closetimer);

		closetimer = null;}}



function reset_status(){

	jsddm_close()

	//document.getElementById('navbar').style.backgroundPosition = "0px 0px";

}

document.onclick = reset_status;

//End Dropdown menu function


jQuery(document).ready(function(){

	// Reset Font Size
 var originalFontSize = jQuery('.post-body').css('font-size');
 jQuery(".resetFont").click(function(){
 jQuery('.post-body').css('font-size', originalFontSize);
 });
 // Increase Font Size
 jQuery(".increaseFont").click(function(){
  var currentFontSize = jQuery('.post-body').css('font-size');
 var currentFontSizeNum = parseFloat(currentFontSize, 10);
   var newFontSize = currentFontSizeNum*1.2;
 jQuery('.post-body').css('font-size', newFontSize);
 return false;
 });
 // Decrease Font Size
 jQuery(".decreaseFont").click(function(){
  var currentFontSize = jQuery('.post-body').css('font-size');
 var currentFontSizeNum = parseFloat(currentFontSize, 10);
   var newFontSize = currentFontSizeNum*0.8;
 jQuery('.post-body').css('font-size', newFontSize);
 return false;
 });

   // Reset Font Size
  /*var originalFontSize = $('html').css('font-size');
    $(".resetFont").click(function(){
    $('html').css('font-size', originalFontSize);
  });
  // Increase Font Size
  $(".increaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.2;
    $('html').css('font-size', newFontSize);
    return false;
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*0.8;
    $('html').css('font-size', newFontSize);
    return false;
  });*/


	//Email this page trick

	if(jQuery('#emailJoomla').length > 0){
		var emaillink = jQuery('#emailJoomla > a').attr('href');
		jQuery('li.emailPage > a').attr('href',emaillink);
		jQuery('#emailJoomla').hide();
	}else if(jQuery('a.mailbtn').length > 0){
		var emaillink = jQuery('a.mailbtn').attr('href');
		jQuery('li.emailPage > a').attr('href',emaillink);
		jQuery('a.mailbtn').hide();
		jQuery('li.emailPage').hide();
	}else{
		jQuery('li.emailPage').hide();
	}

	if(jQuery('#printJoomla').length > 0){
		var printlink = jQuery('#printJoomla > a').attr('href');
		jQuery('li.printPage > a').attr('href',printlink);
		jQuery('#printJoomla').hide();
	}else if(jQuery('a.printbtn').length > 0){
		var printlink = jQuery('a.printbtn').attr('href');
		jQuery('li.printPage > a').attr('href',printlink);
		jQuery('a.printbtn').hide();
	}else{
		jQuery('li.printPage').hide();
	}

	var elem = document.getElementById('navbar');
	elem.onmouseover = function anonymous(event) {
		elem.style.zIndex = 1000;
		jsddm_open();
	}

	elem.onmouseout = function anonymous(event){
		jsddm_close();
	}

	//init framework
	var IE6 = true
	if (typeof document.body.style.maxHeight != "undefined") {// IE 7, mozilla, safari, opera 9
	  IE6 = false
	}
	if(IE6){
		//alert(document.body.scrollWidth);
		//alert(screen.width);
		if(document.body.scrollHeight < 665){
			document.getElementById('Super').style.height = 665;
		}else{
			document.getElementById('Super').style.height = document.body.scrollHeight;
		}
		if(screen.width > 1024){

			window.onresize = function(){
				var num = document.body.scrollHeight
				if(num > 665){
					document.getElementById('Super').style.height = document.body.scrollHeight;
				}
			}
		}
		document.getElementById('pageMask').style.width = screen.width - 29;
	}


	setMenuImage();

if (typeof document.body.style.maxHeight != "undefined") {
	//Mouseover with animate Effect for Menu List Items
  jQuery('#navbar>ul>li>ul>li').hover(function() {
    jQuery(this).children().animate({paddingLeft:"20px"}, {queue:false, duration:300});
  },function() {
    jQuery(this).children().animate({paddingLeft:"15px"}, {queue:false, duration:300});
	//jQuery('#navbar>ul>li>ul').hide();
	jQuery('#navbar>ul>li>ul>li>ul').hide();
	jQuery('#navbar>ul>li>ul>li>ul>li>ul').hide();
  });

	



	jQuery('#navbar>ul>li>ul>li').hover(function(){
		//alert(jQuery('#navbar ul ul ul:animated').size());
		if (jQuery('#navbar ul ul:animated').size() > 0) {
            // create a reference to the active element (this)
            // so we don't have to keep creating a jQuery object
            $heading = jQuery(this);
            // create a reference to visible sibling elements
            // so we don't have to keep creating a jQuery object
            $expandedSiblings = $heading.siblings().find('ul:visible');
            if ($expandedSiblings.size() > 0) {
				$expandedSiblings.hide(500, function(){
                    $heading.find('ul').show(500);
					//$heading.find('ul').css("display","block");
                });
            }
            else {
                $heading.find('ul').show(500);
					//$heading.find('ul').css("display","block");
            }
       }

	},function () {
// hover requires 2 functions - only need one today
});
}else{
	//jQuery('#navbar>ul>li>ul').hide();
	jQuery('#navbar>ul>li>ul>li>ul').hide();
	jQuery('#navbar>ul>li>ul>li>ul>li>ul').hide();



	jQuery('#navbar>ul>li>ul>li').hover(function(){
		//alert(jQuery('#navbar ul ul ul:animated').size());
		if (jQuery('#navbar ul ul:animated').size() == 0) {
            // create a reference to the active element (this)
            // so we don't have to keep creating a jQuery object
            $heading = jQuery(this);
            // create a reference to visible sibling elements
            // so we don't have to keep creating a jQuery object
            $expandedSiblings = $heading.siblings().find('ul:visible');
            if ($expandedSiblings.size() > 0) {
				$expandedSiblings.hide(500, function(){
                    $heading.find('ul').show(500);
					//$heading.find('ul').css("display","block");
                });
            }
            else {
                $heading.find('ul').show(500);
					//$heading.find('ul').css("display","block");
            }
       }

	},function () {
// hover requires 2 functions - only need one today
});
	
}

	jQuery('ul.menurelated>li>ul').hide();
	jQuery('ul.menurelated>li>ul>li>ul').hide();

	jQuery('ul.menurelated>li').hover(function(){
		//alert(jQuery('#navbar ul ul ul:animated').size());
		if (jQuery('ul.menurelated ul:animated').size() == 0) {
            // create a reference to the active element (this)
            // so we don't have to keep creating a jQuery object
            $heading = jQuery(this);
            // create a reference to visible sibling elements
            // so we don't have to keep creating a jQuery object
            $expandedSiblings = $heading.siblings().find('ul:visible');

			//$heading.find('ul').css("display","block");
			//fadeOut , slideUp, hide
			//fadeIn, slideDown, show
			//fadeIn, slideDowm, show

            if ($expandedSiblings.size() > 0) {
				$expandedSiblings.hide(500, function(){
                    $heading.find('ul').show(500);
                });
            }
            else {
                $heading.find('ul').show(500);
            }
       }

	},function () {
// hover requires 2 functions - only need one today
});

	jQuery('ul.menurelated>li.active>ul').show();
	jQuery('ul.menurelated>li>ul>li.active>ul').show();
	jQuery('ul.menurelated>li>ul>li>ul>li.active').show();

	//Move content of headerBox to User8 panel
	$panel = jQuery('#DisplayPane').find('div.headerBox');
	$panel.hide();
	if($panel.size() > 0){
		//alert($panel.html());
		jQuery('#User8').append(jQuery($panel).html());
	}
$panel2 = jQuery('#DisplayPane').find('h4.headerBox');
	$panel2.hide();
	if($panel2.size() > 0){
		//alert($panel.html());
		jQuery('#User8').append(jQuery($panel2).html());
	}
});

function setMenuImage(){
	if(jQuery('#navbar > ul > li').hasClass('item19')){
		jQuery('#navbar > ul > li.item19 > ul').append("<li class='image'><img src='images/cv-apply.jpg' border=0></li>");

	}

	if(jQuery('#navbar > ul > li').hasClass('item16')){
		jQuery('#navbar > ul > li.item16 > ul').append("")

	}

	if(jQuery('#navbar > ul > li').hasClass('item128')){
		jQuery('#navbar > ul > li.item128 > ul').append("")

	}

	/*if(jQuery('#navbar > ul > li').hasClass('item17')){
		jQuery('#navbar > ul > li.item17 > ul').append("<li class='image'><a href='index.php?option=com_content&view=article&id=221&Itemid=206' title='Diamond Xpress Account'><img src='http://89.234.52.90/'images/stories/menu_images/diamond_xpress_account.jpg' border=0></a> <a href='index.php?option=com_content&view=article&id=176&Itemid=166' class='img2' title='Diamond Reach Account'><img src='http://89.234.52.90/images/stories/menu_images/diamond_reach.jpg' border=0></a></li>")

	}	*/

	/*if(jQuery('#navbar > ul > li').hasClass('item18')){
		jQuery('#navbar > ul > li.item18 > ul').append("<li class='image'><a href='index.php?option=com_content&view=article&id=194&Itemid=197' title='Diamond Advantage'><img src='http://89.234.52.90/'images/stories/menu_images/diamond_advantage.jpg' border=0></a> <a href='index.php?option=com_content&view=article&id=131&Itemid=127' class='img2' title='Diamond Trade Tracker'><img src=''http://89.234.52.90/images/stories/menu_images/diamond_trade_tracker.jpg' border=0></a></li>")

	}	*/

	if(jQuery('#navbar > ul > li').hasClass('item20')){
		jQuery('#navbar > ul > li.item20 > ul').append("<li class='image'><a href='index.php?option=com_content&view=article&id=218&Itemid=217' title='Press Releases'><img src='http://89.234.52.90/images/stories/menu_images/news.jpg' border=0></a> <a href='index.php?option=com_content&view=article&id=82&Itemid=81' class='img2' title='Download Centre'><img src='http://89.234.52.90/images/stories/menu_images/download.jpg' border=0></a></li>")

	}

	if(jQuery('#navbar > ul > li').hasClass('item21')){
		jQuery('#navbar > ul > li.item21 > ul').append("<li class='image'><a href='index.php?option=com_content&view=article&id=75&Itemid=76' title='Diamond Care'><img src='http://89.234.52.90/images/stories/menu_images/diamondcare.jpg' border=0></a> <a href='index.php?option=com_content&view=article&id=94&Itemid=90' class='img2' title='Find a Branch'><img src='http://89.234.52.90/images/stories/menu_images/locator.jpg' border=0></a></li>")

	}
}

