/* ------------ LEFTSIDE DROPDOWN MENU -------------- */
/*var menuids=["sidebarmenu1"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas

function initsidebarmenu(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
    ultags[t].parentNode.getElementsByTagName("a")[0].className+=" subfolderstyle"
  if (ultags[t].parentNode.parentNode.id==menuids[i]) //if this is a first level submenu
   ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px" //dynamically position first level submenus to be width of main menu item
  else //else if this is a sub level submenu (ul)
    ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.display="block"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.display="none"
    }
    }
  for (var t=ultags.length-1; t>-1; t--){ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
  ultags[t].style.visibility="visible"
  ultags[t].style.display="none"
  }
  }
}

if (window.addEventListener)
window.addEventListener("load", initsidebarmenu, false)
else if (window.attachEvent)
window.attachEvent("onload", initsidebarmenu) */
$(window).load(function(){
	$("div.allcontent").css({display:"block"});
});
/* ------------- CHANGE FONT SIZE ------------- */
$(document).ready(function(){
  // Reset Font Size
  var originalFontSize = $('.internaltxt p').css('font-size');
  $(".resetFont").click(function(){
  $('.internaltxt p').css('font-size', originalFontSize);
  });
	// Increase Font Size
  $(".increaseFont").click(function(){
  	var currentFontSize = $('.internaltxt p').css('font-size');
 		var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.1;
	$('.internaltxt p').css('font-size', newFontSize);
	return false;
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
  	var currentFontSize = $('.internaltxt p').css('font-size');
 		var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*0.8;
	$('.internaltxt p').css('font-size', newFontSize);
	return false;
  });
	
	
	// FIX CHROME BUGS
	if($.browser.safari){
		$("#ControlSearch1_PanSearch").css({"position":"relative", "left":80, "top":-2});
		$("#ControlSearch1_PanSearch input[type=image]").css("margin-top", 2);
	}
});


/*------------ LEFTSIDE MENU ROLLOVER ------------ */

function MM_swapImgRestore() { //v3.0
  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_findObj(n, d) { //v4.01
  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;
}

function MM_swapImage() { //v3.0
  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_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) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	obj.visibility=v; }
}



/*
	TOP MENU
*/
$(document).ready(function()
{
/* -------------- TOP MENU -------------- */
	 	$('#bcl-cards, #bcl-services').hover(function() {
		$("ul", $(this)).show();
		$("a:first", $(this)).addClass("on");
	}, function() {
			$("ul", $(this)).hide();
			$("a:first", $(this)).removeClass("on");
		});	
		
		
	$('div.cardphoto').next().next().addClass("more_info");
	/*$('#sidebarmenu1').next().css('margin-top', 20);*/
	$('#internal-content-wrapper .underline-titles').next().css('margin-bottom', 20);
	$('.back').parent().css('float', 'right');
	$('select.username-form').css('background','url(../images/search-bg.gif)');
	$('select.username-form').css('font-family','arial');

	$("#leftside-menu li ul").hide()
    
    $("#leftside-menu li a.toggler").click(function() {
        if($(this).parent().children("ul").css("display") == "none") {
            // show
            $(this).data("opened", "true");
            $(this).parent().children("ul").slideDown(500);
            $(this).parent().addClass("noheight");
        } else {
            // hide
            $(this).parent().children("ul").slideUp(300, function(){ $(this).parent().removeClass("noheight"); });
            $(this).data("opened", "false");
        }
    });
    $("#leftside-menu li a.toggler").mouseout(function() {
        if($(this).data("opened") == "true") {
            var src = $("img", $(this)).attr("src").split("-off").join("-on");
            $("img", $(this)).attr("src", src);
        }
    });
		
		if(typeof active_menu_id != "undefined") {
				$("#leftside-menu li#"+active_menu_id+" a.toggler").click().mouseout();
		}
		$('li.left-main-titles ul').css('border-top', '1px solid #fff');
		$('li.left-main-titles ul').css('background', '#777');
		$('li.left-main-titles ul').css('padding-top', 5);
		/*$('.tradition-list li').css('list-style-type', 'none');*/
		
	$('div#printarea h5:first, div#printarea dl:first, div#printarea ul:first').css({'margin-top':0, 'padding-top':0});
	$('.board-of-directors-listing tr:last td').css('border-bottom','none');
});
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;
}
function ValidateOtherSearch(source, args) {
    if (MM_findObj("ControlSearch1_txtSearch").value == "" || MM_findObj("ControlSearch1_txtSearch").value == "Search...")
        args.IsValid = false;
    else
        args.IsValid = true;
}

var max_font_size = 16;
var min_font_size = 10;

$(function(){
	$('.controls a').click(function(){
		var ourText = $('.main-content, .main-content td, .main-content div, .main-content span, .main-content a, .main-content h5, .main-content h1, .main-content p, .main-content h4,  .main-content ul,  .main-content li');
		var currFontSize = ourText.css('fontSize');
		var finalNum = parseFloat(currFontSize, 11);
		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);
	});
});

$(document).ready(function(){
$("#slideMail").hide();
$("a#mailBtn").click(function () {
  if ($("#slideMail").is(":hidden")) {
	$("#slideMail").slideDown("slow");
  } else {
	$("#slideMail").slideUp();
  }
});
$("#closeMail").click(function(){
	$("#slideMail").slideUp();							   
})
});

