if (top != self) {
	top.location.replace(self.location.href);
}

function addLoadEvent(func)
{ 
	var oldonload = window.onload; 

	if (typeof window.onload != 'function') { 
		window.onload = func; 
	}
	else { 
		window.onload = function() { 
			if (oldonload) { 
				oldonload(); 
			} 
	
			func(); 
		} 
	} 
}

function no_windows()
{
	if (navigator.appVersion.indexOf("Win") != -1) {
		document.getElementById('gh-download').href = 'spyder_windows.html';
		document.getElementById('ph-download').href = 'spyder_windows.html';
		document.getElementById('gf-download').href = 'spyder_windows.html';
		
		document.getElementById('gf-windowstry').className = '';
		document.getElementById('gf-easyadder').href = 'http://www.spyderx.com/idevaffiliate/idevaffiliate.php?id=100&url=http://tweetwhistle.com/261-3.html';
	}
}

function shape()
{
	document.getElementById('gf-affiliates').href = '/idevaffiliate/';
	document.getElementById('gf-contact').href = 'contact.html';
}

function share_button()
{
	if (document.getElementById("tweetmeme_button")) {
		document.getElementById("tweetmeme_button").innerHTML = "<iframe src=\"http://api.tweetmeme.com/button.js?url=http%3A//www.spyderx.com/&amp;style=compact\" height=\"20\" width=\"90\" frameborder=\"0\" scrolling=\"no\" style=\"margin-left: 4px;\"></iframe>";
	}
	
	if (document.getElementById("tweetmeme_buttonF")) {
		document.getElementById("tweetmeme_buttonF").innerHTML = "<iframe src=\"http://api.tweetmeme.com/button.js?url=http%3A//www.spyderx.com/friendadder.html&amp;style=compact\" height=\"20\" width=\"90\" frameborder=\"0\" scrolling=\"no\"></iframe>";
	}
	
	if (document.getElementById("facebook_button")) {
		document.getElementById("facebook_button").innerHTML = "<iframe src=\"http://www.facebook.com/plugins/like.php?href=http://www.spyderx.com/&amp;layout=button_count&amp;show-faces=true&amp;width=260&amp;action=like&amp;font=lucida+grande&amp;colorscheme=light\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\" style=\"border:none; overflow:hidden; width:260px; height:28px; margin:-2px 0 0 -8px;\"></iframe>";
	}
}

addLoadEvent(no_windows);
addLoadEvent(share_button);
addLoadEvent(shape);

if (document.getElementById("payment")) {
	addLoadEvent(__utmSetTrans());
}

function set_cookie(name, value, expires, path, domain, secure)
{
	var today = new Date();
	
	today.setTime(today.getTime());

	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	
	var expires_date = new Date(today.getTime() + expires);

	document.cookie = name + "=" + escape(value) + (expires ? ";expires=" + expires_date.toGMTString() : "") + (path ? ";path=" + path : "") + (domain ? ";domain=" + domain : "") + (secure ? ";secure" : "");
}

function get_cookie(name)
{
	var all_cookies = document.cookie.split(';');
	var temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var cookie_found = false;

	for (i = 0; i < all_cookies.length; i++) {
		temp_cookie = all_cookies[i].split('=');
		cookie_name = temp_cookie[0].replace(/^\s+|\s+$/g, '');

		if (cookie_name == name) {
			cookie_found = true;

			if (temp_cookie.length > 1) {
				cookie_value = unescape(temp_cookie[1].replace(/^\s+|\s+$/g, ''));
			}

			return cookie_value;
			break;
		}
		
		temp_cookie = null;
		cookie_name = '';
	}
	
	if (!cookie_found) {
		return null;
	}
}

function delete_cookie(name, path, domain)
{
	if (get_cookie(name)) {
		document.cookie = name + "=" + (path ? ";path=" + path : "") + (domain ? ";domain=" + domain : "") + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
}
