function getWindowHeight() 
 {
   var windowHeight=0;
   var minWindowHeight = 700;
   if (typeof(window.innerHeight)=='number') 
   {
     windowHeight = window.innerHeight;
   }
   else 
   {
     if (document.documentElement&&
         document.documentElement.clientHeight) 
     {
       windowHeight = document.documentElement.clientHeight;
     }
     else 
     {
       if (document.body&&document.body.clientHeight) 
       {
         windowHeight = document.body.clientHeight;
       }
     }
   }
   
   if (windowHeight < minWindowHeight)
     windowHeight = minWindowHeight;
   
   return windowHeight;
}


function bookmark(url,title){
//  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
//  window.external.AddFavorite(url,title);
//  } else if (navigator.appName == "Netscape" || window.sidebar) {
//    window.sidebar.addPanel(title,url,"");  
//  }else {
//    alert("Press CTRL-D (Netscape), Command/CTRL-D (Safari) or CTRL-T (Opera) or to bookmark");
//  }

  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
		window.external.AddFavorite(url,title);
  } else if (window.sidebar) {
    window.sidebar.addPanel(title,url,"");  
  }else {
    alert("Press CTRL+D (Netscape), Apple Key/CTRL+D (Safari) or CTRL+T (Opera) to bookmark");
  }

}
function setHomeMessage()
{
	if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1 && navigator.platform.toLowerCase().indexOf('mac') == -1)
	{	
		alert("To make Anne Geddes your home page, follow these simple steps: \r\n"+
		"\t1. Go to the 'Tools' menu on the standard toolbar above the screen, choose 'Options' \r\n" +
		"\t2. Click on the 'Main' tab \r\n" +
		"\t3. In the area called 'Home Page', click 'Use Current Page' \r\n"+
		"\t4. Click 'OK' and Anne Geddes will be your home page. ")
  }else if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1 && navigator.platform.toLowerCase().indexOf('mac') > -1)
	{	
		alert("To make Anne Geddes your home page, follow these simple steps: \r\n"+
		"1. Go to the 'Firefox' menu on the standard toolbar above the screen, choose 'Preferences...' \r\n" +
		"2. Click on the 'Main' tab \r\n" +
		"3. In the area called 'Home Page', click 'Use Current Page' \r\n"+
		"4. Click 'OK' and Anne Geddes will be your home page. ")
  }
  else if(navigator.userAgent.toLowerCase().indexOf('safari') > -1 )
	{
		alert("To make Anne Geddes your home page, follow these simple steps: \r\n"+
		"1. Go to 'Safari' on the standard toolbar above the screen. Click on 'Safari' to see a pulldown menu. \r\n" +
		"2. Click on 'Preferences'.  \r\n" +
		"3. Choose 'General' from the icons across the top of the popup window  \r\n"+
		"4. Click 'Set to Current Page'. \r\n"+
		"5. Click 'OK' and Anne Geddes will be your home page. ")
	}
	else
	{
    alert("Your browser does not support 'make this my homepage' link. Please add this page manually.");			
	}
   
}



function setHeight() 
{
 if (document.getElementById) 
 {
   var windowHeight=getWindowHeight();
   var divHeaderHeight = document.getElementById("divHeader").offsetHeight;
   var divFooterHeight = document.getElementById("divFooter").offsetHeight;
   var tblTopCornerHeight = document.getElementById("tblTopCorner").offsetHeight;
   var tblBottomCornerHeight = document.getElementById("tblBottomCorner").offsetHeight;
  
   var tblLeftContent = document.getElementById("tblLeftContent");
   var tblRightContent = document.getElementById("tblRightContent");
   var tblCenterContent = document.getElementById("tblCenterContent");

 
   if (windowHeight > 0) 
   {
      var height = windowHeight -  divHeaderHeight - divFooterHeight - tblBottomCornerHeight - tblTopCornerHeight - 20 ;
      
      if ((tblLeftContent != null) 
          &&(tblLeftContent.offsetHeight > height))
        height = tblLeftContent.offsetHeight;
        
      if ((tblRightContent != null) 
          &&(tblRightContent.offsetHeight > height))
        height = tblRightContent.offsetHeight;

      if ((tblCenterContent != null) 
          &&(tblCenterContent.offsetHeight > height))
        height = tblCenterContent.offsetHeight;
      
      if (tblLeftContent != null)
        tblLeftContent.style.height = height + 'px';
      
      if (tblRightContent != null)
        tblRightContent.style.height = height + 'px';
        
      if (tblCenterContent != null)
        tblCenterContent.style.height = height + 'px';
   }
 }
}


