
var MyPkPhoto = 0;
var GetNote = (function(){
	var instance = function(){
		var me = this;
		var container = null;
		
//		getObjLeft(container)
		var BigImageLeft = getObjLeft(document.getElementById('MyImagesMain'));
		var BigImageTop = getObjTop(document.getElementById('MyImagesMain'));
		var BigImageWidth = document.getElementById('MyImagesMain').offsetWidth;
		
		var constructor = function(){
			paint();
		};
		
		me.GetBigImageTop = function() {
			return BigImageTop;
		}
		me.GetBigImageLeft = function() {
			return BigImageLeft;
		}
		

		me.SendContact = function () {
			$('ContactDiv').morph('width:0px;height:0px',{
				afterFinish: function(){ 
				$('ContactDiv').style.display = 'none';
	              	url = '/gallery/contact.php';
					var myAjax = new Ajax.Request(
					url, 
						{
						method: 'post', 
							onComplete: function (originalRequest){
						}
					});
				}
			});
			
		}
		me.OpenContact = function () {
		url = '/gallery/contact.php';
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'post', 
				onComplete: function (originalRequest){
					$('ContactDiv').style.display = 'inline';
			
					$('ContactDiv').style.background = '#000';
					$('ContactDiv').style.position = 'absolute';
				//	$('ContactDiv').style.width = '830px';
				//	$('ContactDiv').style.height = '830px';
					
					$('ContactDiv').style.top = BigImageTop + 'px';
					$('ContactDiv').style.left = BigImageLeft + 'px';
					$('ContactDiv').style.filter= 'alpha(opacity=70)';
					$('ContactDiv').style.opacity = '0.7';
					$('ContactDiv').innerHTML = originalRequest.responseText;
					$('ContactDiv').morph('width:830px;height:600px');
/*					
					Form.getElements($('MyContactForm')).each(function(input) {

						Event.observe(input, 'blur', function(ev) { 
							if ($(Event.element(ev).id).value == ''){
								//Event.element(ev).focus();
								Event.element(ev).style.background = '#f00';
								alert ('Entrer votre nom ');
								return false;
							}
							else {
								Event.element(ev).style.background = '#fff';	
							}
						});
						Event.observe(input, 'keypress', function(ev) { 
								Event.element(ev).style.background = '#fff';
						});

					});
					*/
				}
			});

			
		};
			
		me.OpenNote = function () {
			
		if (MyIntroText == 1){return false;}
		if (MyPkPhoto == 0) {return false;}
			if (Stop == null) {
			
			$('container').style.position = 'absolute';
			$('container').style.left = BigImageLeft + 'px';
			$('container').style.top = BigImageTop + 'px';
			$('container').style.width = (BigImageWidth) + 'px';
			$('container').style.display = 'inline';
			$('container').style.padding = '0px';
//			var ArLeft = document.createElement("div");
//			ArLeft.id = 'ArLeft';
//			ArLeft.innerHTML = 'LEFT';
//			ArLeft.style.left = BigImageLeft + 'px';
//			ArLeft.style.top = (BigImageTop + 200) + 'px';
//			var ArRight = document.createElement("div");
//			ArRight.id = 'ArRight';
//			ArRight.innerHTML = 'ArRight';
//			ArRight.style.left = (BigImageLeft + BigImageWidth-50) + 'px';
//			ArRight.style.top = (BigImageTop + 200) + 'px';

//			if (!$('ArLeft') && !$('ArRight')){
				//$('container').innerHTML
//				$('Main').appendChild(ArLeft);
//				$('Main').appendChild(ArRight);
//			}
		}
		
		
		var MyImageSrc = document.getElementById('MyImagesMain').src;
//		var url = '/gallery/GetMyImage.php?cmd=OpenNote&MyImageSrc=' + MyImageSrc;
		var url = '/gallery/GetMyImage.php?cmd=GetImgInformation&pk_photo=' + MyPkPhoto;
//		var url = './GetMyImage.php?cmd=OpenNote';

		var myAjax = new Ajax.Request(
			url, 
			{
//			var notice = $('container'); 	
				method: 'GET', 
				onComplete: showResponseNote
			});
		
		}

		me.CloseNote = function () {
		if (MyIntroText == 1){return false;}
			document.getElementById('container').style.display = 'none';
			document.getElementById('container').className = 'container';
//			if ($('ArLeft'))
//			$('ArLeft').style.display = 'none';
//			if ($('ArRight'))
//			$('ArRight').style.display = 'none';

//		$('Main').removeChild($('ArLeft'));
		//	if ($('ArRight'))
		//		$('Main').removeChild($('ArRight'));
		}
		
		me.getContainer = function() {
			return container;
		};

		
		me.getIntro = function(MyID) {
			MyIntroText = 1;
			document.getElementById('container').style.position = 'absolute';
			document.getElementById('container').style.left = (BigImageLeft+50) + 'px';
			document.getElementById('container').style.top = (BigImageTop+50) + 'px';
			document.getElementById('container').style.width = (450) + 'px';
			document.getElementById('container').style.padding = '10px';
			document.getElementById('container').style.display = 'block';
			document.getElementById('container').style.filter= 'alpha(opacity=50)';
//			document.getElementById('container').style.MozOpacity = '0.5';
			document.getElementById('container').style.opacity = '0.5';
			
			var url = '/gallery/IntroText.html';
			var myAjax = new Ajax.Request(
			url, 
			{
		//	var notice = $('container');
				method: 'GET', 
				onComplete: showResponseNote
			});

/*			document.getElementById('container').innerHTML = '' +
			'Portefolio<br />' +
			'Martin Valliere<br />' +
			'<br>' +
			'<br>' +
			'<br>' +
			'<br>' +
			'<br>' +
			'<br>' +
			'';*/
		};
		
		var paint = function(){
		
		};

		constructor();
	};

	return instance;
})();




