/**
 * Fade-in image slideshow script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
 * This notice MUST stay intact for legal use
 * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
 */
/**
 * ONLY CHANGE WHAT'S BELOW THIS LINE
 *
 *
 * Each link is constructed as follows:
 * mfadeimage[order in which the image should appear (starting from zero)]=["location of image in hrd ftp space", "where it should link to"];
 *
 * or mfadeimages[1]=["2", "3"];
 *
 * where:
 * 1 = order to show images
 * 2 = location of image on server
 * 3 = where the image links to (the web address)
 */
var mfadeimages = new Array(); // do not change this line
mfadeimages[0]=["http://www.restaurantpunto.co.uk/assets/images/punto_pic1.jpg"];
mfadeimages[1]=["http://www.restaurantpunto.co.uk/assets/images/punto_pic2.jpg"];
mfadeimages[2]=["http://www.restaurantpunto.co.uk/assets/images/punto_pic3.jpg"];
mfadeimages[3]=["http://www.restaurantpunto.co.uk/assets/images/punto_pic4.jpg"];
mfadeimages[4]=["http://www.restaurantpunto.co.uk/assets/images/punto_pic5.jpg"];
mfadeimages[4]=["http://www.restaurantpunto.co.uk/assets/images/punto_pic6.jpg"]; 

var mslideshow_width 		= '1010px'; //SET IMAGE WIDTH
var mslideshow_height 		= '260px'; //SET IMAGE HEIGHT
var mpause 					= 6000; //SET PAUSE BETWEEN SLIDE (3000=3 seconds)
var mcurpos 				= 10;
var mdegree 				= 10;
var mcurcanvas 				= "mcanvas0";
var mcurimageindex 			= 0;
var mnextimageindex 		= 1;
var mpreloadedimages 		= new Array();
var filename 				= "";
var mtempobj;

/**
 * Check what browser we're using
 */
var mie4 = document.all;
var mdom = document.getElementById;

/**
 * Load our images into another array - not sure why?
 *
 *
 */
for(q = 0; q < mfadeimages.length; q++) {
	mpreloadedimages[q] = new Image();
	mpreloadedimages[q].src = mfadeimages[q][0];
}

// --------------------------------------------------------

/**
 * Returns the current Internet Explorer version
 *
 * @param void
 * @return float
 */
function getInternetExplorerVersion() {    

	var rv = -1; // Return value assumes failure. 
	
	if (navigator.appName == 'Microsoft Internet Explorer') {   
	
		var ua = navigator.userAgent;        
		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");        
		if (re.exec(ua) != null)            
		rv = parseFloat(RegExp.$1);    
		
	}    
	
	return rv;
}

// --------------------------------------------------------

/**
 * Fades the images out (and in?)
 *
 * @param void
 * @return void
 */
function mfadepic() {
	
	if (mcurpos<100) {
	
		mcurpos += 10;
		
		if (mtempobj.filters) {

			mtempobj.filters.alpha.opacity = mcurpos;
			
		} else if(mtempobj.style.MozOpacity) {

			mtempobj.style.MozOpacity = mcurpos/101;
		}
			
	} else {
			
		clearInterval(mdropslide);
		mnextcanvas = (mcurcanvas=="mcanvas0") ? "mcanvas0" : "mcanvas1";
		mtempobj = mie4 ? eval("document.all." + mnextcanvas) : document.getElementById(mnextcanvas);
		mtempobj.innerHTML = minsertimage(mnextimageindex);
		mnextimageindex = (mnextimageindex<mfadeimages.length-1) ? mnextimageindex+1 : 0;
		var mtempobj2 = mie4 ? eval("document.all." + mnextcanvas) : document.getElementById(mnextcanvas);
		mtempobj2.style.visibility = "hidden";
						
		setTimeout("mrotateimage()",mpause);
	}
}

// --------------------------------------------------------

/**
 * Loads an image into the page
 *
 * @param int
 * @return string
 */
