/* Extension to Element */

Object.extend(Element, {
	setLeft: function(element, t){
		element = $(element);
		element.style.left = t + "px";
	},
	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	}
});


function genEmail(u,d,s,how,p,desc,cls){
	//user
	//domain
	//suffix
	//how - how to generate the email: asLink, withDesc
	//parameters (i.e. ?subject=I loved your website!)
	//description of the link (what goes between the <a></a> tags
	//class - style sheet
	var parameters = (p ? p : "");
	if(parameters!="" && parameters.substring(0,1) != "?"){parameters = "?" + parameters;}
	var e = u + "@" + d + "." + s;
	var txt;
	if(how == "asLink"){
		document.write("<a href='mailto:" + e + parameters + "'" + (cls ? " class=\"" + cls + "\"" : "") + ">" + e + "</a>");
	} else if(how == "withDesc"){
		document.write("<a href='mailto:" + e + parameters + "'" + (cls ? " class=\"" + cls + "\"" : "") + ">" + desc + "</a>");
	} else {
		document.write(e);
	}
}

function checkURL(u){
	if(u.value=="") return;
	if(u.value.indexOf("http://") == -1 && u.value.indexOf("https://") == -1) u.value = "http://" + u.value;
}

function getObj(oName){
  //now using prototype... 
  return $(oName);
}

function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}

//helper functions from http://www.crockford.com/javascript/remedial.html
function isAlien(a) {return isObject(a) && typeof a.constructor != 'function';}
function isArray(a) {return isObject(a) && a.constructor == Array;}
function isBoolean(a) {return typeof a == 'boolean';}
function isFunction(a) {return typeof a == 'function';}
function isNull(a) {return typeof a == 'object' && !a;}
function isNumber(a) {return typeof a == 'number' && isFinite(a);}
function isObject(a) {return (a && typeof a == 'object') || isFunction(a);}
function isString(a) {return typeof a == 'string';}
function isUndefined(a) {return typeof a == 'undefined';} 
function isEmpty(o) {
    var i, v;
    if (isObject(o)) {for (i in o) {v = o[i];if (isUndefined(v) && isFunction(v)) {return false;}}}
    return true;
}
Array.prototype.inArray = function ( obj ) {
	var len = this.length;
	for ( var x = 0 ; x <= len ; x++ ) {
		if ( this[x] == obj ) return true;
	}
	return false;
}



function findSelectValueIndex(selName,val){
	var obj = getObj(selName);
	if(obj == null) return '';
	for(var i=0;i<obj.length;i++)
		if(obj[i].value == val) return i;
	return '';
}

function setSelectIndex(selName,val){
	var obj = getObj(selName);
	if(obj == null) return;
	var idx = findSelectValueIndex(selName,val);
	if(idx == '') return;
	obj.selectedIndex = idx;
}

/* Prototype -- Script.aculo.us  Functions */

function setLoadingOverlay(e,text){
	// Loading overlay class used for overlaying object for feedback to user
  //   that something is currently happening

	//  assumptions: object is positioned relatively
  //							 Prototype & Scriptaculous are loaded
  //							 Location of loading image
  
  var element = $(e);
  
  if(!element) return; 
  
  if($(element.id + '_loadingOverlay')){
  	//overlay already exists - make it visible & return
    $(element.id + '_loadingOverlay').style.display = ''
    new Effect.Appear(element.id + '_loadingOverlay',{to: .7}); 
    return;
  }
  
	var objLoadingOverlay = document.createElement("div");
	objLoadingOverlay.setAttribute('id',element.id + '_loadingOverlay');
  objLoadingOverlay.className = 'loadingOverlay';
  var objLoadingDiv = document.createElement("div");
  objLoadingDiv.innerHTML = text == "" ? "loading" : text;

  var objLoadingImage = document.createElement("img");
  objLoadingImage.setAttribute('src', "/images/loading.gif");

	objLoadingDiv.appendChild(objLoadingImage);
  objLoadingOverlay.appendChild(objLoadingDiv);
  
	element.appendChild(objLoadingOverlay);

  $(element.id + '_loadingOverlay').style.width = element.offsetWidth;
  $(element.id + '_loadingOverlay').style.height = element.offsetHeight;
  
}