function print_function(title1,title2)
{ 
    title1 = title1.split("€").join("@@")
    title2 = title2.split("€").join("@@")
	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("printarea").innerHTML;
	var docprint=window.open("","",disp_setting);
	docprint.document.open();
	docprint.document.write('<html><head><title>Banque de Syrie et du Liban</title>');
	docprint.document.write('<link rel="stylesheet" type="text/css" href="css/bsl.css" media="screen" /></head><body onLoad="window.print()">');
	if (title2 == "-1") {
	    docprint.document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td style="padding:10px;"><div style="border-bottom:1px solid #00a6db; padding:0 0 10px 0;"><img src="../images/bsl-logo.gif"></div></td></tr><tr><td><div style="padding-left:10px;"><object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="26"><param name="movie" value="swf/title.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="swfversion" value="9.0.45.0" /><!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you donít want users to see the prompt. --><param name="expressinstall" value="Scripts/expressInstall.swf" /><param name="flashvars" value="title=' + title1 + '" /><!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --><!--[if !IE]>--><object type="application/x-shockwave-flash" data="swf/title.swf" width="400" height="24"><!--<![endif]--><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="swfversion" value="9.0.45.0" /><param name="expressinstall" value="Scripts/expressInstall.swf" /><param name="flashvars" value="title=' + title1 + '" /><!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --><div><h4>Content on this page requires a newer version of Adobe Flash Player.</h4><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p></div><!--[if !IE]>--></object><!--<![endif]--></object></div></td></tr><tr><td style="padding:10px;">'+content_value+'</td></tr></table>');
	} else {
	    docprint.document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td style="padding:10px;"><div style="border-bottom:1px solid #00a6db; padding:0 0 10px 0;"><img src="../images/bsl-logo.gif"></div></td></tr><tr><td><div style="padding-left:10px;"><object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="26"><param name="movie" value="swf/title.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="swfversion" value="9.0.45.0" /><!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you donít want users to see the prompt. --><param name="expressinstall" value="Scripts/expressInstall.swf" /><param name="flashvars" value="title=' + title1 + '" /><!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --><!--[if !IE]>--><object type="application/x-shockwave-flash" data="swf/title.swf" width="400" height="24"><!--<![endif]--><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="swfversion" value="9.0.45.0" /><param name="expressinstall" value="Scripts/expressInstall.swf" /><param name="flashvars" value="title=' + title1 + '" /><!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --><div><h4>Content on this page requires a newer version of Adobe Flash Player.</h4><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p></div><!--[if !IE]>--></object><!--<![endif]--></object></div><div style="padding-left:10px; padding-bottom:20px;"><object id="FlashID2" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="22"><param name="movie" value="swf/titleSub.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="swfversion" value="9.0.45.0" /><!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you donít want users to see the prompt. --><param name="expressinstall" value="Scripts/expressInstall.swf" /><param name="flashvars" value="titleSub=' + title2 + '" /><!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --><!--[if !IE]>--><object type="application/x-shockwave-flash" data="swf/titleSub.swf" width="400" height="22"><!--<![endif]--><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="swfversion" value="9.0.45.0" /><param name="expressinstall" value="Scripts/expressInstall.swf" /><param name="flashvars" value="titleSub=' + title2 + '" /><!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --><div><h4>Content on this page requires a newer version of Adobe Flash Player.</h4><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p></div><!--[if !IE]>--></object><!--<![endif]--></object></div></td></tr><tr><td style="padding:10px;">'+content_value+'</td></tr></table>');
	}
	docprint.document.write('</body></html>');
	docprint.document.close(); 
 	//docprint.focus();
}


function ValidateSearch(source, args)
{
if (MM_findObj('ControlSearch1_txtSearch').value.length < 3 )
	args.IsValid = false;
else
	args.IsValid = true;
}


/*******Flash Title************/


var requiredVersion = 8;   
var useRedirect = false;
var flashPage   = ""
var noFlashPage = ""
var upgradePage = ""
var flash2Installed = false;    
var flash3Installed = false;    
var flash4Installed = false;    
var flash5Installed = false;    
var flash6Installed = false;    
var flash7Installed = false;    
var flash8Installed = false;    
var flash9Installed = false;    
var maxVersion = 9;             
var actualVersion = 0;          
var hasRightVersion = false;    
var jsVersion = 1.0;

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; 
jsVersion = 1.1;

if(isIE && isWin){

  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
  document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
  document.write('<\/SCR' + 'IPT\> \n'); 

}

function detectFlash() {  

  if (navigator.plugins) {
    if (navigator.plugins["Shockwave Flash 2.0"]
        || navigator.plugins["Shockwave Flash"]) {
      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
      var flashVersion = parseInt(flashDescription.substring(16));
      flash2Installed = flashVersion == 2;    
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion == 6;
      flash7Installed = flashVersion == 7;
      flash8Installed = flashVersion == 8;
      flash9Installed = flashVersion >= 9;
    }
  }
  for (var i = 2; i <= maxVersion; i++) {  
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 4;  
  if (actualVersion >= requiredVersion) {
    if (useRedirect) {
      if(jsVersion > 1.0) {
        window.location.replace(flashPage);  
      } else {
        window.location = flashPage;
      }
    }
    hasRightVersion = true;                
  } else {  
    if (useRedirect) {
      if(jsVersion > 1.0) {
        window.location.replace((actualVersion >= 2) ? upgradePage : noFlashPage);
      } else {
        window.location = (actualVersion >= 2) ? upgradePage : noFlashPage;
      }
    }
  }
}
detectFlash();

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs




    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
