/*
********Top Nav***********
*/
sfHover = function(nav) {
	var sfEls = document.getElementById(nav).getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("\\s?sfhover\\b"), "");
		}
	}
}

showHide = function() {
  var divs = document.getElementsByTagName('div');

  for (var i=0; i<divs.length; i++) {
	var div = divs[i];
    var classAttribute = String(div.getAttribute('title'));
	if (classAttribute.toLowerCase().match('showhide')) {
	  div.style.cursor = "pointer";
	  div.onclick = function () { this.style.visibility = (this.style.visibility == "visible") ? "hidden" : "visible"; return false; }	
	}
  }  
}

maintainHighlight = function(menu) {
  var listItem = document.getElementById(menu).getElementsByTagName('ul'); 
  for(var i=0;i<listItem.length;i++) {
    listItem[i].onmouseover=function() {
     
      if(menu == 'menu') {
        var changeStyle = this.parentNode.getElementsByTagName('a');
        changeStyle[0].style.color = "#fff";
        changeStyle[0].style.backgroundPosition = "right -30px";
      } else {
        var changeStyle = this.parentNode.getElementsByTagName('span');
        if(changeStyle.length>0)
            changeStyle[0].style.color = "#990000";
      }
    }
           
    listItem[i].onmouseout=function() {
      if(menu == 'menu') {
        var changeStyle = this.parentNode.getElementsByTagName('a');
        changeStyle[0].removeAttribute('style');
      } else {
        var changeStyle = this.parentNode.getElementsByTagName('span');
        if(changeStyle.length>0)
            changeStyle[0].removeAttribute('style');
      }
    }
  }
}

function addEvent( obj, type, fn ) {
  if ( obj.attachEvent ) {
    obj['e'+type+fn] = fn;
    obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
    obj.attachEvent( 'on'+type, obj[type+fn] );
  } else
    obj.addEventListener( type, fn, false );
  }
function removeEvent( obj, type, fn ) {
  if ( obj.detachEvent ) {
  obj.detachEvent( 'on'+type, obj[type+fn] );
  obj[type+fn] = null;
  } else
    obj.removeEventListener( type, fn, false );
  }

addEvent(window, 'load', function () { sfHover('menu'); maintainHighlight('menu'); });
addEvent(window, 'load', function () { sfHover('option1'); maintainHighlight('option1'); });
addEvent(window, 'load', function () { sfHover('option2'); maintainHighlight('option2'); });
addEvent(window, 'load', function () { sfHover('option3'); maintainHighlight('option3'); });
addEvent(window, 'load', showHide);

/*

*******Cycle*******

  Based on the work of:
    Matt Oakes: http://portfolio.gizone.co.uk/applications/slideshow/
    Torsten Baldes: http://medienfreunde.com/lab/innerfade/
*/