function clearLoadingOverlay(e){
	// Loading overlay class used for overlaying object for feedback to user
  //   that something is currently happening

	//  assumptions: Overlay is loaded
  //							 Prototype & Scriptaculous are loaded
  
  var element = $(e); 
  if(!element) return; 

  if($(element.id + '_loadingOverlay')){
  	//overlay already exists - make it visible & return
    if($(element.id + '_loadingOverlay').style.display == 'none') return;
	  new Effect.Fade(element.id + '_loadingOverlay'); 
  } 
  
}

function getXMLResponseDataNode(response){
	if(response){return response.responseXML.getElementsByTagName("response")[0];}
  return false;
}

function xmlToArray(xml){
	//Constants
  var ELEMENT_NODE = 1;
  var TEXT_NODE = 3;
	var arr = new Array();
	for(var i=0; i < xml.childNodes.length; i++){
  	if(xml.childNodes[i].nodeType == ELEMENT_NODE) arr.push(xmlToObject(xml.childNodes[i]));
  }
  return arr;
}

function xmlToObject(xml){
	//Constants
  var ELEMENT_NODE = 1;
  var TEXT_NODE = 3;
	
  if(xml.nodeType == ELEMENT_NODE){
  	if(xml.attributes){
	  	var obj = new Object();
    	for(var i = 0; i < xml.attributes.length; i++) obj[xml.attributes[i].name] = xml.attributes[i].value;
      return obj; 
    }
  }
}

function getXMLResponseSingleValue(response){
	if(typeof(response) == "undefined") return false;
  var arr = xmlToArray(getXMLResponseDataNode(response));
  return arr[0].value; 
}

function emptySelectBox(element){
	var e = $(element);
  if(e.options) {while(e.options.length > 0){e.options[0] = null;}}
}

function addSelectOption(element,text,value){
	if(element == "") return;
  if($(element) && $(element).options) $(element).options[$(element).options.length] = new Option(text,value);
}

function loadSelectBoxWithXMLArrayObject(element,arr){
  var e = $(element);
 
  if(arr.length > 0){
		emptySelectBox(e);
    addSelectOption(e,'','');
	  for(var i = 0; i < arr.length; i++){addSelectOption(e,arr[i].name,arr[i].id);}
  } 

}

function loadCheckboxArrayWithXMLArrayObject(element,inputName,arr){
  if(!isArray(arr) || inputName == "" || element == "" || typeof($(element)) == 'undefined' || arr.length < 1) return;

  var e = $(element);
  e.innerHTML = "";
    
	var objCheckboxDiv;
	var objCheckboxLabel;  
  var objCheckbox;

  var i = 0;
	arr.each(
  	function(element){
      i++;
    	objCheckboxDiv = document.createElement("div");
      
      //objCheckboxLabel = document.createElement("label");
      //objCheckboxLabel.setAttribute('for','checkbox_' + inputName + "_" + ++i);
      objCheckboxLabel = document.createElement("span");
      objCheckboxLabel.innerHTML = element.name;
      
    	objCheckbox = document.createElement("input");
      objCheckbox.setAttribute('type','checkbox');
      objCheckbox.setAttribute('class','checkbox');
      objCheckbox.className = "checkbox";
      objCheckbox.setAttribute('style','border: none;');
      objCheckbox.setAttribute('value',element.id);
      objCheckbox.setAttribute('id','checkbox_' + inputName + "_" + i);
      objCheckbox.setAttribute('name',inputName + '[]');

      objCheckboxDiv.appendChild(objCheckbox);
      objCheckboxDiv.appendChild(objCheckboxLabel);
      e.appendChild(objCheckboxDiv);
			
      //cause setting the atribute didn't work for IE
      //if(element.checked == 1) objCheckbox.setAttribute('checked',true);
      if(element.checked == 1) $('checkbox_' + inputName + "_" + i).checked = true;

    }
  );

}