//accordion js
function switchcontent(className){
this.className=className
this.collapsePrev=false //Default: Collapse previous content each time
this.enablePersist=false //Default: Disable session only persistence
//Limit type of element to scan for on page for switch contents if 2nd function parameter is defined, for efficiency sake (ie: "div")
this.filter_content_tag=(arguments.length==2)? arguments[1].toLowerCase() : ""
}

switchcontent.prototype.setStatus=function(openHTML, closeHTML){ //PUBLIC: Set open/ closing HTML indicator. Optional
this.statusOpen=openHTML
this.statusClosed=closeHTML
}

switchcontent.prototype.setColor=function(openColor, closeColor){ //PUBLIC: Set open/ closing color of switch header. Optional
this.colorOpen=openColor
this.colorClosed=closeColor
}

switchcontent.prototype.setPersist=function(bool){ //PUBLIC: Enable/ disable persistence. Default is true.
this.enablePersist=bool
}

switchcontent.prototype.collapsePrevious=function(bool){ //PUBLIC: Enable/ disable collapse previous content. Default is false.
this.collapsePrev=bool
}


switchcontent.prototype.sweepToggle=function(setting){ //PUBLIC: Expand/ contract all contents method. (Values: "contract"|"expand")
if (typeof this.headers!="undefined" && this.headers.length>0){ //if there are switch contents defined on the page
for (var i=0; i<this.headers.length; i++){
if (setting=="expand")
this.expandcontent(this.headers[i]) //expand each content
else if (setting=="contract")
this.contractcontent(this.headers[i]) //contract each content
}
}
}

// -------------------------------------------------------------------
// PUBLIC: defaultExpanded(indices_of_contents)- Set contents that should be expanded by default when the page loads.
// Note that the persistence feature (if enabled) overrides this setting.
// Pass in the position of the contents relative to the rest of the contents ie: defaultExpanded(0,2,3) would expand the 1st, 3rd, and 4th contents by default
// -------------------------------------------------------------------

switchcontent.prototype.defaultExpanded=function(){
var expandedindices=[] //Array to hold indices (position) of content to be expanded by default
//Loop through function arguments, and store each one within array
//Two test conditions: 1) End of Arguments array, or 2) If "collapsePrev" is enabled, only the first entered index (as only 1 content can be expanded at any time)
for (var i=0; (!this.collapsePrev && i<arguments.length) || (this.collapsePrev && i==0); i++)
expandedindices[expandedindices.length]=arguments[i]
this.expandedindices=expandedindices.join(",") //convert array into a string of the format: "0,2,3" for later parsing by script
}


//PRIVATE: Sets color of switch header.

switchcontent.prototype.togglecolor=function(header, status){
if (typeof this.colorOpen!="undefined")
header.style.color=status
}


//PRIVATE: Sets status indicator HTML of switch header.

switchcontent.prototype.togglestatus=function(header, status){
if (typeof this.statusOpen!="undefined")
header.firstChild.innerHTML=status
}


//PRIVATE: Contracts a content based on its corresponding header entered

switchcontent.prototype.contractcontent=function(header){
var innercontent=document.getElementById(header.id.replace("-title", "")) //Reference content for this header
innercontent.style.display="none"
this.togglestatus(header, this.statusClosed)
this.togglecolor(header, this.colorClosed)
}


//PRIVATE: Expands a content based on its corresponding header entered

switchcontent.prototype.expandcontent=function(header){
var innercontent=document.getElementById(header.id.replace("-title", ""))
innercontent.style.display="block"
this.togglestatus(header, this.statusOpen)
this.togglecolor(header, this.colorOpen)
}

// -------------------------------------------------------------------
// PRIVATE: toggledisplay(header)- Toggles between a content being expanded or contracted
// If "Collapse Previous" is enabled, contracts previous open content before expanding current
// -------------------------------------------------------------------