(function($) {

$.fn.cycle = function(options) {

  this.each(function(){
	
    var settings = {
      animationtype: 'fade',
      speed: 1000,
      timeout: 8000,
      containerheight: 'auto',
      runningclass: 'cycle',
      playState: 'play'
    };

    if(options) $.extend(settings, options);
    var elements = $(this).find('ul').children();
  
    if (elements.length > 1) {

      $(this).css('float', 'left');
      $(this).find('ul').css('position', 'relative');
      $(this).addClass(settings.runningclass);
      $(this).find('ul').css('height', settings.containerheight);
      $(this).find('li').slice(0,1).css('display','block');
      $(this).append("<div class='nav'><a class='button previous' href='#'>Previous</a><a class='button pause' href='#'>Pause</a><a class='button next' href='#'>Next</a><ul class='numbers'></ul></div>");

      $(this).find(".nav").css({marginTop:outerHeight($(this).find("li:eq(0)")) + "px"});
      
      settings.parent = $(this);

      for ( var i = 0; i < elements.length; i++ ) {
        $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute');
        $(elements[i]).hide();
        $(this).find(".nav .numbers").append('<li><a href="#">' + (i + 1) + '</a></li>');
      };
      
      $(this).find(".nav .numbers li:first").addClass("active");
      $(this).find(".nav .numbers li:last a").addClass("last");

      settings.next = 1; settings.current = 0;
      setTimeout(function(){$.cycle.next(elements, settings);}, settings.timeout);
      $(elements[0]).show();

    };
    
  //Pause Button	
    $(this).find('.pause').click(function() {
    
      settings.playState = (settings.playState == "pause") ? "play" : "pause";
      $(this).toggleClass("play");
      
      return false;
    });
	
  //Next Button
    $(this).find('.next').click(function() {
    						 
      settings.playState = "pause";
      $(this).parent(".nav").find(".pause").addClass("play");
      
      $.cycle.transition(settings, elements);
      return false;
    });
    
  //Previous Button
    $(this).find('.previous').click(function(next, current) {
    
      settings.playState = "pause";
      $(this).parent(".nav").find(".pause").addClass("play");
      
      if ( settings.current == 0 ) { settings.next = elements.length - 1; } else { settings.next = settings.current - 1; };
      $.cycle.transition(settings, elements, next, current);
      return false;
    });
  
  //Number Buttons
    $(this).find(".numbers li").click(function() {
       
      if(!$(this).hasClass("active")) {
        $(settings.parent).find(".numbers li").removeClass("active");
        $(this).addClass("active");
        
        settings.playState = "pause";
        $(settings.parent).find(".nav .pause").addClass("play");
      
        settings.next = $(this).find("a").text() - 1;
        $.cycle.transition(settings, elements);
      }
      
      return false;
    });

  });
};

$.cycle = function() {}
  $.cycle.next = function (elements, settings) {
  if ( settings.playState == 'play' ) { $.cycle.transition(settings, elements); };
    setTimeout((function(){$.cycle.next(elements, settings);}), settings.timeout);
  };

  $.cycle.transition = function (settings, elements) {
  
    $(settings.parent).find(".nav").css({marginTop:outerHeight($(settings.parent).find("li:eq(" + settings.next + ")")) + "px"});
    $(settings.parent).find(".nav .numbers li").removeClass("active");
    $(settings.parent).find(".nav .numbers li:eq(" + settings.next + ")").addClass("active");

    $(settings.parent).find(".elements li:visible").fadeOut(settings.speed);
    $(elements[settings.next]).fadeIn(settings.speed);

    if ( ( settings.next + 1 ) < elements.length ) {
      settings.next = settings.next + 1;
      settings.current = settings.next - 1;
    } else {
      settings.next = 0;
      settings.current = elements.length - 1;
    };

  };
})(jQuery);

$(document).ready(function(){
  $(".cycle").cycle();
  positionDiv();
});

/*

*******Scroll*******

  Based on the work of:
    Matt Oakes: http://portfolio.gizone.co.uk/applications/slideshow/
    Torsten Baldes: http://medienfreunde.com/lab/innerfade/
*/

$.fn.accessscroll = function(settings) {
  settings = $.extend({
    scrollSpeed: "slow",
    scrollItemsPerSet: "2",
    scrollPosition:"0"
  }, settings);
  return this.each(function(i) {
    ascroll.init(settings,this);
  });
};
var scroll = function(s,p) {
	var item = $(p).find(".contianer");
	
	if(s.scrollPosition==0 || s.scrollPosition=="NaN")
		s.scrollPosition = s.animateLeft;
	else
	{
		s.scrollPosition = parseInt(s.scrollPosition) + parseInt(s.animateLeft);
		s.animateLeft = s.scrollPosition;
	}
	$(p).find(".container").stop().animate({ left: s.animateLeft }, s.scrollSpeed);
}