function getCheckboxArrayQueryString(inputName){
	if(inputName == "") return "";
  
  var str = "";
  var i = 0;
  while($('checkbox_' + inputName + "_" + ++i)){
  	if($('checkbox_' + inputName + "_" + i).checked == true){
    	str += (str == "" ? "" : "&") + inputName + "[]=" + $('checkbox_' + inputName + "_" + i).value;
    } 
  }
  return str;
}

function appendAnchor(element,href,text){
	if(!$(element)) return;
	objAnchor = document.createElement("a");
  objAnchor.setAttribute('href',href);
  objAnchor.innerHTML = text;
  $(element).appendChild(objAnchor);
}

function hideElements(arr,eff, duration){
	var fade;
	if(!isArray(arr) && arr == "") return;
  if(!isArray(arr)) arr = new Array(arr);
  if(typeof(eff) != 'undefined' && eff != "") {
  	if(typeof(duration) == 'undefined' || duration == "") duration = .5;
	  if(eff == 'Fade'){arr.each(function(a){if($(a) && $(a).style.display != 'none') new Effect.Fade($(a), {duration: duration});});}
	  if(eff == 'Blind'){arr.each(function(a){if($(a) && $(a).style.display != 'none') Effect.BlindUp($(a), {duration: duration});});}
  } else {
	  arr.each(function(a){$(a).style.display = 'none';});
  }
}

function showElements(arr){
	if(!isArray(arr) && arr == "") return;
  if(!isArray(arr)) arr = new Array(arr);
  arr.each(function(a){$(a).style.display = '';});
}

function hideLoadingPane(){$('loadingPane').style.display = 'none';}

function showLoadingPane(){$('loadingPane').style.display = '';}

/* Tabbed Box */

var tabbedBox_curTab = '';

function tabbedBox_switchTab(newTab){
	if(newTab == tabbedBox_curTab) return;
	
  if($('tabbedBox_' + newTab))
  $('tabbedBox_' + newTab).style.display = '';  
  $('tabbedBoxNav_' + newTab).className = 'current';
  
  if(tabbedBox_curTab != "" && $('tabbedBox_' + tabbedBox_curTab)){
    $('tabbedBox_' + tabbedBox_curTab).style.display = 'none';
    $('tabbedBoxNav_' + tabbedBox_curTab).className = '';
	}
  
  tabbedBox_curTab = newTab;
} 

function showHideObj(obj,effect){
	if($(obj) && $(obj).style){
  	if(typeof(effect) != 'undefined' && effect != ""){

    	//slide
      if(effect == 'slide'){
        if($(obj).style.display == ""){
        	Effect.SlideUp(obj);
        } else Effect.SlideDown(obj, {duration: .5});
      }

    	//blind
      if(effect == 'blind'){
        if($(obj).style.display == ""){
        	Effect.BlindUp(obj);
        } else Effect.BlindDown(obj, {duration: .5});
      }

    } else $(obj).style.display = $(obj).style.display == "" ? "none" : "";
  }
}

function onloadGoToHash(loc){
	if(loc == "") return;
  Event.observe(window, 'load', function (){window.location.hash=loc;}, false);
}

function checkAll(field){
  for (i = 0; i < field.length; i++)
	field[i].checked = true;
}

function uncheckAll(field){
  for (i = 0; i < field.length; i++)
	field[i].checked = false;
}

function getWindowSize() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    return {'height': window.innerHeight, 'width': window.innerWidth};
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    return {'height': document.documentElement.clientHeight, 'width': document.documentElement.clientWidth};
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    return {'height': document.body.clientHeight, 'width': document.body.clientWidth};
  }
}