switchcontent.prototype.toggledisplay=function(header){
var innercontent=document.getElementById(header.id.replace("-title", "")) //Reference content for this header
if (innercontent.style.display=="block")
this.contractcontent(header)
else{
this.expandcontent(header)
if (this.collapsePrev && typeof this.prevHeader!="undefined" && this.prevHeader.id!=header.id) // If "Collapse Previous" is enabled and there's a previous open content
this.contractcontent(this.prevHeader) //Contract that content first
}
if (this.collapsePrev)
this.prevHeader=header //Set current expanded content as the next "Previous Content"
}


// -------------------------------------------------------------------
// PRIVATE: collectElementbyClass()- Searches and stores all switch contents (based on shared class name) and their headers in two arrays
// Each content should carry an unique ID, and for its header, an ID equal to "CONTENTID-TITLE"
// -------------------------------------------------------------------

switchcontent.prototype.collectElementbyClass=function(classname){ //Returns an array containing DIVs with specified classname
var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)", "i") //regular expression to screen for classname within element
this.headers=[], this.innercontents=[]
if (this.filter_content_tag!="") //If user defined limit type of element to scan for to a certain element (ie: "div" only)
var allelements=document.getElementsByTagName(this.filter_content_tag)
else //else, scan all elements on the page!
var allelements=document.all? document.all : document.getElementsByTagName("*")
for (var i=0; i<allelements.length; i++){
if (typeof allelements[i].className=="string" && allelements[i].className.search(classnameRE)!=-1){
if (document.getElementById(allelements[i].id+"-title")!=null){ //if header exists for this inner content
this.headers[this.headers.length]=document.getElementById(allelements[i].id+"-title") //store reference to header intended for this inner content
this.innercontents[this.innercontents.length]=allelements[i] //store reference to this inner content
}
}
}
}


//PRIVATE: init()- Initializes Switch Content function (collapse contents by default unless exception is found)

switchcontent.prototype.init=function(){
var instanceOf=this
this.collectElementbyClass(this.className) //Get all headers and its corresponding content based on shared class name of contents
if (this.headers.length==0)
return //If no headers are present (no contents to switch), just exit
// Get ids of open contents below. Three possible scenerios:
// 1) Persistence is enabled AND corresponding cookie contains a non blank ("") string, indicating this isn't the first page load
// 2) Or, check to see if there are contents that should be enabled by default (even if persistence is enabled and this IS the first page load)
// 3) Or, default to no contents should be expanded on page load ("" value)
var opencontents_ids=(this.enablePersist && switchcontent.getCookie(this.className)!="")? ','+switchcontent.getCookie(this.className)+',' : (this.expandedindices)? ','+this.expandedindices+',' : ""
for (var i=0; i<this.headers.length; i++){ //BEGIN FOR LOOP (1)
if (typeof this.statusOpen!="undefined") //If open/ closing HTML indicator is enabled/ set
this.headers[i].innerHTML='<span class="status"></span>'+this.headers[i].innerHTML //Add a span element to original HTML to store indicator
if (opencontents_ids.indexOf(','+i+',')!=-1){ //(2) if index "i" exists within cookie string or default-enabled string (i=position of the content to expand)
this.expandcontent(this.headers[i]) //Expand each content per stored indices (if ""Collapse Previous" is set, only one content)
if (this.collapsePrev) //If "Collapse Previous" set
this.prevHeader=this.headers[i]  //Indicate the expanded content's corresponding header as the last clicked on header (for logic purpose)
}
else //else if no indices found in stored string
this.contractcontent(this.headers[i]) //Contract each content by default
this.headers[i].onclick=function(){instanceOf.toggledisplay(this)}
}
if (this.enablePersist)
switchcontent.dotask(window, function(){instanceOf.rememberpluscleanup()}, "unload") //Call persistence method onunload
}


// -------------------------------------------------------------------
// PRIVATE: rememberpluscleanup()- Stores the indices of content that are expanded inside session only cookie
// If "Collapse Previous" is enabled, only 1st expanded content index is stored
// -------------------------------------------------------------------

