function switchMedia(target, baseurl, project_id, image_id, loadingimg) {
	var req = new Request({
		
		
		url: baseurl+'/get_single_media/'+project_id+'/'+image_id,
		evalScripts: false,
		onRequest: function() {
			
		},
		onSuccess: function(txt){
			$(target).set('html', txt);
			document.location.href = '#top';
		},

		// Our request will most likely succeed, but just in case, we'll add an
		// onFailure method which will let the user know what happened.
		onFailure: function(){
			$(target).set('html', 'The request failed.');
		}
	})
	req.send();
	return true;
}

function preloadImages(images) {
	for(var i=0; i<images.length; i++) {
		if(images[i] != undefined) {
			if(!c.isLoaded(images[i])) {
				c.addToQueue(images[i]);
			}
		}
	}
}

function switchIt(target,image, spacer, width) {
	var img = $(target).getElement('img');
	if(img.getProperty('src') != image) {
		$(target).set('tween', {
				onComplete: function(e) {
					img.setProperty('src', spacer);
					
					c.addEventOnLoad(image, function() {
						$(target).set('tween', {
								onComplete: function() {
									img.setProperty('src', image);
									$(target).set('tween', {duration: 'normal',transition: Fx.Transitions.Quad.easeInOut});
									$(target).tween('opacity', 1);
								},
								duration: 'normal',
								transition: Fx.Transitions.Quad.easeInOut
							}
						);
						$(target).tween('width', width);
					});
					if(c.isLoaded(image)) {
						$(target).set('tween', {
								onComplete: function() {
									img.setProperty('src', image);
									$(target).set('tween', {duration: 'normal',transition: Fx.Transitions.Quad.easeInOut});
									$(target).tween('opacity', 1);
								},
								duration: 'normal',
								transition: Fx.Transitions.Quad.easeInOut
							}
						);
						$(target).tween('width', width);
					}else {
						c.addToQueue(image);
					}
				},
				duration: 'normal',
				transition: Fx.Transitions.Quad.easeInOut
			}
		);
		
		$(target).tween('opacity', 0);
	}
}

function show_login()
{
	login_div = document.getElementById("login");
	login_div.style.display = "block";
}

function hide_login()
{
	login_div = document.getElementById("login");
	login_div.style.display = "none";
}

function enlargeView(newImage) {
	document.getElementById('enlarge').style.display = 'none';
	document.getElementById('retract').style.display = 'block';
	document.getElementById('visual_big').src = newImage;
}

function retractView(newImage) {
	document.getElementById('retract').style.display = 'none';
	document.getElementById('enlarge').style.display = 'block';
	document.getElementById('visual_big').src = newImage;
}

function pageWidth() {return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;}
	