if (top != self) { top.location = location; }

var Emergo = Class.create();

Emergo.prototype = {
	initialize: function() {
	   this.is = 'ermergo'   
	},
	
	higlightError: function(domid) {
   	new Effect.Highlight(domid,{startcolor:'#bd0113'})
   },
   
   scrollTo: function(domid) {
	   new Effect.ScrollTo(domid,{beforeStart: function() { new Effect.Highlight(domid,{duration: 3}) } })
	   return false
	},
	
	showAndScroll: function(domid) {
	   if ( $(domid) ) {
	      $(domid).show();
	      this.scrollTo(domid);
	   }
	},
	

	setupInputs: function() {
	   if ( Prototype.Browser.IE ) {
         var inputs = document.getElementsByTagName("INPUT")
         for ( var i=0; i<inputs.length; i++ ) {
            if ( inputs[i].type == 'text' || inputs[i].type == 'password' ) {
               $(inputs[i]).addClassName("text")
            }

            if ( inputs[i].type == 'button' ) {
               $(inputs[i]).addClassName("button")      
            }
   	   } 
   	}
	},
	
	openInfo: function(id,e) {
	   if ( $(id) ) {
   	   var pointer = Event.pointer(e)
   	   Element.setStyle(id,{left: (10+pointer.x) + 'px', top: (pointer.y+10) + 'px'})
   	   $(id).show()
	   } else {
	      alert('no info')
	   }
	},
	
	closeInfo: function(id) {
	   if ( $(id) ) {
	      $(id).hide();
	   }
	},
	
	moveInfo: function(id,e) {
	   if ( $(id) ) {
	      var pointer = Event.pointer(e)
         new Effect.Move(id, { x: (10+pointer.x), y: (pointer.y+10), mode: 'absolute' });
	   }
	   
	},
	
	roundCorner: function(id,size) {
      var shadow = '10px 10px 5px #888'
      $(id).setStyle({
         'borderRadius': size, 'boxShadow': shadow,
         'MozBorderRadius': size, 'MozBoxShadow': shadow,
         'WebkitBorderRadius': size, 'WebkitBoxShadow': shadow 
      
      })
	},
	
	robos: function(class_name) {
	   if ( !class_name ) {
	      class_name = 'robo'
	   }
      if ( Prototype.Browser.IE ) {
         DD_roundies.addRule('.'+class_name, 10, true); 
      } else {
   	   var myrobos = document.getElementsByClassName(class_name)
         for ( var i=0; i<myrobos.length; i++ ) {
            this.roundCorner(myrobos[i],'10px')
         }
      }
	},
	
	setupErrorForm: function(id) {
	   $(id).onclick = function() { new Effect.DropOut(this); }
	   $(id).setOpacity('0.9');
	   var efields = document.getElementsByClassName("fieldWithErrors");
	   for ( var i=0; i<efields.length; i++ ) {
   	   efields[i].firstChild.onclick = function() {
   	      this.parentNode.removeClassName('fieldWithErrors')
   	   }	      
	   }
	}
}

var emergo = new Emergo();