switchcontent.prototype.rememberpluscleanup=function(){ //store index of opened ULs relative to other ULs in Tree into cookie
// Define array to hold ids of open content that should be persisted
// Default to just "none" to account for the case where no contents are open when user leaves the page (and persist that):
var opencontents=new Array("none")
for (var i=0; i<this.innercontents.length; i++){
//If persistence enabled, content in question is expanded, and either "Collapse Previous" is disabled, or if enabled, this is the first expanded content
if (this.enablePersist && this.innercontents[i].style.display=="block" && (!this.collapsePrev || (this.collapsePrev && opencontents.length<2)))
opencontents[opencontents.length]=i //save the index of the opened UL (relative to the entire list of ULs) as an array element
this.headers[i].onclick=null //Cleanup code
}
if (opencontents.length>1) //If there exists open content to be persisted
opencontents.shift() //Boot the "none" value from the array, so all it contains are the ids of the open contents
if (typeof this.statusOpen!="undefined") //Cleanup code
this.statusOpen=this.statusClosed=null //Cleanup code
switchcontent.setCookie(this.className, opencontents.join(",")) //populate cookie with indices of open contents: classname=1,2,3,etc
}


// -------------------------------------------------------------------
// A few utility functions below:
// -------------------------------------------------------------------


switchcontent.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
}

switchcontent.getCookie=function(Name){ 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

switchcontent.setCookie=function(name, value){
document.cookie = name+"="+value
}


function changeBorder(event, imageId){
	if(document.getElementById)
	{
		var table=document.getElementById(imageId);
		if(event!="out"){
			//table.setAttribute("borderColor","dfc7a8");
			table.style.border="2px solid #ff9933";
		}else{
			table.style.border="2px solid #FFFFFF";
			//table.setAttribute("borderColor","white");
		}
	}
	table=null;
}

function changeCounter(tItem, textCounter)
{
if (document.getElementById(tItem) == null 
    || document.getElementById(textCounter) == null)
    return;
    
var intTextCount;
intTextCount=255-document.getElementById(tItem).value.length;
if(intTextCount<=-1)
	{document.getElementById(tItem).value=document.getElementById(tItem).value.slice(0,255)}
	else
	{document.getElementById(textCounter).value=intTextCount;}
}

function changeCounterwithNumber(tItem, textCounter, number)
{
if (document.getElementById(tItem) == null 
    || document.getElementById(textCounter) == null)
    return;
    
var intTextCount;
intTextCount=number-document.getElementById(tItem).value.length;
if(intTextCount<=-1)
	{document.getElementById(tItem).value=document.getElementById(tItem).value.slice(0,number)}
	else
	{document.getElementById(textCounter).value=intTextCount;}
}

function MaxTextLength(tItem, number)
{
if (document.getElementById(tItem) == null)
    return;
    
var intTextCount;
intTextCount=number-document.getElementById(tItem).value.length;
if(intTextCount<=-1)
	{document.getElementById(tItem).value=document.getElementById(tItem).value.slice(0,number)}
}


function trim(inputString) 
{
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} 

function isValidEmail(str) 
{
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false;
		 }

 		 return true;				
  }

function ShowHideControl(controlID, bShow)
{
  var control = document.getElementById(controlID);
  
  if (control != null)
  {
    if (bShow)
    {
      control.style["display"] = '';
    }
    else
    {
      control.style["display"] = 'none';
    }
  }
}

function CheckTextFieldRequired(txtRequiredField, txtErrorMsg)
{
  if (CheckTextFieldEmpty(txtRequiredField))
  {
    ShowHideControl(txtErrorMsg, true);
    return false;
  }
  else
  {
    return true;
  }
}

function CheckDropdownRequired(ddlRequiredField, txtErrorMsg)
{
  var ddlDropDown = document.getElementById(ddlRequiredField);
  if (ddlDropDown.selectedIndex <= 0)
  {
    ShowHideControl(txtErrorMsg, true);
    return false;
  }
  else
  {
    return true;
  }
}

function CheckTextFieldEmpty(txtField)
{
  var txtMessage = document.getElementById(txtField);

  if (trim(txtMessage.value) == '')
  {
    return true;
  }
  else
  {
    return false;
  }
}

function CheckTextFieldEmailFormat(txtRequiredField, txtErrorMsg)
{
  var txtAlbumName = document.getElementById(txtRequiredField);
  
  if (!isValidEmail(txtAlbumName.value))
  {
    ShowHideControl(txtErrorMsg, true);
    return false;
  }
  else
  {
    return true;
  }
}

function SetTextBoxText(txtBoxClientID, value)
{
  var ctrlTextBox = document.getElementById(txtBoxClientID);
  ctrlTextBox.value = value;
}

