// JavaScript Document
		function ___getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};		




	function str_replace(cadena, cambia_esto, por_esto) {
      return cadena.split(cambia_esto).join(por_esto);
	}
	
	function validar(e,host) {
		tecla = (document.all) ? e.keyCode : e.which;
		if (tecla==13){
			var buscar = host+'search/'+$("#type").val()+'/'+$("#input").val()+'/allsite';
			//alert(buscar);			
			document.location.href = buscar;
		}
	}
	
	function validarBTN(host) {
			var buscar = host+'search/'+$("#type").val()+'/'+$("#input").val()+'/allsite';
			//alert(buscar);			
			document.location.href = buscar;
	}
	
	function validar2(e,host,idalb) {
		tecla = (document.all) ? e.keyCode : e.which;
		if (tecla==13){
			var type = document.getElementById('itipo').value;
			var album = document.getElementById('album').value;
			var isec = document.getElementById('isec').value;
			var buscar;
			
			if(album!='0'){
				//linea = host+'search/'+type+'/'+id+'/'+album+'/img';
				buscar = host+'search/'+idalb+'/'+$("#insearch").val()+'/img';				
			}
			else{
				//linea = host+'search/'+type+'/'+id+'/'+isec+'/alb';
				buscar = host+'search/'+idalb+'/'+$("#insearch").val()+'/alb';
			}
		
			alert(buscar);			
			//document.location.href = buscar;
		}
	}
	
	function validarBTN2(host,idalb) {
		var type = document.getElementById('itipo').value;
		var album = document.getElementById('album').value;
		var isec = document.getElementById('isec').value;
		var buscar;
		
		if(album!='0'){
			//linea = host+'search/'+type+'/'+id+'/'+album+'/img';
			buscar = host+'search/'+idalb+'/'+$("#insearch").val()+'/img';
		}
		else{
			//linea = host+'search/'+type+'/'+id+'/'+isec+'/alb';
			buscar = host+'search/'+idalb+'/'+$("#insearch").val()+'/alb';
		}
			
			//alert(buscar);			
			document.location.href = buscar;
	}
	
	function checkmail(mail){
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)){
		    return (true)
	    } else {
		    return (false);
		}
	}

	function isend(){
		var name = $("#name").val();
		var email = $("#email").val();
		var desc = $("#desc").val();
		
		if( name=='' || email=='' || desc=='' ){
			//alert('All the fields are required.');
			$(".message").html('All the fields are required.');
		}
		else{
			$.ajax({
					url: "services/mail.php",
					data: "name=" +name+"&mail="+email+"&desc="+desc,
					type:"GET",
					async: true,
					success: function(retorna){
						if(retorna == 'true'){
							$(".message").html('Thank You - Your Message Has Been Sent');
						}
						else{
							$(".message").html('Sorry, an error has ocurred while we\'re sending your message.');
						}
						//alert(retorna);
					}

			});// fin de .ajax
		}
		
		return false;
	}
	
	function setThisInfo(titulo,descripcion,img,URLS,host){
		//alert(host);
		//return false;
		var tmp;
		var cut;
		var istring;
		var img_big = document.getElementById('img');
		img_big.src = '../news/square_medium.php?photo='+img;
		
		var myArray = URLS.split(',');
		for(x=0; x < myArray.length; x++){
			istring = '%';
			//formamos el string a reemplazar.
			for(i=1;i < myArray[x].length-1; i++){
				istring = istring+'|';
			}
			istring = istring+'%';
			istring[istring.length-1] = '%';
			
			cut = myArray[x].split('/');
			
			if( cut.length == 4 ){// la tratamos para link de album
				tmp = str_replace(cut[0],'event:',host)+'/1/'+cut[1]+'/'+cut[2]+'##>';
				tmp = str_replace(tmp,',','');
			}
			else{
				//$tmp = str_replace('event:','fullimage.php?sec=',$yo[0]).'&pagina=1&alb='.$yo[1].'&idalb='.$yo[2].'&npic='.$yo[3].'&pic='.$yo[4].'##>';
				tmp = str_replace(cut[0],'event:',host)+'/1/'+cut[1]+'/'+cut[2]+'/'+cut[3]+'/'+cut[4]+'/preview##>';
				tmp = str_replace(tmp,',','');
			}
			
			//alert('---'+tmp);
			descripcion = str_replace(descripcion,istring,tmp);
			//alert(myArray[x]);
		}
		descripcion = str_replace(descripcion,'(fin)','</a>');
		descripcion = str_replace(descripcion,'/r/n','<br>');
		descripcion = str_replace(descripcion,'##','"');
		descripcion = str_replace(descripcion,'$$','\'');
		descripcion = str_replace(descripcion,'//',';');
		descripcion = str_replace(descripcion,'#$','\'');
		
		titulo = str_replace(titulo,'/r/n','<br>');
		titulo = str_replace(titulo,'##','"');
		titulo = str_replace(titulo,'$$','\'');
		titulo = str_replace(titulo,'//',';');
		titulo = str_replace(titulo,'#$','\'');
		
		$("#titulo").html(titulo);
		$("#descripcion").html(descripcion);
//		"../news/1.jpg"
		
		return false;
	}
	
	function ilinkto(){
		var iref = document.getElementById('ito').value;
		//alert('--' + iref);
		document.location.href = iref;
		return false;
	}
	
	function searchthis(id,host){
		//var type = document.getElementById('type').value;
		var type = document.getElementById('itipo').value;
		var album = document.getElementById('album').value;
		var isec = document.getElementById('isec').value;
		
		if(album!='0'){
			linea = host+'search/'+type+'/'+id+'/'+album+'/img/abc';
		}
		else{
			linea = host+'search/'+type+'/'+id+'/'+isec+'/alb/abc';
		}
		document.location.href=linea;
		//alert(linea);
		return false;
	}
	
	function setLink(img,titulo,descripcion,linkto){
		//alert('img='+img+'titulo='+titulo+'descripcion='+descripcion);
		var idescripcion = descripcion;
		var ititulo = titulo;
		
		var img_big = document.getElementById('img');
		img_big.src = '../links/square_medium.php?photo='+img;
		
		var link_to = document.getElementById('linkto');
		link_to.href = linkto;
		//alert('---'+link_to.href);
		
							idescripcion = str_replace(idescripcion,'(fin)','</a>');
							idescripcion = str_replace(idescripcion,'/r/n','<br>');
							idescripcion = str_replace(idescripcion,'##','"');
							idescripcion = str_replace(idescripcion,'$$','\'');
							idescripcion = str_replace(idescripcion,'//',';');
							idescripcion = str_replace(idescripcion,'#$','\'');
							idescripcion = str_replace(idescripcion,'�','\'');
							
							ititulo = str_replace(ititulo,'/r/n','<br>');
							ititulo = str_replace(ititulo,'##','"');
							ititulo = str_replace(ititulo,'$$','\'');
							ititulo = str_replace(ititulo,'//',';');
							ititulo = str_replace(ititulo,'#$','\'');
							ititulo = str_replace(ititulo,'�','\'');
		
		$("#titulo").html(str_replace(str_replace(ititulo,'<-','\''),'->','\"'));
		$("#descripcion").html(str_replace(str_replace(idescripcion,'<-','\''),'->','\"'));
		
		return false;
	}
	
	function setMiniInfo(id){
		//alert('llllllll'+id);
		
			$.ajax({
					url: "services/getinfo.php",
					data: "pos="+id,
					type:"GET",
					async: true,
					success: function(retorna){
						//alert('......'+retorna);
						var myArray = retorna.split('@@');
//						alert('......'+retorna);
							var descripcion = myArray[3];
							var titulo = myArray[1];
							
							descripcion = str_replace(descripcion,'(fin)','</a>');
							descripcion = str_replace(descripcion,'/r/n','<br>');
							descripcion = str_replace(descripcion,'##','"');
							descripcion = str_replace(descripcion,'$$','\'');
							descripcion = str_replace(descripcion,'//',';');
							descripcion = str_replace(descripcion,'#$','\'');
							
							titulo = str_replace(titulo,'/r/n','<br>');
							titulo = str_replace(titulo,'##','"');
							titulo = str_replace(titulo,'$$','\'');
							titulo = str_replace(titulo,'//',';');
							titulo = str_replace(titulo,'#$','\'');


							var thumb = document.getElementById('imgthumb');
							thumb.src = '../stuff/square.php?photo='+myArray[0];
							$("#titulo").html(' '+titulo);
							$("#fecha").html(' '+myArray[2]);
							$("#descripcion").html(' '+descripcion);
						
					}

			});// fin de .ajax
			
		return false;
	}
	
	function setMain(id){
		//alert('llllllll'+id);
		
			$.ajax({
					url: "services/getmain.php",
					data: "pos="+id,
					type:"GET",
					async: true,
					success: function(retorna){
						//alert('......'+retorna);
						var myArray = retorna.split('@@');
						//alert('......'+retorna);
							var descripcion = myArray[3];
							var titulo = myArray[1];
							
							descripcion = str_replace(descripcion,'(fin)','</a>');
							descripcion = str_replace(descripcion,'/r/n','<br>');
							descripcion = str_replace(descripcion,'##','"');
							descripcion = str_replace(descripcion,'$$','\'');
							descripcion = str_replace(descripcion,'//',';');
							descripcion = str_replace(descripcion,'#$','\'');
							
							titulo = str_replace(titulo,'/r/n','<br>');
							titulo = str_replace(titulo,'##','"');
							titulo = str_replace(titulo,'$$','\'');
							titulo = str_replace(titulo,'//',';');
							titulo = str_replace(titulo,'#$','\'');
							
							var img_big = document.getElementById('img');
							
							//ahora modificamos la imagen grande
							img_big.src = '../stuff/square_medium.php?photo='+myArray[0];
							$("#img_titulo").html(titulo);
							$("#img_descripcion").html(str_replace(str_replace(descripcion,'<-','\''),'->','\"'));
							
							//constrimos el iref
							$("#ito").val(myArray[4]);
							//alert($("#ito").val());
							//alert(myArray[4]);
/*							
							var thumb = document.getElementById('imgthumb');
							thumb.src = '../stuff/square.php?photo='+myArray[0];
							$("#titulo").html(' '+titulo);
							$("#fecha").html(' '+myArray[2]);
							$("#descripcion").html(' '+descripcion);
*/
						
					}

			});// fin de .ajax
			
		return false;
	}
	
	function setInfo(img,titulo,fecha,descripcion,iyo){
		
		descripcion = str_replace(descripcion,'(fin)','</a>');
		descripcion = str_replace(descripcion,'/r/n','<br>');
		descripcion = str_replace(descripcion,'##','"');
		descripcion = str_replace(descripcion,'$$','\'');
		descripcion = str_replace(descripcion,'//',';');
		descripcion = str_replace(descripcion,'#$','\'');
		
		titulo = str_replace(titulo,'/r/n','<br>');
		titulo = str_replace(titulo,'##','"');
		titulo = str_replace(titulo,'$$','\'');
		titulo = str_replace(titulo,'//',';');
		titulo = str_replace(titulo,'#$','\'');
		
		//alert('img='+img+'titulo='+titulo+'fecha='+fecha+'descripcion='+descripcion);
		//var thumb = document.getElementById('imgthumb');
		var img_big = document.getElementById('img');
		
		//thumb.src = '../stuff/square.php?photo='+img;
		
		//$("#titulo").html(titulo);
		//$("#fecha").html(fecha);
		//$("#descripcion").html(descripcion);
		
		//ahora modificamos la imagen grande
		img_big.src = '../stuff/square_medium.php?photo='+img;
		$("#img_titulo").html(titulo);
		$("#img_descripcion").html(str_replace(str_replace(descripcion,'<-','\''),'->','\"'));
		
		//constrimos el iref
		$("#ito").val(iyo);
		
		return false;
	}
	
	
	//$.noConflict(); //inicializamos $ para poder trabajar con lightbox
	$(document).ready(function() {
		var donde = ' ';
			//$('#pLink').hide();
		//$(".message").hide();
		$("#ALL").click(function(){
			var iref = $("#backALL").val();
			if(iref != undefined){
				document.location.href = iref;
				//alert('jajaja'+iref);
			}
			
			return false;
		});
				
		$("#typeS1").click(function(){
				$("#typeS2").removeClass('typeEnable');
				$("#typeS1").addClass('typeEnable');
				$("#type").val(2);
				//alert($("#type").val());
				return false;
		});
		$("#typeS2").click(function(){
				$("#typeS1").removeClass('typeEnable');
				$("#typeS2").addClass('typeEnable');
				$("#type").val(1);
				//				alert($("#type").val());
				return false;
		});
		
		$("#input").focus(function(){
			if($("#input").val() == 'search site-wide'){
				$("#input").val('');
			}
		});
		
		$("#input").blur(function(){
			if($("#input").val() == ''){
				$("#input").val('search site-wide');
			}
		});
		
		$("#insearch").focus(function(){
			donde = $("#insearch").val();
			if($("#insearch").val() == 'Search Inside Category' || $("#insearch").val() == 'Search Inside Album' ){
				$("#insearch").val('');
			}
		});
		
		$("#insearch").blur(function(){
			if($("#insearch").val() == ''){
				$("#insearch").val(donde);
			}
		});
			
		
	});