function minsertimage(i) {

	var fileext = checkfileext(mfadeimages[i][0]);

	if(fileext == "swf") {
		return minsertswf(i);
	}

	var mtempcontainer = '<img src="'+mfadeimages[i][0]+'" border="0" class="item">';

	return mtempcontainer;
}

// --------------------------------------------------------

/**
 * loads a swf object into the page
 *
 * @param int
 * @return string
 */
function minsertswf(i) {

	var mtempcontainer = mfadeimages[i][1] != "" ? '<a href="'+mfadeimages[i][1]+'" target="_blank">' : "";	
	
	mtempcontainer += '<object type="application/x-shockwave-flash" data="' + mfadeimages[i][0] + '" width="'+mslideshow_width+'" height="'+mslideshow_height+'">'+'<param name="movie" value="'+mfadeimages[i][0]+'" /></object>';
	
	mtempcontainer = mfadeimages[i][1] != "" ? mtempcontainer + '</a>' : mtempcontainer;	


	return mtempcontainer;
}

// --------------------------------------------------------

/**
 * checks file extensions
 *
 * @param string filename
 * @return string three char file extension
 */
function checkfileext(filename) {
	return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined;
}

// --------------------------------------------------------

/**
 * changes the image being viewed in the div
 *
 * @param void
 * @return void
 */
function mrotateimage(){

	
	if (mie4||mdom) {
		
		mresetit(mcurcanvas);
		var mcrossobj = mtempobj = mie4 ? eval("document.all."+mcurcanvas) : document.getElementById(mcurcanvas);
		mcrossobj.style.zIndex++;
		mtempobj.style.visibility = "visible";
		var mtemp = 'setInterval("mfadepic()",50)';
		mdropslide = eval(mtemp);
		mcurcanvas = (mcurcanvas == "mcanvas0") ? "mcanvas1" : "mcanvas0";
		
	} else {
		
		document.images.mdefaultslide.src = mfadeimages[mcurimageindex][0];
		mcurimageindex = (mcurimageindex<mfadeimages.length-1) ? mcurimageindex+1 : 0;
		
	}
}

// --------------------------------------------------------

/**
 * Resets a div's opacity
 *
 * @param string element id
 * @return void
 */
function mresetit(mwhat){
	
	mcurpos = 10;
	
	var mcrossobj = mie4 ? eval("document.all."+mwhat) : document.getElementById(mwhat);
	
	if (mcrossobj.filters) {
		mcrossobj.filters.alpha.opacity = mcurpos;
	} else if (mcrossobj.style.MozOpacity) {
		mcrossobj.style.MozOpacity = mcurpos/101;
	}
}

// --------------------------------------------------------

/**
 * Starts the process off (init function)
 *
 * @param void
 * @return void
 */
function mstartit(){
	var mcrossobj = mie4 ? eval("document.all."+mcurcanvas) : document.getElementById(mcurcanvas);
	mcrossobj.innerHTML = minsertimage(mcurimageindex);
	mrotateimage();
}

// --------------------------------------------------------

/**
 * Write out the initial div
 *
 *
 */
if (mie4||mdom) {
	
	
	document.write( '<div style="position:relative;width:'+mslideshow_width+';height:'+mslideshow_height+';overflow:hidden;" id="bannerWrapper">'+
					'<div id="mcanvas0" style="position:absolute; width:'+mslideshow_width+'; height:'+mslideshow_height+'; top:0; left:0; filter:alpha(opacity=10); -moz-opacity:10"></div>'+
					'<div id="mcanvas1" style="position:absolute; width:'+mslideshow_width+'; height:'+mslideshow_height+'; top:0; left:0; filter:alpha(opacity=10); -moz-opacity:10; visibility:hidden"></div>'+
					'</div>');
	
	window.onload = mstartit;
	
} else {

	document.write('<img name="mdefaultslide" src="'+mfadeimages[0][0]+'" style="width:'+mslideshow_width+'px; height:'+mslideshow_height+'px;" alt="" class="item" />');
	setInterval("mrotateimage()", mpause);
	
}