// Flash Player Version Detection - Rev 1.6
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

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 = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    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_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 "id":
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      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;
}





function Hover__AspNetMenu(element)
{
//    AddClassUpward__CssFriendlyAdapters(element.firstChild /* gets the inner SPAN or A */, topmostClass, hoverClass);
    AddClass__CssFriendlyAdapters(element, hoverClass);
}

function Unhover__AspNetMenu(element)
{
//    RemoveClassUpward__CssFriendlyAdapters(element.firstChild /* gets the inner SPAN or A */, topmostClass, hoverClass);
    RemoveClass__CssFriendlyAdapters(element, hoverClass);
}

function SetHover__AspNetMenu()
{
    var menus = document.getElementsByTagName("ul");
    for (var i=0; i<menus.length; i++)
    {
        if(menus[i].className == topmostClass)
        {
            var items = menus[i].getElementsByTagName("li");
            for (var k=0; k<items.length; k++)
            {
                items[k].onmouseover = function() { Hover__AspNetMenu(this); }
                items[k].onmouseout = function() { Unhover__AspNetMenu(this); }
            }
        }
    }
}


function CanHaveClass__CssFriendlyAdapters(element)
{
    return ((element != null) && (element.className != null));
}

function HasAnyClass__CssFriendlyAdapters(element)
{
    return (CanHaveClass__CssFriendlyAdapters(element) && (element.className.length > 0));
}

function HasClass__CssFriendlyAdapters(element, specificClass)
{
    return (HasAnyClass__CssFriendlyAdapters(element) && (element.className.indexOf(specificClass) > -1));
}

function AddClass__CssFriendlyAdapters(element, classToAdd)
{
    if (HasAnyClass__CssFriendlyAdapters(element))
    {
        if (!HasClass__CssFriendlyAdapters(element, classToAdd))
        {
            element.className = element.className + " " + classToAdd;
        }
    }
    else if (CanHaveClass__CssFriendlyAdapters(element))
    {
        element.className = classToAdd;
    }
}

function AddClassUpward__CssFriendlyAdapters(startElement, stopParentClass, classToAdd)
{
    var elementOrParent = startElement;
    while ((elementOrParent != null) && (!HasClass__CssFriendlyAdapters(elementOrParent, topmostClass)))
    {
        AddClass__CssFriendlyAdapters(elementOrParent, classToAdd);
        elementOrParent = elementOrParent.parentNode;
    }    
}

function SwapClass__CssFriendlyAdapters(element, oldClass, newClass)
{
    if (HasAnyClass__CssFriendlyAdapters(element))
    {
        element.className = element.className.replace(new RegExp(oldClass, "gi"), newClass);
    }
}

function SwapOrAddClass__CssFriendlyAdapters(element, oldClass, newClass)
{
    if (HasClass__CssFriendlyAdapters(element, oldClass))
    {
        SwapClass__CssFriendlyAdapters(element, oldClass, newClass);
    }
    else
    {
        AddClass__CssFriendlyAdapters(element, newClass);
    }
}

function RemoveClass__CssFriendlyAdapters(element, classToRemove)
{
    SwapClass__CssFriendlyAdapters(element, classToRemove, "");
}

function RemoveClassUpward__CssFriendlyAdapters(startElement, stopParentClass, classToRemove)
{
    var elementOrParent = startElement;
    while ((elementOrParent != null) && (!HasClass__CssFriendlyAdapters(elementOrParent, topmostClass)))
    {
        RemoveClass__CssFriendlyAdapters(elementOrParent, classToRemove);
        elementOrParent = elementOrParent.parentNode;
    }    
}


function openWin(URL, options) 
{
  if(options=="" | options==null)
  {
  options="width=450,height=370,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes"
  };
  if(window.location.href.indexOf("74.125.19.147") > -1 || window.location.href.indexOf("translate.google.com") > -1 )
  {
  var strQueryString = window.location.href.split("?");
  var aQueryString = strQueryString[1].split("&");

  Popup = window.open(strQueryString[0] + "?" + aQueryString[0] + "&" + aQueryString[1] + "&" + "u=http://www.annegeddes.com" + URL,'Image',options);Popup.focus();
  }
  else
  {
  Popup = window.open(URL,'Image',options);Popup.focus();
  }
} 
 
function clearDefault(el) {
	if (el.defaultValue==el.value)
		el.value = ""
}


