
// Resize window
self.focus();
self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);

// Bookmark
function bookmark_page() {
	try {
		if (document.all) {
			window.external.AddFavorite('http://www.gaypasslist.net/younggaypass/', 'Young Gay Passwords');
		} else if (window.sidebar) {
			window.sidebar.addPanel('Young Gay Passwords', 'http://www.gaypasslist.net/younggaypass/', "");
		}
		stats('links', 'bookmark');
	} catch (err) {
		alert("Error! Your Internet browser does not allow to execute this action. Press Ctrl-D.");
	} 
	return false;
}

// Set homepage
function set_homepage(src) {
	try {
		src.style.behavior='url(#default#homepage)';
		src.setHomePage('http://www.gaypasslist.net/younggaypass/');
		stats('links', 'sethomepage');
	} catch (err) {
		alert("Error! Your Internet browser does not allow to execute this action.");
	} 
	return false;
}

// Copy username and password to clipboard
function clp(el) {
	try {
		var ua = navigator.userAgent.toLowerCase();
		if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) {
			window.clipboardData.setData("Text", el.firstChild.nodeValue);
		}
	} catch (err) { } 

	return false;
}

// Show current time
function showTime() {
	var tm = new Date();
	var isnMonth = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	var isnDay = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
	var year = tm.getUTCFullYear();
	var month = tm.getUTCMonth();
	var date = tm.getUTCDate();
	var day = tm.getUTCDay();
	var hour = tm.getUTCHours();
	var min = tm.getUTCMinutes();
	var sec = tm.getSeconds();
	if (date <= 9) {date = "0" + date}
	if (hour <= 9) {hour = "0" + hour}
	if	(min <= 9) {min = "0" + min}
	if (sec <= 9) {sec = "0" + sec}
	var time = isnDay[day] + ", " + isnMonth[month] + " " + date + ", " + year + " " + hour + ":" + min + ":" + sec + " GMT";
	var clk = document.getElementById("clock");
	if (clk) { clk.firstChild.nodeValue = time; }
	setTimeout("showTime()", 1000);
}
showTime();

// Set color of opened links
function url(src) {
	try {
		src.style.color = "#5b5551";
	} catch (err) { } 
}

// Report dead passwords
function rep(src, rec, suff) {
	try {
		var domain, username, password;
		var itm = src.parentNode;
		for (var i = 0; i <= itm.childNodes.length - 1; i++ ) {
			el = itm.childNodes[i];
			if (el.nodeName == 'A' && el.className != "report") { domain = el.firstChild.nodeValue }
			if (el.nodeName == 'EM' && el.title == "login") {
				if (el.firstChild) {
					username = el.firstChild.nodeValue;
				} else {
					username = '';
				}
			}
			if (el.nodeName == 'EM' && el.title == "password") { password = el.firstChild.nodeValue }
		}

		rec = '' + rec;
		while (rec.length < 3) { rec = '_' + rec }

		if (typeof(suff) == "undefined") { suff = ' ' };
		var request = encode64('rec=' + escape(rec) + '&name=' + escape(domain) + '&login=' + escape(username) + '&passw=' + escape(password) + '&src=' + escape(suff));

		src.href = "http://www.gaypasslist.net/younggaypass/report.html" + '?' + request;
		src.firstChild.nodeValue = '';

		return true;
	} catch (err) {
		alert("Error! Your Internet browser does not allow to execute this action.");
		return false;
	}
}

// Base64 encode for rep(src, rec) function
function encode64(input) {
	var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

	do {
		chr1 = input.charCodeAt(i++);
		chr2 = input.charCodeAt(i++);
		chr3 = input.charCodeAt(i++);

		enc1 = chr1 >> 2;
		enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
		enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
		enc4 = chr3 & 63;

		if (isNaN(chr2)) {
			enc3 = enc4 = 64;
		} else if (isNaN(chr3)) {
			enc4 = 64;
		}

		output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);

	} while (i < input.length);
   
   return output;
}

// Links statistics
function stats(id, num, url) {
	try {

		var s = document.getElementById('hidd');
		var f = document.createElement('form');
		f.setAttribute('target', 'ifrm_hidd');
		f.setAttribute('action', 'http://www.gaypasslist.net/cgi-bin/a/io/out.cgi');
		s.appendChild(f);
		var i;

		if (id) {
			i = document.createElement('input');
			i.setAttribute('type', 'hidden');
			i.setAttribute('name', 'id');
			i.setAttribute('value', id);
			f.appendChild(i);
		}

		if (num) {
			i = document.createElement('input');
			i.setAttribute('type', 'hidden');
			i.setAttribute('name', 'num');
			i.setAttribute('value', num);
			f.appendChild(i);
		}

		if (url) {
			i = document.createElement('input');
			i.setAttribute('type', 'hidden');
			i.setAttribute('name', 'url');
			i.setAttribute('value', url);
			f.appendChild(i);
		}
	
		f.submit();
		s.removeChild(f);

	} catch (err) {}

	return true;
}

// stats() wrapper for out links
function out(src) {

	try {
		var url = src.href;
		if (! url) { return true; }
		var text = url.replace(/^http:\/\/(www\.)?([^\/]+).+/, "$2");
		stats('out', text, url);
	} catch (err) {}

	return true;
}

// Blinds
function blnd(url) {
	try {
		if (url) {
			window.status = 'http://anonym.to/?' + url;
		} else {
			window.status = '';
		}

	} catch (err) {}
}
