


function Hook_Image_Slideshow(imgarray, divid, fadeIn, fadeOut, delay, width, height)
{
	// Require
	dojo.require("dojo._base.fx");
    //dojo.require("dojox.image");
    
    // Preload
    //dojox.image.preload([imgarray]);
    
	fadeIn = parseInt(fadeIn);
	fadeOut = parseInt(fadeOut);
	delay = parseInt(delay);
	
	// The div
	var divNode = dojo.byId(divid);
	divNode.innerHTML = "";
	
	// The img
	var imgNode = document.createElement("img");
	var imgId = "hook_slideshow_img";
	imgNode.id = imgId;
	imgNode.style.opacity = "0";
	imgNode.src = imgarray[0];
	
	// Width and height
	if(height > 0)
		imgNode.height = height;
	if(width > 0)
		imgNode.width = width;
	
	divNode.appendChild(imgNode);
	
	// Fadeing
	var In = dojo.fadeIn({node: imgId, duration:fadeIn });
	dojo.connect(In,"onEnd",function(){ 
		setTimeout(function(){ Hook_Image_Slideshow_Create(imgarray, imgId, 0, fadeIn, fadeOut, delay) }, delay);
	});
	In.play();
}

function Hook_Image_Slideshow_Create(imgarray, imgId, next, fadeIn, fadeOut, delay)
{
	// Fadeing out
	var Out = dojo.fadeOut({node: imgId, duration:fadeOut });
	dojo.connect(Out,"onEnd",function(){
		
		// Finding the next
		var amount = imgarray.length;
		next++;
		next = (next >= amount) ? 0 : next;
		
		// Changing the image
		dojo.byId(imgId).src = imgarray[next];
		
		// Fading In again
		var In = dojo.fadeIn({node: imgId, duration:fadeIn });
		dojo.connect(In,"onEnd",function(){ 
			setTimeout(function(){ Hook_Image_Slideshow_Create(imgarray, imgId, next, fadeIn, fadeOut, delay) }, delay);
		});
		In.play();
	});
	Out.play();
}

function removeinput(e,o){
		if(o.firstTime){return}
		o.firstTime=true
		o.value=""
}


function insertsubscriber(){
	var email = dojo.byId('email').value;
	var divid = "newsletter";
	var url = '/api/get?type=insertsubscriber&email='+email;
	document.body.style.cursor = "wait";
	if (divid != "") {
		dojo.byId(divid).innerHTML = '<img src="/app/design/backend/default/skin/img/preload.gif"/>';
	}
	dojo
			.xhrGet( {
				url :url,
				load : function(response, ioArgs) {

					document.body.style.cursor = "default";
					if (divid != "") {
						dojo.byId(divid).innerHTML = response;
					}

					return response;
				},
				error : function(response, ioArgs) {
					document.body.style.cursor = "default";
					if (divid != "")
						if (response == "Error: Tried to register widget with id==edit but that id is already registered") {
							alert("Login session timedout");
							window.location = "/admin/login/login";
						} else
							dojo.byId(divid).innerHTML = "An error occurred, with response: "
									+ response;
					return response;
				},
				handleAs :"text"
			});
	
}