document.write('<script type="text/javascript" src="/foresee/foresee-trigger.js"></script>');
document.write('<script type="text/javascript" src="/_res/javascript/email_page.js"></script>');

var GAcode;
SetGoogleAnalytics();






$(function() {

  $("ul.sf-menu").superfish({
        animation: {height:'show'}, // slide-down effect without fade-in
        delay:     0              
     });
     
     $('#searchText').focus(function() { 
      if($(this).val()=='Search this Site'){  
        $(this).val('');
      }
 
      }); 

     $('#searchText').blur(function() { 
 
        if($(this).val()==''){
            $(this).val('Search this Site');
        }
 
      }); 


	$("#printLink a").click(function(event){
		window.print();
   	});
   	
   	
    $(".GoogleTrack").click(function(event){
		GoogleTrack(this.id)
   	});

   
    $("ul.sf-menu .selected").parents().eq(2).children("a").addClass("subSelected");
    
    $("#ContentBody a[href|=#top]").parent().addClass("toplink");
    
    $("#ContentBody a[href|=#top]").attr('href', '#page');
    
    $("#ContentBody a[name^='#']").each(
        function() {
		    var name = $(this).attr("name");
		    name = name.replace("#", "")
		    $(this).attr('name', name);
		    $(this).attr('id', name);
	    }
    )
    
    
    
	/*------Arrow Steps--------*/	
	
//	$(".steps li").prepend("<span class='arrowbg'><span class='steptxt'>STEP</span><span class='stepnum'>10</span></span>");
	
		 $(".steps li").each(function(x){
            x = x+1;
			if(x<10){
                $(this).prepend("<span class='arrowbg'><span class='steptxt'>STEP</span><span class='stepnum'>"+ x +"</span></span>");
            }else{
                $(this).prepend("<span class='arrowbg'><span class='steptxt'>STEP</span><span class='stepnum_twodigit'>"+ x +"</span></span>");
            }
		});
	
	$(".steps ol").each(function(){
	   $(this).children().last().addClass('lastli');								
	});
	
	/*------Adds icon relative to file's extention--------*/	
$("#PageContent ul.links a").each(
	function() {
		var url = this.href.split(".");
		var ext = url[url.length - 1].toLowerCase().replace("/", "");
				
		$(this).parent().addClass(ext);
	}
)

	/*------News Section /news/news_1735.html--------*/	
	
	$("ul").each(function(){
	   $(this).children().last().addClass('lastli');								
	});
	
	/*------Alpha Blocks for A-Z Index--------*/
	
	$(".section").append("<a class='backtotop' href='#page'>Back to top</a>");
	$('.section').first().find('.backtotop').remove();

	
	/*---listNumbered-------------*/
	
    $(".QA dt").prepend("<span class='questionLabel'>Q:</span>");
    $(".QA dd").prepend("<span class='answerLabel'>a:</span>");
	
   
	$(".listNumbered").each(function(i) {
		 $(this).children("dt").each(function(x){
            x = x+1;
            if(x<10){
                $(this).prepend("<span class='bulletPlacement bulletCircle'>"+ x +".</span>");
            }else{
                $(this).prepend("<span class='bulletPlacement-large bulletCircle'>"+ x +".</span>");
            }
		});
	});
	
	
	$(".listNumbered").each(function(){
	   $(this).children().last().addClass('lastdd');								
	});
    
     /*---listCollapsible and regular Collapsible-------------*/
    
    $(".listCollapsible h3").addClass('listTitle');
    $(".listCollapsible h3").wrap("<div class='listHeader'></div>");
    $(".listCollapsible .listHeader").append("<span class='listBtns'><h3 class='listOpenBtn'>Open All</h3><h3 class='listCloseBtn'>Close All</h3></span>");
    
    $(".listCollapsible .listOpenBtn").click(function(event){
    
		$(this).parents().eq(2).children("dl").children("dd").show();
		$(this).parents().eq(2).children("dl").children("dt").children(".bulletPlacement").addClass('bulletMinus');
		$(this).parents().eq(2).children("dl").children("dt").children(".bulletPlacement").removeClass('bulletPlus');
   	});
    
     $(".listCollapsible .listCloseBtn").click(function(event){
		
		$(this).parents().eq(2).children("dl").children("dd").hide();
		$(this).parents().eq(2).children("dl").children("dt").children(".bulletPlacement").addClass('bulletPlus');
		$(this).parents().eq(2).children("dl").children("dt").children(".bulletPlacement").removeClass('bulletMinus');
   	});
    
    //$(".QA dt").prepend("<span class='questionLabel'>Q:</span>");
    //$(".QA dd").prepend("<span class='answerLabel'>a:</span>");
    
    $(".listCollapsible dt").prepend("<span class='bulletPlacement bulletMinus'></span>");
    
    
    
    $(".listCollapsible dd").hide();
    $(".listCollapsible dt").children(".bulletPlacement").addClass('bulletPlus');
    $(".listCollapsible dt").children(".bulletPlacement").removeClass('bulletMinus');
    
  	
   	 $(".listCollapsible dt").click(function(event){
		    if($(this).next().is(":hidden")){
		        $(this).next().show();
                $(this).children(".bulletPlacement").addClass('bulletMinus');
                $(this).children(".bulletPlacement").removeClass('bulletPlus');
		    }else{
		        $(this).next().hide();
                $(this).children(".bulletPlacement").addClass('bulletPlus');
                $(this).children(".bulletPlacement").removeClass('bulletMinus');
		    }
   	});
	 
   	    
        // even and odd TR to be styled		
		$("#PageContent .DataTable tr:nth-child(even)").addClass("even");
		$("#PageContent .DataTable tr:nth-child(odd)").addClass("odd");	
		
 });


