﻿

//This function is used to print out the page on all inner pages
function Clickheretoprint()
{ 
  // this was added because internet explorer does not allow a document.write when there is a document.domain
  if (navigator.appName=="Microsoft Internet Explorer")
  {
     window.print();
  }
  else
  {  
     var disp_setting="toolbar=no,location=no,directories=no,menubar=yes,resizable=yes,"; 
         disp_setting+="scrollbars=yes,width=800, height=700, left=100, top=25"; 
     var content_vlue1 = document.getElementById("print1").innerHTML;
     var content_vlue2 = document.getElementById("print2").innerHTML;
     var content_vlue3 = document.getElementById("print3").innerHTML; 

     var docprint=window.open("","",disp_setting); 
       docprint.document.open(); 
       docprint.document.write('<html><head><title>Choose Maryland Printer Friendly</title>'); 
       docprint.document.write('</head><body onLoad="self.print()">');          
       docprint.document.write(content_vlue1);
       docprint.document.write('<BR><BR>');
       docprint.document.write(content_vlue2);
       docprint.document.write(content_vlue3);
       docprint.document.write('</center></body></html>'); 
       docprint.document.close(); 
       docprint.focus(); 
  }
}


//  This function is used for the gray call to action buttons
function showModal(divID) 
{
    window.scrollTo(0,0);
    document.body.style.overflow="hidden";
        
     addTransparencyToAllFlashes();

     
//    window.onscroll = function() 
//	{ 
//	  document.getElementById(divID).style.top = document.body.scrollTop; 
//	};
    document.getElementById(divID).style.display = "block";
    document.getElementById(divID).style.top = document.body.scrollTop;
    


}

// this function is used when the user clicks the x or submit for the call to action buttons
function hideModal(divID) 
{
    document.body.style.overflow="auto";
	document.getElementById(divID).style.display = "none";
//	document.getElementById("signupframe").src = "/_layouts/usersManagement/eNewsletterSignUp.aspx";
}

// for google search
function GoogleSearch()
{
   var searchText = document.getElementById("q");
   if (searchText == null ) return false;
   var link = "http://search.maryland.gov/search?" + "q=" + searchText.value + "&site=Business_and_Economic_Development_ChooseMaryland" 
            + "&client=search_md_1"  + "&output=xml_no_dtd"  + "&proxystylesheet=search_md_1";
   window.open(link);
   return false;
}


     
// this is for the left navigation     

var temp, temp2, cookieArray, cookieArray2, cookieCount;
function initiate()
{

  cookieCount=0;
  if(document.cookie){
    cookieArray= new Array(); 
    cookieArray= document.cookie.split(";");
    cookieArray2=new Array();
    for(i in cookieArray)
    {
      cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,"");
    }
  }
  cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array();

  temp=document.getElementById("containerul");
  for(var o=0;o<temp.getElementsByTagName("li").length;o++)
  {
    if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0)
    {
      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(/publishingImages/tier3/minus.gif)":"url(/publishingImages/tier3/plus.gif)"):"url(/publishingImages/tier3/plus.gif)";
      temp2.onclick=function()
      {
        showhidemenu(this.parentNode);
        writeCookie();
      }
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)
      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";
      if(cookieArray[cookieCount]=="true")
      {
        showhidemenu(temp.getElementsByTagName("li")[o]);
      }
      cookieCount++;
    }
    else
    {
      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = "url(/publishingImages/tier3/page.gif)";
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);
    }
  }
}

function showhidemenu(el)
{
  el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";
  el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(/publishingImages/tier3/minus.gif)":"url(/publishingImages/tier3/plus.gif)";
}

function writeCookie()
{
  cookieArray=new Array()
  for(var q=0;q<temp.getElementsByTagName("li").length;q++)
  {
    if(temp.getElementsByTagName("li")[q].childNodes.length>0)
    {
      if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){
        cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");
      }
    }
  }
  document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString();
}
// end of left navigation

     
// Switches the default mode of the HTML editing field from to inner to pop up 
// Copyright Vincent Rothwell 2007 http://blog.thekid.me.uk

var _tk_old_RTE2_LaunchEditor = null;

function _tk_RTE2_LaunchEditor(parameterArray, clientId, displayPanelClientId, emptyPanelClientId, hiddenInputFieldId, webUrl, popupMode, sourceMode, fromInlineMode)
{
	var bPopupMode = "False";
	if (popupMode != "True") bPopupMode = "True";

	_tk_old_RTE2_LaunchEditor(parameterArray, clientId, displayPanelClientId, emptyPanelClientId, hiddenInputFieldId, webUrl, bPopupMode, sourceMode, fromInlineMode);
}

function _tk_switchRTE2_PopupMode()
{
	//RTE2_PopupMode(strBaseElementID)
    if (typeof(RTE2_LaunchEditor) != "undefined")
    {
    	_tk_old_RTE2_LaunchEditor = RTE2_LaunchEditor;
        RTE2_LaunchEditor = _tk_RTE2_LaunchEditor;
    }
}

setTimeout("_tk_switchRTE2_PopupMode()", 100);

// till here

// This code was added because the flash would bleed through or at least still work over the box.  Moved to bottom to make less messy
function addTransparencyToAllFlashes()
{
    //this piece is because Firefox shows flash on home page on top
    for (var ems = document.embeds, i = 0, em; em = ems[i]; i++) 
    {
	  em.setAttribute('wmode', 'transparent');
	  var nx = em.nextSibling, pn = em.parentNode;
	  pn.removeChild(em);
	  pn.insertBefore(em, nx);
	}
    

    // loop through every object tag on the site for internet explorer
    var objects = document.getElementsByTagName('object');
    for(i=0; i<objects.length; i++) {
        object = objects[i];
        var new_object;
        // object is an IE specific tag so we can use outerHTML here
        if(object.outerHTML) {
            var html = object.outerHTML;
            // replace an existing wmode parameter
            if(html.match(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")[a-zA-Z]+('|")\s*\/?\>/i))
                new_object = html.replace(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")window('|")\s*\/?\>/i,"<param name='wmode' value='transparent' />");
            // add a new wmode parameter
            else 
                new_object = html.replace(/<\/object\>/i,"<param name='wmode' value='transparent' />\n</object>");
            // replace the old embed object with the fixed versiony
            object.insertAdjacentHTML('beforeBegin',new_object);
            object.parentNode.removeChild(object);
        }
    }

}



     //preload calendar images
     var calalldown = new Image();
     calalldown.src = "/services/PublishingImages/CalDown.jpg";
     var calexdown = new Image();
     calexdown.src = "/services/PublishingImages/CaladDown.jpg";

// Header e-mail
 		function sendMail(elem, fromEmail) 
 		{
 		  if (elem != null)
 		  {
 		     var mailElement = document.getElementById(elem);
 		     if (mailElement != null)
 		     {
 		        if (fromEmail == null)
 		        {
 		           mailElement.setAttribute("href","mailto:?subject=" + document.title + "&body=" + location.href); 		   
 		        }
 		        else
 		        { 
 		            mailElement.setAttribute("href","mailto:" + fromEmail + "?subject=" + document.title + "&body=" + location.href); 		   
 		        }
 		     }
 		  }
 		} 	