function findPos(obj,topParent) {
	//returns x,y positions of requested obj
  topParent = typeof(topParent) != "undefined" && topParent != "" ? topParent : '';
  obj = $(obj);
  if(!obj) return;
  var curleft = curtop = 0;
	if (obj.offsetParent) {
		while (true) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
      if(!obj.offsetParent || (topParent != "" && obj.offsetParent.id == topParent)) break;
      obj = obj.offsetParent;
		}
	}
  //var browser = new BrowserDetect();	
  //curleft += browser.isIE ? 1 : 0;
	return [curleft,curtop];
}

function findPos_new(obj,topParent) {
  return [findPosX(obj,topParent),findPosY(obj,topParent)];
}

function findPosX(obj,topParent){
  var curleft = 0;
  if(obj.offsetParent){
    while(1){
      curleft += obj.offsetLeft;
      if(!obj.offsetParent || (topParent != "" && obj.offsetParent.id == topParent)) break;
      obj = obj.offsetParent;
    }
  } else if(obj.x) curleft += obj.x;
  return curleft;
}

function findPosY(obj,topParent){
  var curtop = 0;
  if(obj.offsetParent){
    while(1){
      curtop += obj.offsetTop;
      if(!obj.offsetParent || (topParent != "" && obj.offsetParent.id == topParent)) break;
      obj = obj.offsetParent;
    }
  } else if(obj.y) curtop += obj.y;
  return curtop;
}

function setPos(obj,x,y){
  obj = $(obj);
  if(obj == "") return;
  obj.style.left = x + 'px';
  obj.style.top = y + 'px';
}

function getDim(e){
	if($(e)){
    return [Element.getWidth(e), Element.getHeight(e)];
  }
  
}

var currentMouseCoordinates = '';

function setCurrentMouseCoordinates(e){
	arr = [Event.pointerX(e),Event.pointerY(e)];
  currentMouseCoordinates = arr;
}
Event.observe(document,'mousemove',function(e){setCurrentMouseCoordinates(e);},false);


function withinCoordinates(x,y,w,h){
	if(currentMouseCoordinates == "") return false
	mouseX = currentMouseCoordinates[0];
  mouseY = currentMouseCoordinates[1];
  //writeToDebugPanel([x,y,x+w,y+h,currentMouseCoordinates].inspect());
  return mouseX >= x && mouseY >= y && mouseX <= (w + x) && mouseY <= (h + y);  
}

function mouseWithinElement(e){
  if(!$(e)) return;
	xy = findPos(e);
  x = xy[0];
  y = xy[1];
	h = Element.getHeight(e);
	w = Element.getWidth(e);
  return withinCoordinates(x,y,w,h);
}

function appendTextNode(element,text){
	$(element).appendChild(Builder.node('p',text));
}

function writeToDebugPanel(text){
	if(!$('debugPanel') || text == '') return;
	appendTextNode('debugPanel',text);
  $('debugPanel').scrollTop = $('debugPanel').scrollHeight;
}

