/****************************************Drop Down & Rollover Menu  ********************************/

function MM_swapImgRestore() { 
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) {
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x &&d.getElementById) x=d.getElementById(n); return x;
}

var old_menus = [];
var delay = 700;

function MM_showHideLayers() {
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i += 3) {
		if ((obj=MM_findObj(args[i])) != null) {
			v = args[i+2];
			if (obj.style) {
				v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v;
				showhide(obj, v);
			}
		}
	}
}

function OpenPhotosWindow(U) {
    openIT(U, 600, 600, true, false)
}


function openIT(u, W, H, sc) {
    window.open(u, '', "width=" + W + ",height=" + H + ",resizable=no,scrollbars=" + (sc ? "yes" : "no"));
}


function hideAllOthers()
{
	while(old_menus.length) {
		var menu = old_menus.pop();
		if(typeof menu.timeout != "undefined") window.clearTimeout(menu.timeout);
		menu.style.visibility = "hidden";
	}
}
function showhide(e, v)
{
	if(typeof e == "undefined") return;
	if(v == "visible") {
		hideAllOthers();
		if(typeof e.timeout != "undefined") window.clearTimeout(e.timeout);
		e.style.visibility = v;
	} else {
		if(typeof e.timeout != "undefined") window.clearTimeout(e.timeout);
		e.hideAfterDelay = function(){ var me = e; me.timeout = window.setTimeout(function(){ me.style.visibility = "hidden"}, delay) };
		e.hideAfterDelay();
		old_menus.push(e);
	}
}

/********************Top Menu Slide**********************/
$(document).ready(function() {
	$(".topMenuAction").click( function() {
		if ($("#openCloseIdentifier").is(":visible")) {
			$("#slider").animate({ 
				marginTop: "-115px"
				}, 350 );
			$(".topMenuAction").html('<img src="images/close.png" alt="close" />');
			$("#openCloseIdentifier").hide();
		} else {
			$("#slider").animate({ 
				marginTop: "0px"
				}, 600 );
			$(".topMenuAction").html('<img src="images/open.png" alt="open" />');
			$("#openCloseIdentifier").show();
		}
	});
});

/*******************Change Font*************************/
var max_font_size = 18;
var min_font_size = 12;

$(function(){
	$('a.controls').click(function(){
		var ourText = $('#contentControls, #contentControls');
		var currFontSize = ourText.css('fontSize');
		var finalNum = parseFloat(currFontSize, 12);
		var stringEnding = currFontSize.slice(-2);
		if(this.id == 'large') {
			if(finalNum < max_font_size) finalNum += 2;
		}
		else if (this.id == 'small'){
			if(finalNum > min_font_size) finalNum -=2;
		}
		ourText.css('fontSize', finalNum + stringEnding);
	});
});

/*****************Footer Menu Slide******************/
/*$(document).ready(function() {
	$(".footerMenuAction").click( function() {
		if ($("#openCloseFooter").is(":hidden")) {
			$("#sliderFooter").animate({ 
				marginTop: "-141px"
				}, 500 );
			$("#footerMenuImage").html('<img src="images/top.png" alt="open" />');
			$("#openCloseFooter").show();
		} else {
			$("#sliderFooter").animate({ 
				marginTop: "0px"
				}, 500 );
			$("#footerMenuImage").html('<img src="images/down.png" alt="close" />');
			$("#openCloseFooter").hide();
		}
	});  
});*/

$(function() {
	var open = false;
	$('#footerSlideButton').click(function() {
	if(open === false) {
		$('#footerSlideContent').animate({ height: '150px'},300);
		$(this).css('backgroundPosition', 'bottom left');
		open = true;
	}else{
		$('#footerSlideContent').animate({ height: '10px'},300);
		$(this).css('backgroundPosition', 'top left');
		open = false;
	}
	});
});

/*******Accordion*************/

$(document).ready(function() {
	$('.acc_container').hide();
	$('.acc_trigger:first').addClass('active').next().show();
	
	//On Click
	$('.acc_trigger').click(function(){
		if( $(this).next().is(':hidden') ) {
			/*$('.acc_trigger').removeClass('active').next().slideUp();*/
			$(this).toggleClass('active').next().slideDown();
		}else{
			$(this).toggleClass('active').next().slideUp();
		}
		return false;
	});
});

function showTooltipAdv(ObjectID) {

    $(ObjectID).tooltip({ bodyHandler: function () { return $($(this).attr("href")).html(); }, showURL: false });
}

//function MakeColumnsInvisibleIfEmpty() {
//    var RightTD = $("#rightcolumn");
//    var RightSpacer = $("#rightspacer");
//    var RightZone = $("#BICMSZone1_Panel1")

//    var agt = navigator.userAgent.toLowerCase();
//    var isNav = ((agt.indexOf('mozilla') != -1) && ((agt.indexOf('spoofer') == -1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1)));
//    var isIE = (agt.indexOf("msie 8") != -1 || agt.indexOf("msie 7") != -1 || agt.indexOf("msie 6") != -1);
//    var isIE9andHigher = (agt.indexOf("msie 8") == -1 && agt.indexOf("msie 7") == -1 && agt.indexOf("msie 6") == -1 && agt.indexOf("msie") != -1);

//    //  alert(agt);

//    //alert(RightZone[0].childNodes.length);
//    if ((isIE && RightZone[0].childNodes.length <= 3) || (isNav && RightZone[0].childNodes.length < 8) || (isIE9andHigher && RightZone[0].childNodes.length < 8)) 
//     {
//      //  RightTD[0].style.display = "none";
//      //  RightSpacer[0].style.display = "none";
//    }
// 
//}


/************************************************/

function updateBackgroundSize()
{
	var windowheight = $(document).height();
    $('div.whiteBg').height(windowheight);

}
$(document).ready(function() {
	updateBackgroundSize()

	$(".acc_trigger").click(function(){
		window.setTimeout(updateBackgroundSize, 500);
	})

});


// for the window resize
$(window).resize(function() {
    updateBackgroundSize();
});

$(window).load(function() {
    updateBackgroundSize();
});


$(document).ready(function() {
	var windowheight2 = $(document).height();
	$('div.maskHome').css({height:windowheight2});
});


/******************Tooltip*************************/

/******************End Tooltip************************/
/***********************PRINT******************************/

function print_function()
{     
	var disp_setting="toolbar=no,location=no,directories=no,menubar=no,";
	disp_setting+="scrollbars=yes,width=610, height=400, left=100, top=100";
	var content_value = document.getElementById("contentControls").innerHTML;
	var docprint=window.open("","",disp_setting);
	docprint.document.open();
	docprint.document.write('<html><head><title>test</title>');
	docprint.document.write('<link rel="stylesheet" type="text/css" href="styles/mentorarabia.css" media="screen" /><style>.acc_container{display:block !important;font-size:12px;}</style></head><body onLoad="javascript:self.print(); self.close();">');
	docprint.document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td style="padding:10px;">'+content_value+'</td></tr></table>');
	docprint.document.write('</body></html>');
	docprint.document.close(); 
 	docprint.focus();
}
/**************************PRINT******************************/