var ascroll = {
	    init: function(s, p) {
	        if ($.browser.msie && $(p).hasClass("featured-items")) {
	            var parentWidth = $(p).find(".box-body").width() - (parseInt($(p).find(".box-body").css("paddingLeft")) + parseInt($(p).find(".box-body").css("paddingRight")));
	            $("mainIte").css({ width: parentWidth + "px" });
	            $(p).find(".box-body").css({ width: parentWidth + "px" });
	            
	        }

	        var itemWidth = outerWidth($(p).find(".elements li:eq(0)"));

	        var itemLength = $(p).find(".elements li").length;
	        var itemSets = Math.ceil(itemLength / s.scrollItemsPerSet);
	        var scrollContainerWidth = itemLength * itemWidth;
	        

	        $(p).find(".elements").wrap("<div class='container'></div>");
	        $(p).find(".container").css("width", scrollContainerWidth+8 + "px");

	        if (itemSets > 1) {

	            $(p).append("<div class='nav'><a id=\"previous\" class='button previous disabled' href='#'>Previous</a><a class='button next' href='#'>Next</a></div>");

	            if ($(p).hasClass("featured-items")) {

	                $(p).find(".nav").append('<ul class="dots"></ul>');

	                for (var i = 0; i < itemSets; i++) {
	                    $(p).find(".dots").append("<li><a href='#'>" + (i + 1) + "</a></li>");
	                };

	                $(p).find(".dots li").slice(0, 1).addClass("active");
	                $(p).find(".dots li:last a").addClass("last");
	                
	            }
	            else {
	                $(p).find(".nav").append('<ul class="numbers"></ul>');
	                for (var i = 0; i < itemSets; i++) {
	                    $(p).find(".numbers").append("<li><a class='nn' href='#'>" + (i + 1) + "</a></li>");
	                };
	                $(p).find(".numbers li").slice(0, 1).addClass("active");
	                $(p).find(".numbers li:last a").removeClass("nn").addClass("last");
	            }
	            // Next Button
	            $(p).find(".next").click(function() {
	                if (!$(p).find(".next").hasClass("disabled")) {
	                	try
	                	{
		                	var currentItem = parseInt($(p).find(".dots .active").text());
		                	var nextItem = $(p).find(".dots li:nth-child("+ (currentItem + 1) +")");
		                	if(isNaN(currentItem))
		                	{
		                		currentItem = parseInt($(p).find(".numbers .active").text());
		                		nextItem = $(p).find(".numbers li:nth-child("+ (currentItem + 1) +")");
		                	}
	                	}catch(e)
	                	{
	                		alert('s');
	                	}
	            		 $(nextItem).trigger('click');
	                	 var setWidth = itemWidth * s.scrollItemsPerSet;
	                	
	                }
	                if ((parseInt($(p).find(".container").css("left")) + parseInt($(p).find(".container").css("width")) - setWidth) <= setWidth) {
	                    $(p).find(".next").addClass("disabled");
	                }
	                $(p).find(".next").trigger('blur');
	                return false;
	            });
	            //Previous Button
	            $(p).find("#previous").click(function() {
	                if (!$(p).find("#previous").hasClass("disabled")) {
	                	try{
		                	var currentItem = parseInt($(p).find(".dots .active").text());
		                	var nextItem = $(p).find(".dots li:nth-child("+ (currentItem - 1) +")");
		                	if(isNaN(currentItem))
		                	{
		                		currentItem = parseInt($(p).find(".numbers .active").text());
		                		nextItem = $(p).find(".numbers li:nth-child("+ (currentItem - 1) +")");
		                	}
	                	}catch(e)
	                	{
	                		alert('d');
	                	}
	                	$(nextItem).trigger('click');
	                	$(p).find("#previous").trigger('blur');
	                }
	                if (parseInt($(p).find(".container").css("left")) >= -(itemWidth * s.scrollItemsPerSet)) {                	
	                	$(p).find("#previous").addClass("disabled");
	                }
	                return false;
	            });
	            //Number Buttons
	            $(p).find(".numbers li").click(function() {
	                if (!$(this).hasClass("active")) {
	                	
	                    var currentItem = parseInt($(p).find(".numbers .active").text());
	                    var selectedItem = parseInt($(this).text());
	                    if (currentItem > selectedItem) var direction = "+"; else direction = "";
	                    s.animateLeft = direction + (itemWidth * s.scrollItemsPerSet) * (currentItem - selectedItem);
	                    scroll(s, p);
	                    $(p).find(".numbers li").removeClass("active");
	                    $(this).addClass("active");
	                    $(p).find(".nav a").removeClass("disabled")
	                    if ($(this).text() == 1)
	                        $(p).find("#previous").addClass("disabled");
	                    else if ($(this).text() >= ($(p).find(".elements li").length / s.scrollItemsPerSet))
	                        $(p).find(".next").addClass("disabled");
	                    else
	                        $(p).find(".next").removeClass("disabled");
	                }
	                return false;
	            });
	            $(p).find(".dots li").click(function() {
	                if (!$(this).hasClass(".active")) {
	                    var currentItem = parseInt($(p).find(".dots .active").text());
	                    var selectedItem = parseInt($(this).text());
	                    if (currentItem > selectedItem) var direction = "+"; else direction = "";
	                    s.animateLeft = direction + (itemWidth * s.scrollItemsPerSet) * (currentItem - selectedItem);
	                    scroll(s, p);
	                    $(p).find(".dots li").removeClass("active");
	                    $(this).addClass("active");
	                    $(p).find(".nav a").removeClass("disabled")
	                    if ($(this).text() == 1)
	                        $(p).find("#previous").addClass("disabled");
	                    else if ($(this).text() >= ($(p).find(".elements li").length / s.scrollItemsPerSet))
	                        $(p).find(".next").addClass("disabled");
	                    else
	                        $(p).find(".next").removeClass("disabled");
	                }
	                return false;
	            });
	        }
	    }
	};

