
var PostForm = {
  toggle: function() {
    var container = $('form_container');
    var form = $$('#form_container form').first();
    if(container.hasClassName('active')) {
      form.visualEffect('blind_up', { duration: 0.25, afterFinish: function(){
        container.removeClassName('active');
      }});
    } else {
      form.visualEffect('blind_down', { duration: 0.5, beforeStart: function(){
        container.addClassName('active');
      }});
    }
  }
};


if( YAHOO.inv === undefined) { 
	YAHOO.namespace("inv.ivm");
}	

YAHOO.inv.ivm.opacity = function(id, opacStart, opacEnd, millisec) {
		    //speed for each frame
		    var speed = Math.round(millisec / 100);
		    var timer = 0;
				
		    //determine the direction for the blending, if start and end are the same nothing happens
		    if(opacStart > opacEnd) {
		        for(i = opacStart; i >= opacEnd; i--) {
		            setTimeout("YAHOO.inv.ivm.changeOpac(" + i + ",'" + id + "')",(timer * speed));
		            timer++;
		        }
		    } else if(opacStart < opacEnd) {
		        for(i = opacStart; i <= opacEnd; i++){
		            setTimeout("YAHOO.inv.ivm.changeOpac(" + i + ",'" + id + "')",(timer * speed));
		            timer++;
		        }
		    }
		    else {
		    	YAHOO.inv.ivm.changeOpac(opacStart,id);
		    }
		};

//change the opacity for different browsers
YAHOO.inv.ivm.changeOpac = function(opacity, id) {

	  YAHOO.util.Dom.setStyle(id, 'opacity', (opacity/100.0));
		return;
		/*
	  var dopacity = YAHOO.util.Dom.getStyle(id, 'opacity'); 
	  //YAHOO.log(id + ":" + dopacity);	
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
    return;
    YAHOO.log(object.filter);
    */
    /*.opaque {
			-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; // first! for ie8
			filter: alpha(opacity=50);					// second!
		}
		*/
};

			
// custom object
YAHOO.inv.ivm.myObj = function(name) {
    this.name = name;
    // define a custom event
    this.event1 = new YAHOO.util.CustomEvent("event1", this);
};

// a custom consumer object that will listen to "event1"
YAHOO.inv.ivm.Consumer = function(name, oObj) {
    this.name = name;
    this.oObj = oObj;
    this.oObj.event1.subscribe(this.onEvent1, this);
};

//var manager;
YAHOO.inv.ivm.overlayArray;
YAHOO.inv.ivm.Consumer.prototype.onEvent1 = function(type, args, me) {
		YAHOO.inv.ivm.overlayArray = args[0].data;
    var i;
    var seed=true;
    for(i=0; i<YAHOO.inv.ivm.overlayArray.length;i++) {
 			if(YAHOO.inv.ivm.overlayArray[i].cfg.getProperty("visible") == true ) {
 				seed=false;
 			}
 		}
 		if( seed == true ) {
 			YAHOO.inv.ivm.overlayArray[0].show();
 			
 		}
 		else {
 			for(i=0; i<YAHOO.inv.ivm.overlayArray.length;i++) {
 				if(YAHOO.inv.ivm.overlayArray[i].cfg.getProperty("visible") == true ) {
 					break;
 				}
 			}
 			YAHOO.inv.ivm.overlayArray[i].hide();
 			i++;
 			i %= YAHOO.inv.ivm.overlayArray.length;
 			YAHOO.inv.ivm.overlayArray[i].show();
 		}

};

// random test data to be used as an event argument
YAHOO.inv.ivm.myData = function(data) {
    this.data = data;		
};

// create an instance of our test object
YAHOO.inv.ivm.t = new YAHOO.inv.ivm.myObj("myobj");

// create the event consumer, passing in the custom 
// object so that it can subscribe to the custom event
YAHOO.inv.ivm.c = new YAHOO.inv.ivm.Consumer("myconsumer", YAHOO.inv.ivm.t);

// create a data object that will be passed to the consumer when the event fires
YAHOO.inv.ivm.d;

YAHOO.inv.ivm.tagOverlay;

// end of flash animation sequence
YAHOO.inv.ivm.end = function() {
							  			
	  		// for ie to hide flash after done(by time not function call) - need a callback for done from swfobject
				/*objects = document.getElementsByTagName('object');
					for(i = 0; i < objects.length; i++) {
					objects[i].style.visibility = 'hidden';
				}	*/								
				$('logoAnimID').hide(); // for ff

				YAHOO.inv.ivm.opacity('made-easy',0,0);
				$('made-easy').hide();

			  YAHOO.inv.ivm.tagOverlay.render();
			  YAHOO.inv.ivm.tagOverlay.show();
			  
			  YAHOO.inv.ivm.opacity('screen-shot',0,0);
			  $('screen-shot').show();
			  YAHOO.inv.ivm.opacity('screen-shot',0,100);
			  
};

YAHOO.inv.ivm.init_overlays = function(){

			var tagsxy = YAHOO.util.Dom.getXY("what-invalueable-offers");
		  var msgxy = YAHOO.util.Dom.getXY("visit-message-space");
		  var visit = new YAHOO.widget.Overlay("visit-our-forum", { 
		  								xy: msgxy,
										  visible:true,
										  zIndex:1000,
										  effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} } );
			visit.render();
								
		  $('screen-shot').hide();
		  var oLay=[]
		  for(var i=0;i<6;i++){
		  	oLay[i] = new YAHOO.widget.Overlay("overlay"+i, { 
		  								xy: tagsxy,
										  visible:false,
										  zIndex:1000,
										  effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} } );
				oLay[i].render();														  
			}

	  	YAHOO.inv.ivm.d = new YAHOO.inv.ivm.myData(oLay);
			YAHOO.inv.ivm.rotate_overlay();
			
			var tlxy = YAHOO.util.Dom.getXY("flash_container");
		  tlxy[1] *= .75;
			YAHOO.inv.ivm.tagOverlay = new YAHOO.widget.Overlay("taglines", {
											xy: tlxy,
										  visible:false,
										  zIndex:1000,
										  effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:1.25} } );

			
			var t=setTimeout(YAHOO.inv.ivm.end,3000);
				
			
		};

YAHOO.inv.ivm.rotate_overlay = function() {
	YAHOO.inv.ivm.t.event1.fire(YAHOO.inv.ivm.d);
	setTimeout( YAHOO.inv.ivm.rotate_overlay, 10000 );
};

