/**
 * Fonction : BlankPic
 *
 * @Description : L'image s'ouvre dans une nouvelle fenêtre redimentionner pour l'image.
 * @Fonctionnement : Appliquer au lien vers l'image la class="ToBlankPic"
 * @Dependency : prototype.js, utilities.js
 *   
 */
var blankpic_trigger_class = 'ToBlankPic';
var blankpic_default_title = 'Untitled Image';
var blankpic_window = null;
var blankpic_tpl = new Template('<html><head><title>#{title} (click to close)</title></head><body style="margin:0px;" onload="setTimeout(function(){ document.getElementById(\'clicktoclose\').parentNode.removeChild(document.getElementById(\'clicktoclose\')); }, \'1500\');"><div style="width:100%; position:absolute; top:15px; text-align:center; color:#ffffff;" id="clicktoclose">(click to close)</div><img src="#{src}" name="#{title}" border="0" onclick="#{actionClose}" style="cursor:pointer;" /></body></html>');

	Event.observe(window, 'load', function() { 
		
		blankpicLinks = document.getElementsByClassName(blankpic_trigger_class);
		
		if(blankpicLinks.length>0){
		
			total = blankpicLinks.length;
			for(i=0;i<total;i++){
				
				vTitle = (blankpicLinks[i].title!='')?blankpicLinks[i].title:blankpic_default_title;
				
				blankpicLinks[i].onclick = blankpic_show;
				blankpicLinks[i].vars = {src: blankpicLinks[i].href, title: vTitle, actionClose:'window.close()'};
				
			}
		
		}
		
	});
	
	blankpic_set_tpl = function(tpl){
	
		blankpic_default_tpl = new Template(tpl);
	
	}

	blankpic_show = function(){
		
		
		var arrayPageSize = getPageSize();
		
		if(screen){
				
			pLeft = (screen.width/2)-100;
			pTop = (screen.height/2)-100;
	
		}else{
			
			pLeft = (arrayPageSize[0]/2)-100;
			pTop = (arrayPageSize[1]/2)-100;
				
		}		
		
		pWinname = Math.round(Math.random()*1000);
		
		blankpic_window = open('', pWinname, 'width=200, height=200, left=' + pLeft + ', top=' + pTop + ', toolbar=0, scrollbars=0, resizable=1, menuBar=0');
	
		html = blankpic_tpl.evaluate(this.vars);
		
		blankpic_window.document.write("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>");
		blankpic_window.document.write(html);
		blankpic_window.document.close(); 
		
		Event.observe(blankpic_window, 'load', blankpic_resize);
		
		return false;
		
	}
	
	blankpic_resize = function(){
	
		pImage = blankpic_window.document.getElementsByTagName('img').item(0);
		
		if(pImage.complete){
			
			var arrayPageSize = getPageSize(blankpic_window);
			
			if(screen){
				
				pWidth = screen.width;
				pHeight = screen.height;
		
			}else{
				
				pWidth = arrayPageSize[0];
				pHeight = arrayPageSize[1];
				
			}
			
			if(BrowserDetect.browser=='Explorer' && BrowserDetect.version > 6){
				
				iWidth = $(pImage).width;
				iHeight = $(pImage).height+40;
			
			}else{
			
				iWidth = $(pImage).width;
				iHeight = $(pImage).height+18;			
			
			}
			
			blankpic_window.resizeTo(iWidth, iHeight);
			blankpic_window.moveTo((pWidth/2)-(iWidth/2), (pHeight/2)-(iHeight/2));
			
			
		}else{
			setTimeout('blankpic_resize()', 250);
		}
	
	}
/**
 * Fonction End : blankPic
 */