$(function() {
  $(".scroll").accessscroll({ scrollSpeed: "medium", scrollItemsPerSet: "2" });
  $(".featured-items").accessscroll({ scrollSpeed: "slow", scrollItemsPerSet: "2" });
});


/*

*******Bits*******

*/


// Returns the number only pixel of a given item
var num = function(el, prop) {
  return parseInt($.css(el.jquery?el[0]:el,prop))||0;
};

// Returns the outerHeight of a given item
var outerHeight = function(element) {
  outerWidthResult = element.height() + num(element,'borderTopWidth') + num(element, 'borderBottomWidth') + num(element, 'paddingTop') + num(element, 'paddingBottom') + num(element, ',marginTop') + num(element, 'marginBottom');
  return outerWidthResult;
}

// Returns the outerWidth of a given item
var outerWidth = function(element) {
  outerWidthResult = element.width() + num(element,'borderLeftWidth') + num(element, 'borderRightWidth') + num(element, 'paddingLeft') + num(element, 'paddingRight') + num(element, ',marginLeft') + num(element, 'marginRight');
  return outerWidthResult;
}

$.fn.popUp = function() {
  $(this).click(function () {  
    var hrefLocation = $(this).attr("href");
    window.open(hrefLocation, 'popup', 'toolbar=0,scrollbars=yes,location=1,statusbar=0,menubar=1,resizable=1,width=820,height=580,left=20,top=20');
    return false;
  });
};

//Swaps out gallery media elements (such as a photo gallery or timeline component)
$.fn.galleryToggle = function() {

  if( !$("#video").attr("id") ) {
  
    var elementId = (location.hash).substring(1);

    if (elementId) {  
      var playerURL = "http://photos.america.gov/galleries/amgov" + elementId;
      $.fn.galleryToggle.swap(playerURL,elementId);
    } else if ( !(elementId) && ($(".player").attr("class")) ) {
      var playerURL = $(".collection-box li:eq(0) a.gallerylink").attr("href");
      var elementId = playerURL.split('amgov')[1];
      $.fn.galleryToggle.swap(playerURL,elementId);
    }

    this.each(function() {
      $(this).find(".collection-box li, .box-body li").click(function () {
        var playerURL = $(this).find("a.gallerylink").attr("href");
        var elementId = playerURL.split('amgov')[1];
        $.fn.galleryToggle.swap(playerURL,elementId);
        return false;
      });
    });
  }
};

$.fn.galleryToggle.swap = function(playerURL,elementId) {
  $(".player").html('<iframe src="' + playerURL + '" frameborder=0 width=616 height=418 scrolling=no></iframe>');
  parent.location.hash = elementId;
  $.fn.galleryToggle.activeHighlight(playerURL);
};

$.fn.galleryToggle.activeHighlight = function(playerURL) {
  $(".collection-box").find("li").removeClass("active");
    
  var matchContent = $("a[href=" + playerURL + "]:eq(1)").text();    
  var tabName = $(".collection-box ul:contains('" + matchContent + "')").attr("title");

  if(matchContent && tabName) {
    $(".collection-nav").find("li").removeClass();
    $(".collection-box").find(".elements").hide();

    $(".collection-box ul:contains('" + matchContent + "')").show();
    $(".collection-box li:contains('" + matchContent + "')").addClass("active");
    $(".collection-nav li:contains('" + tabName + "')").addClass("active");
  }
};


// Tabbed Displays in which the tab is on the left (calendars, etc)
$.fn.tab = function() {
  this.each(function(){
    var columnWidth = $(this).width();
    if(columnWidth < 316) var column = "narrow"; else var column = "wide";
    $(this).find(".box-body:eq(0)").addClass("modified " + column);

    var tabHeight = outerHeight($(this).find(".tab-nav:eq(0)"));
    var i = 0;
    while ((i + 1) <= $(this).find(".tab-content").length) {
      if(i != 0) {
        var moveTabHeight = tabHeight * i;
        $(this).find(".tab-content:eq(" + i + ")").css({marginTop:-moveTabHeight});
      }
      i++;
    };

  });
  $(".tab-nav").click(function () {  
    $(this).parent().parent().find("li").removeClass("active");
    $(this).parent().addClass("active");
    return false;
  });
};