var currentMoreInfoElement = '';
var currentMoreInfoTrigger = '';
var hideMoreInfoTimeout = '';
function showMoreinfo(trigger,element,topParent){
    var browser = new BrowserDetect();	

  //show a specific more info element
  if(!$(element)) return;
  if(currentMoreInfoElement == element){
    //reset timeout
    if(hideMoreInfoTimeout != '') clearTimeout(hideMoreInfoTimeout); 
    hideMoreInfoTimeout = setTimeout(function(){hideMoreinfo(trigger,element);},500);
    return;
  }
  
  if(currentMoreInfoElement != "" && currentMoreInfoElement != element) hideMoreinfo(currentMoreInfoTrigger,currentMoreInfoElement,true,true);
    
  currentMoreInfoElement = element;
  
  xy = findPos(trigger,topParent);
  //xy = currentMouseCoordinates
  wh = getDim(trigger);
  Element.setLeft(element, xy[0] + wh[0] + 2);
  par = typeof(topParent) == "undefined" || topParent == null || topParent == 'null' ? document.body : topParent;
  Element.setTop(element, xy[1] + 3);
	
  //set triggerPostion
  triggerPostion = $(element).getAttribute('triggerPostion');
  if(triggerPostion == 'below') Element.setTop(element, xy[1] + wh[1]); 
  if(triggerPostion == 'belowMouse'){
    y = 0;
    x = topParent != '' ? findPos(topParent)[0] : 0;
    x += browser.isIE ? 10 : 0;    
    y += browser.isIE ? 10 : 0;    
    Element.setTop(element, (xy[1] + wh[1]) - y);
    Element.setLeft(element, currentMouseCoordinates[0] - x);
  } 

  Element.show(element);
  if((xy[0] + wh[0] + 2 + Element.getWidth(element)) > Element.getWidth(par)){
    Element.setLeft(element, Element.getWidth(par) - Element.getWidth(element) - 10);
    Element.setTop(element, xy[1] + wh[1] + 3);
  }

  //make sure moreInfo object doesn't overlap the parent, and therefore would not be visible
  if(topParent != ''){
   e_wh = [Element.getWidth(element), Element.getHeight(element)];
   e_xy = findPos(element, topParent);
   p_wh = [Element.getWidth(topParent), Element.getHeight(topParent)];
   if(e_wh[0] + e_xy[0] > p_wh[0]) Element.setLeft(element,e_xy[0] - (e_wh[0] + e_xy[0] + (browser.isIE ? 30 : 20) - (p_wh[0])));
   if(e_wh[1] + e_xy[1] > p_wh[1]) Element.setTop(element,e_xy[1] - (e_wh[1] + e_xy[1] + (browser.isIE ? 30 : 20) - (p_wh[1])));
  }
  
  hideMoreInfoTimeout = setTimeout(function(){hideMoreinfo(trigger,element);},500);
}

function hideMoreinfo(trigger,element,hideItNow,override){

  if(override === true || (!mouseWithinElement(trigger) && !mouseWithinElement(element) && hideItNow === true)){
    currentMoreInfoElement = '';
    currentMoreInfoTrigger = ''
    clearTimeout(hideMoreInfoTimeout);
    Element.hide(element);
    return;
  }
  
  //alert([trigger,findPos(trigger), getDim(trigger), currentMouseCoordinates, mouseWithinElement(trigger), element, mouseWithinElement(element)]);
  if(!mouseWithinElement(trigger) && !mouseWithinElement(element) && hideItNow !== true){
    if(hideMoreInfoTimeout != '') clearTimeout(hideMoreInfoTimeout);
    hideMoreInfoTimeout = setTimeout(function(){hideMoreinfo(trigger,element,true);},500);
    return;
  } 

  //Set timeout as moreinfo is still not hidden
  hideMoreInfoTimeout = setTimeout(function(){hideMoreinfo(trigger,element);},500);
  
}

function setMoreinfoTriggers(){
  items = $$('.moreinfo').each(function (element){
    if($(element)){
      trigger = $(element).getAttribute('trigger');
      topParent = $(element).getAttribute('topParent');
      if($(trigger)){
        id = $(element).id;
        if($(trigger).href && $(trigger).href == "") $(trigger).href = "javascript:showMoreinfo('" + trigger + "','" + id + "')";
        Event.observe($(trigger),'mouseover',new Function("showMoreinfo('" + trigger + "','" + id + "','" + topParent + "')"));
        Event.observe($(trigger),'focus',new Function("$('" + trigger + "').blur()"));
      }
    }
  });
   //showMoreinfo('moreinfoTrigger','moreinfoItem')
}
Event.observe(window,'load',setMoreinfoTriggers);


function activateFlashIE(){
	return;
  objects = document.getElementsByTagName("object");
  for (var i = 0; i < objects.length; i++){
	  objects[i].outerHTML = objects[i].outerHTML;
  }
}

