function preload(m) {
	
	x = new Image();
	
	x.src = m;
	
}



function tos() {
	
	alert("Thanks for visiting Aquate. If this is your first visit here, welcome; if it's not, then thanks for your patronage! Unfortunately, the only thing we couldn't revolutionize of the image uploader is the ToS. So if you'd please skim the following rules and follow them, it'd make sure we'll be around for a long time and that you'll be able to use the services.\n\n1. No pornography or overly offensive images. We do not prohibit language, but items such as hentai and etc. are not allowed and will warrant an instant IP ban.\n2. Don't hack us, please? If we see that your IP has uploaded a file twice our size limit, then we know that something's up and you'll be banned. \n3. Do not upload any images protected by copyright law in any country.\n4. Anything illegal shouldn't be on our servers either.\n5. Use your common sense. If you wouldn't put it on your grandma's refrigerator, think twice before uploading it here.\n6. We reserve the right to delete any image without warning. All images uploaded here become the property of Aquate unless previously protected by copyright.\n\nIf you like Aquate, send us a donation at chocolate570@gmail.com. The more money we get, the more inclined we are to add more features! ;)\nEnjoy.");
}




y=navigator.userAgent;

if(y.match(/Mac/i)) {
	
	document.write("<style type='text/css'>#show { top:0px;}</style>");
	
}

preload("./Includes/Images/again.png");

preload("./Includes/Images/copy.png");





function copy(text2copy) {
	
  if (window.clipboardData) {
	  
	window.clipboardData.setData("Text",text2copy);
	
  } else {
	  
	var flashcopier = 'flashcopier';
	
	if(!document.getElementById(flashcopier)) {
		
	  var divholder = document.createElement('div');
	  
	  divholder.id = flashcopier;
	  
	  document.body.appendChild(divholder);
	  
	}
	
	document.getElementById(flashcopier).innerHTML = '';
	
	var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
	
	document.getElementById(flashcopier).innerHTML = divinfo;
  
  }
  
}




function unflash() {
	
	var box6 = $('req');

	var fx6 = box6.effects({duration: 500});

	fx6.start({

		color: "#2177B2"

	})
	
}




function flash() {
	
	var box6 = $('req');

	var fx6 = box6.effects({duration: 500});

	fx6.start({

		color: "#EF3B3B"

	})
	
	setTimeout("unflash()",2000);
	
	return false;
	
}




function chosen() {
	
	file = document.getElementById("hidden");
	
	if(file.value.length>0) {
		
		uploadClicked();
		
		return true;
		
	} else {
		
		return flash();
		
	}
	
}




function figure() {

	file = document.getElementById("hidden");

	val = file.value;

	if( val ) {

		val = val.substring( val.lastIndexOf("\\")+1,val.length );

		document.getElementById("show").value = val;

	}

}



function uploadClicked() {

	var box2 = $('show');

	var fx2 = box2.effects({duration: 500});

	fx2.start({

		width: 0

	})

	setTimeout("inputs()",500)

}



function fetch() {

	var box5 = $('loading');

	var fx5 = box5.effects({duration: 1000});

	fx5.start({

		opacity: 1

	})

	

}



function inputs() {

	document.getElementById("show").style.display="none";
	
	fetch();

	var box3 = $('input1');

	var fx3 = box3.effects({duration: 500});

	fx3.start({

		opacity: 0

	})

	var box4 = $('input2');

	var fx4 = box4.effects({duration: 500});

	fx4.start({

		opacity: 0

	})

}



function textbox() {
	
	document.getElementById("show").style.display="";
	
	var box6 = $('show');

	var fx6 = box6.effects({duration: 500});

	fx6.start({

		width: '272px',
		opacity: 1

	})
}




function showInputs() {
	
	var box3 = $('input1');

	var fx3 = box3.effects({duration: 500});

	fx3.start({

		opacity: 1

	})

	var box4 = $('input2');

	var fx4 = box4.effects({duration: 500});

	fx4.start({

		opacity: 1

	})
	document.getElementById("loading").style.visiblity="none";
	var box5 = $('loading');

	var fx5 = box5.effects({duration: 500});

	fx5.start({

		opacity: 0

	})
	
	setTimeout("textbox()",800);
}




function error(m) {
	
	var box3 = $('input1');

	var fx3 = box3.effects({duration: 500});

	fx3.start({

		opacity: 1

	})

	var box4 = $('input2');

	var fx4 = box4.effects({duration: 500});

	fx4.start({

		opacity: 1

	})
	
	document.getElementById("loading").style.visiblity="none";
	var box5 = $('loading');

	var fx5 = box5.effects({duration: 500});

	fx5.start({

		opacity: 0

	})
	
	setTimeout("textbox()",800);
	setTimeout("flash()",800);

}



function again() {
	
	uploadClicked();
	
	setTimeout("origin()",1500);
	
}



function origin() {
	
	document.getElementById("hidcont").style.left="-262px";
	
	document.getElementById("input1").style.backgroundImage="url(http://aquate.us/Includes/Images/browse.png)";
	
	document.getElementById("input2").style.backgroundImage="url(http://aquate.us/Includes/Images/upload.png)";
	
	if(!document.all) document.getElementById("input2").type="submit";
	
	if(document.all)
	
		document.getElementById("zoop").innerHTML='<input id="input2" value="" type="submit" style="border:0px solid black;" />';
		
	$("input1").removeEvents();
	
	$("input2").removeEvents();
	
	document.getElementById("hidden").value="";
	
	document.getElementById("show").value="";
	
	showInputs();

}




function message(m) {
	
	document.getElementById("input1").style.backgroundImage="url(http://aquate.us/Includes/Images/copy.png)";
	
	document.getElementById("hidcont").style.left="-5000px";
	
	if(!document.all) $("input2").setProperty("type","button");
	
	if(document.all) 
	
		document.getElementById("zoop").innerHTML='<input id="input2" value="" type="button" style="border:0px solid black;" />';
	
	document.getElementById("input2").style.backgroundImage="url(http://aquate.us/Includes/Images/again.png)";
	
	$("input1").addEvent("click",function() {copy(m);});
	
	$("input2").addEvent("click",function() {again();});
	
	document.getElementById("show").value = m;
	
	showInputs();
	
}




function handleResponse(msg) {
	
	fut = msg.match(/http\:\/\//i)?"message":"error";
	
	body = msg.match(/http\:\/\//)?msg:msg.split("Error: ")[1];
	
    setTimeout(fut+"('"+body+"')",1500);

}



function checkCount() {
	
	try {
		
		new Ajax("count.txt", {
			
			method: 'get',
			
			update: 'num'
			
		}).request();
		
	} catch(e) {}
	
}




function unfade() {
	
	var box7 = $('num');

	var fx7 = box7.effects({duration: 500});

	fx7.start({

		opacity: 1

	});
}



function upDate() {
	try {
		document.getElementById("time").innerHTML=date("h:i:s A");
	} catch(e) {}
}




window.onload = function() {y = setInterval("checkCount()",3000);}

z = setInterval("upDate()",1000);