function getCookie(c_name) {
	if(document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if(c_start != -1) {
			c_start = c_start + c_name.length + 1; 
			c_end = document.cookie.indexOf(";",c_start);
			if(c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	else {
		alert("HopIt Error: Please enable cookies to be able to use this function.");
		return false;
	}
}

function autopreview() {
	var ExpireDate = new Date();
	var data;
	var text;
	ExpireDate.setDate(ExpireDate.getDate() + 360);
	if(getCookie("HopIt_AutoPreview") == 1) {
		data = 0;
		text = "Off";
	}
	else {
		data = 1;
		text = "On";
	}
	document.cookie = "HopIt_AutoPreview=" + data + ";expires=" + ExpireDate.toGMTString();
	document.getElementById('plink').innerHTML = text;
}

function donate() {
	document.getElementById('box').innerHTML = '<br /><div class="centered-text"><h3>Donate to HopIt</h3><br /><br />Donations are currently not being accepted.<br /><br /><button onclick="javascript:window.location = \'/\';">OK</button></div><br />';
}

function feedback() {
	document.getElementById('box').innerHTML = '<br /><div class="centered-text"><h3>Send feedback to HopIt</h3><br /><br />Feedback service currently unavailable.<br /><br /><button onclick="javascript:window.location = \'/\';">Cancel</button></div><br />';
}

function terms() {
	document.getElementById('box').innerHTML = '<br /><div class="centered-text"><h3>HopIt Terms and Conditions</h3></div><br /><div>HopIt was created solely for the purpose of making longer URLs easier to post/send or write down; you may create them only if you wish to use them as proper URLs. Using HopIt for illegal or spamming activity is prohibited and will result in your HopID holding the longer URL being deleted - The source IP address may then be forwarded to government organisations and ISPs for further investigation. HopIt does not come with warranty of any kind, and is not responsible for any content on the URLs that are in the HopIt URL database.</div><br /><div class="centered-text"><button onclick="javascript:window.location = \'/\';">OK</button></div><br />';
}