//---Begin Additions to Javascript File---//

//Used for CSI Drop Downs: /travel/travel_1744.html, /travel/cis_pa_tw/cis/cis_1765.html
      function formHandler(form)
      {
        var URL = form.action.options[form.action.selectedIndex].value;
        if (URL != 0) window.location.href = URL;
      }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Used for Congressional Liason Contact Information Page: /congress/contactinformation/contactinformation_4609.html
function filterByConsular(){
  $("#data > tr").show();
  $("#countryList").attr("selectedIndex", 0);
  return filterTable("consular", "consularList");
  
}

function filterByCountry(){
  $("#data > tr").show();
  $("#consularList").attr("selectedIndex", 0);
  return filterTable("country", "countryList");
}

function filterTable(listtype, list_id){
     $("#data").show();
     var selected = $("#" + list_id + " option:selected");
     
     if(selected.val() != ""){
         $("." + listtype).each(function(){
           if(selected.val() == $(this).text()){
             $(this).parent().show();
           } else {
             $(this).parent().hide();
           }
         });
    
     } 
     return false;
}

//Shows everything in the table
function showAll(){
    $("#data").show();
    $("tr").show();
    $("#countryList").attr("selectedIndex", 0);
    $("#consularList").attr("selectedIndex", 0);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Used for Toggle Show-Hide using JQuery: /travel/announcement/crisis/crisis_4828.html
 $().ready(function(){
   $(".icon").css("border", "0px");
   $(".togglable :first-child").click(function(){
    
     var imgicon = $(this).children(".icon").toggle();
          
     $(this).next(".detail_text").slideToggle("fast");
    
   });
   $(".detail_text").hide();
  
   $("#show_all").click(function(){
     $(".togglable :first-child").each(function(){
      $(this).children(".icon_open").show();
      $(this).children(".icon_closed").hide();
       $(this).next(".detail_text").slideDown("fast");
     });
   });
  
   $("#hide_all").click(function(){
     $(".togglable :first-child").each(function(){
       $(this).children(".icon_open").hide();
           $(this).children(".icon_closed").show();
       $(this).next(".detail_text").slideUp("fast");
     });
   });
 });

//Used for Dropdown on: /visa/temp/types/types_4514.html

function form_select()
{
	if(dreport.dreport_select.options[dreport.dreport_select.selectedIndex].value!=0)
	{
	window.location.href = dreport.dreport_select.options[dreport.dreport_select.selectedIndex].value;
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Used for PDF dropdown on US Embassy/Consulate page: /visa/immigrants/info/info_3830.html

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_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
function MM_jumpMenuGo1(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu1(targ,selObj,restore);
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0 
var s = selObj.options[selObj.selectedIndex].value;
window.open(s);
if (restore) selObj.selectedIndex=0; 
} 
function MM_jumpMenu1(targ,selObj,restore){ //v3.0 
var s = selObj.options[selObj.selectedIndex].value;
if(s != 'nothing')
{
window.open(s);
}
else
{
alert('The selected U.S. Embassy/Consulate has no location-specific information.');
}
if (restore) selObj.selectedIndex=0; 
} 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Used for PDF dropdown on Interview Preparation - Medical Examination page: /visa/immigrants/info/info_3739.html

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_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
function MM_jumpMenuGo2(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu2(targ,selObj,restore);
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0 
var s = selObj.options[selObj.selectedIndex].value;
window.open(s);
if (restore) selObj.selectedIndex=0; 
} 
function MM_jumpMenu2(targ,selObj,restore){ //v3.0 
var s = selObj.options[selObj.selectedIndex].value;
if(s != 'nothing')
{
window.open(s);
}
else
{
alert('The selected U.S. Embassy/Consulate has no location-specific panel physician list.');
}
if (restore) selObj.selectedIndex=0; 
} 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Used for PDF dropdown on US Embassy/Consulate page: /visa/immigrants/info/info_3742.html

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_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
function MM_jumpMenuGo3(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu3(targ,selObj,restore);
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0 
var s = selObj.options[selObj.selectedIndex].value;
window.open(s);
if (restore) selObj.selectedIndex=0; 
} 
function MM_jumpMenu3(targ,selObj,restore){ //v3.0 
var s = selObj.options[selObj.selectedIndex].value;
if(s != 'nothing')
{
window.open(s);
}
else
{
alert('The selected U.S. Embassy/Consulate has no location-specific interview guidelines.');
}
if (restore) selObj.selectedIndex=0; 
} 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Displays current date on this page: /passport/processing/processing_1740.html

        function setClock()
	    {
          // initialize accumulative HTML variable to empty string
          var text = ""
          // set standard convention for digit and punctuation images
          // initialize time-related variables with current time settings
          var now = new Date()
          var day_of_week = getDayOfWeek(now.getDay()) ;
          var month = getMonthName(now.getMonth()) ;
          var day = now.getDate();
          var year = now.getFullYear();
            
          text = day_of_week+" "+month+" "+day+", "+year;
          return text
        }
         
        function getMonthName(month)
		{
          // create array to hold name of each month
          var ar = new Array(12)
          ar[0] = "January"
          ar[1] = "February"
          ar[2] = "March"
          ar[3] = "April"
          ar[4] = "May"
          ar[5] = "June"
          ar[6] = "July"
          ar[7] = "August"
          ar[8] = "September"
          ar[9] = "October"
          ar[10] = "November"
          ar[11] = "December"
          // return name of specified month (parameter)
          return ar[month]
        }
        
        function getDayOfWeek(day)
		{
          // create array to hold name of each month
          var ar = new Array(12)
          ar[0] = "Sunday"
          ar[1] = "Monday"
          ar[2] = "Tuesday"
          ar[3] = "Wednesday"
          ar[4] = "Thursday"
          ar[5] = "Friday"
          ar[6] = "Saturday"
          // return name of specified month (parameter)
          return ar[day]
		}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Used for Visa Visitor Exchange Skills List: /visa/temp/types/types_4790.html, /visa/temp/types/types_4793.html?country=2 (PHP page). There are multiple functions inside of tsg_toggle.js that may be referenced elsewhere also. FUNCTION DOES NOT WORK.

function TSG_doToggleDL(x){
    var zDD=document.getElementById('TSG_DL').getElementsByTagName('dd');
    var zDT=document.getElementById('TSG_DL').getElementsByTagName('dt'); 
    zDD[x].className=(zDD[x].className=='hideDD')?'showDD':'hideDD';
    zDT[x].className=(zDT[x].className=='DTplus')?'DTminus':'DTplus'; 
}
function TSG_ToggleDLopen(){//we open all of them
    var zDD=document.getElementById('TSG_DL').getElementsByTagName('dd');
    var zDT=document.getElementById('TSG_DL').getElementsByTagName('dt'); 
    for(var i=0;i<zDT.length;i++){
	    zDD[i].className='showDD';
	    zDT[i].className='DTminus';
    }
	return false;
}
function TSG_ToggleDLclose(){//we close all of them 
    var zDD=document.getElementById('TSG_DL').getElementsByTagName('dd');
    var zDT=document.getElementById('TSG_DL').getElementsByTagName('dt'); 
    for(var i=0;i<zDT.length;i++){
	   zDD[i].className='hideDD';
 	   zDT[i].className='DTplus';
    }
	return false;
}

function TSG_ToggleDL(){
    if (document.getElementById && document.getElementsByTagName){ 
		if(document.getElementById('TSG_DL')!=null){
	    var zDT=document.getElementById('TSG_DL').getElementsByTagName('dt');
	    var zDD=document.getElementById('TSG_DL').getElementsByTagName('dd');
	    var ToggleON = document.getElementById('TSG_ToggleON');
	    var ToggleOFF = document.getElementById('TSG_ToggleOFF'); 
		    if (ToggleON && ToggleOFF){
				ToggleON.onclick = TSG_ToggleDLopen;
				ToggleON.title = "View all";
				ToggleON.href = "#";
			   	ToggleOFF.onclick = TSG_ToggleDLclose; 
 			   	ToggleOFF.title = "Hide all answers";
				ToggleOFF.href = "#";
			}
	    for(var i=0;i<zDT.length;i++){
    		var zContent = zDT[i].innerHTML;
		    var zHref = "<a href='#' onclick=\"TSG_doToggleDL("+i+");return false\" title='Show/hide the answer'>";
		    zDT[i].innerHTML = zHref + zContent + "</a>";
		    zDD[i].className='hideDD';
		    zDT[i].className='DTplus';
		}
	    }
    }
}


function SetGoogleAnalytics(){
    
    /*
    section = window.location.toString().split("/");
    section = section[3];
    
    switch(section)
    {
    case "passport":
        //alert("This is Passports");
        GAcode = "UA-21043299-1";
        break;
        
    case "travel":
        GAcode = "UA-21043299-1";
        break;
        
    case "abduction":
        //alert("This is abduction");
        GAcode = "UA-21043952-1";
        break;
        
    case "visa":
        //alert("This is visa");
        GAcode = "UA-21043486-1";
        break;
        
    default:
        //alert("This is other");
        GAcode = "UA-21044428-1";
    }
    */
    
    GAcode = "UA-21044428-1";
    document.write('<script type="text/javascript" src="/_res/javascript/google_analytics.js"></script>');
    
}

function GoogleTrack(IDin){

    section = window.location.toString().split("/");
    section = section[3];
    
   IDin = IDin.split("_")[0];
   
    //alert(section);
    //alert(IDin);
    
    _gaq.push(['_trackEvent', section, IDin]);
		
		//alert(section);
}