//Tabbed Collection Boxes (Such as on the video, photo gallery or webchat pages)
$.fn.tabbedCollection = function() {

  var p = $(this); 
  $(p).prepend("<ul class='collection-nav'></ul>");
  
  var i = 0;
  while ((i + 1) <= $(p).find(".elements").length) {
    var currentElement = $(p).find(".elements:eq(" + i + ")");
    var tabName = $(currentElement).attr("title");
    var tabID = "tab" + Math.floor(Math.random()*1001)
    $(p).find(".collection-nav").append("<li class=\"open\"><a href='#" + tabID + "' rel='#" + tabID + "'>" + tabName + "</a></li><li class=\"close\"></li>");
    $(currentElement).attr({"id":tabID});
    i++;
  };
  
  $(p).find(".collection-nav li:eq(0)").addClass("active");
  $(p).find(".collection-box li:eq(0)").addClass("active");

  $(p).find(".elements").hide();
  $(p).find(".elements:eq(0)").show();

  $(p).find(".collection-box li").click(function () {
    $(".collection-box li.open").removeClass("active");
    $(this).addClass("active");
  });

  $(p).find(".collection-nav li.open").click(function () {  
    $(this).parent().find("li").removeClass("active");
    $(this).addClass("active");

    var elementList = $(this).find("a").attr("rel");
    //elementList = elementList.hash;
    $(p).find(".elements").hide();
    $(p).find(elementList).show();
    return false;
  });
};

// Search Text Hint Show/Hide
// By Remy Sharp: http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/
$.fn.hint = function () {
  return this.each(function (){
    var p = $(this); 
    var title = p.attr('title'); 
    if (title) { 
      p.blur(function (){ if (p.val() == '') { p.val(title); p.addClass('blur'); } });
      p.focus(function (){ if (p.val() == title) { p.val(''); p.removeClass('blur'); } });
      p.parents('form:first()').submit(function(){ if (p.val() == title) { p.val(''); p.removeClass('blur'); } });
      p.blur();
    }
  });
}

//Swap web chat elements from the hidden list
$.fn.webchatSwap = function () {
  var p = this;
  $(p).find("#webchat-items").hide();

  var elementId = location.hash;
  if (elementId) {
    $.fn.webchatSwap.swap(elementId,p);
  } else {
    var elementId = "#" + $(p).find("#webchat-items div:eq(0)").attr("id");
    if(elementId != "#undefined") $.fn.webchatSwap.swap(elementId,p);
  }

  $(this).find(".collection-box li").click(function () {  
    var elementId = $(this).find("a:eq(0)").attr("href");
    $.fn.webchatSwap.swap(elementId,p);
    parent.location.hash = elementId;
    return false;
  });
}

$.fn.webchatSwap.swap = function(elementId,p) {
  $(p).find(".webchat-current").empty();
  $(elementId).clone().appendTo($(p).find(".webchat-current")).enlarge();

  if($.browser.msie && ($.browser.version < 7)) { //This is a *really* dirty IE6 hack. C'est la vie.
    $(p).find(".webchat-current").empty();
    $(elementId).clone().appendTo($(p).find(".webchat-current")).enlarge();
  }
};

$(function() {

  $(".tabbed").tab();
  $(".search-text").hint();

  $("#webchats, #ejournals").webchatSwap();
  $(".tabbed-collection").tabbedCollection(); //Top tabs function, active state on content elements. Used for video, webchats, photos
  $("#photo .tabbed-collection, #photo .scroll").galleryToggle();

  $(".quiz").quiz();

  $("a[href*='#popup']").popUp();

  $(".print a").click(function () { window.print(); return false; });
  $(".back").click(function () { history.go(-1); return false; });

  //Preserves the mouse-over on top-level menu elements when hovering over children
  $("#menu ul ul").each(function(i){
    $(this).hover(function(){
      $(this).parent().find("a").slice(0,1).addClass("maintainHover"); 
    },function(){ 
      $(this).parent().find("a").slice(0,1).removeClass("maintainHover"); 
    });
  });

  // IE6 Fix: Drop-down fix due to lack of support for :hover on list elements
  if($.browser.msie && ($.browser.version < 7)) {
    $("#menu ul").each(function(i){
      $(this).find("li").hover(function(){
        $(this).find("ul").addClass("ieHover");
      },function(){ 
        $(this).find("ul").removeClass("ieHover"); 
      });
    });
  }

  // IE6 Fix: Corrects IE6' lack of :first-child support 
  if($.browser.msie && ($.browser.version < 7)) {
    //$("#index .package-list li:last-child").css({ border: "none", marginBottom: "0", paddingBottom: "0" }); <-- Not needed?
    $("#footer li:last-child").css({ border: "none", marginRight: "0", paddingRight: "0" });
    $("#package .rss-items li:last-child").css({ border: "none" });
  }

  //Zebra Striping for tables
  $("tr:nth-child(odd)").addClass("odd");
  
});

/*

*******Enlarge*******

*/


$(function() {

  $("a[rel='enlarge']").prepend("<div class='enlarge'/>");

  var viewport = {
    o: function() {
      if (self.innerHeight) {
        this.pageYOffset = self.pageYOffset;
        this.pageXOffset = self.pageXOffset;
        this.innerHeight = self.innerHeight;
        this.innerWidth = self.innerWidth;
      } else if (document.documentElement && document.documentElement.clientHeight) {
        this.pageYOffset = document.documentElement.scrollTop;
        this.pageXOffset = document.documentElement.scrollLeft;
        this.innerHeight = document.documentElement.clientHeight;
        this.innerWidth = document.documentElement.clientWidth;
      } else if (document.body) {
        this.pageYOffset = document.body.scrollTop;
        this.pageXOffset = document.body.scrollLeft;
        this.innerHeight = document.body.clientHeight;
        this.innerWidth = document.body.clientWidth;
      }
      return this;
    },
    
	init: function(el) {  
      $(el).css({visibility: "visible"});
      $(el).css("width",($(".enlarge_large_image").width() + 60));
      $(el).css("left",Math.round(viewport.o().innerWidth/2) + viewport.o().pageXOffset - Math.round($(el).width()/2));
      $(el).css("top",Math.round(viewport.o().innerHeight/2) + viewport.o().pageYOffset - Math.round($(el).height()/2));
      $(el).hide().fadeIn("medium",function(){$('#enlarge_loading').remove();});
    }
  };

  $("a[rel='enlarge']").click(function(){

    $("body").append("<div id='enlarge_loading'></div>");
   
    $(".enlarge_window").remove();

    // Checks if the image has a title, otherwise gets text in the HTML element (since it'll probably be an anchor
    if($(this).find("img").attr("rel")) { var srtTitle = $(this).find("img").attr("rel") } else { var srtTitle = $(this).text() }
                  
    var strEnlarge = "<div class='enlarge_window'><div>";
    strEnlarge += "<a href='#' class='enlarge_close'>[x] Close</a>";
    strEnlarge += "<img src='" + $(this).attr("href") + "' class='enlarge_large_image' />";
    strEnlarge += "<p>" + srtTitle + "</p>";
    strEnlarge += "</div></div>";

    $("body").append(strEnlarge);
    
	//Check if image is loaded
    $(".enlarge_large_image").load( function() { viewport.init(".enlarge_window"); });
      
    $("#enlarge_overlay,.enlarge_window").click(function(){
      $("#enlarge_overlay,.enlarge_window").fadeOut("medium",function(){$('#enlarge_overlay,#enlarge_loading,#enlarge_hideSelect,.enlarge_window').remove();});

      if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
        $("body","html").css({height: "auto", width: "auto"});
        $("html").css("overflow","");
      }

      return false;
    });
    return false;
  });
});
  
/*
******* 2nd Enlarge Image Positioning*******
*/ 
function positionDiv() {

    var kids = $("#middle-content-article p").size();
    var mf = Math.floor(kids / 2);

    $("#ie2").prependTo('#middle-content-article p:eq(' + mf + ')');
}

/*
******* Email - Print*******
*/  
  
function mailpage()
{  
mail_str = "mailto:?subject= " + document.title;  
mail_str += "&body= I recommend this Embassy's webpage -- " + document.title;  
mail_str += ". You should check this out at, " + location.href;   location.href = mail_str;
}