/*
----------------------------------------------------------------------------------
- TEXTFORMATERING
----------------------------------------------------------------------------------
*/
/*
----------------------------------------------------------------------------------
- DHTML EXTRAS
----------------------------------------------------------------------------------
*/
/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2001-3 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// onresize for ns4
var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}
//-->
/*
----------------------------------------------------------------------------------
- LOGIN
----------------------------------------------------------------------------------
*/
<!--
function initLogin() {
	getElemRefs('dynamic-content').innerHTML = "";
	showLayer('site-overall');
	showLayer('dynamic-content-holder');
	showLayer('dynamic-content');
	showLayer('ajax-loading-bar');
	return true;
}
//-->
<!--
function completeLogin(response) {
	if(response && response == "postback-valid"){
		window.location.href = "./";
		return false;
	}else if(response && response == "postback-notactive"){
		alert("Your account is not activated, please contact us at support@rakemenot.com\n");
	}else{
		alert(response);
	}
	getElemRefs('dynamic-content').className = "";
	getElemRefs('dynamic-content').innerHTML = "";
	hideLayer('dynamic-content-holder');
	hideLayer('dynamic-content');
	hideLayer('site-overall');
	hideLayer('ajax-loading-bar');
}
//-->
/*
----------------------------------------------------------------------------------
- LOGOUT
----------------------------------------------------------------------------------
*/
<!--
function logout() {
	my_ajax = new sack();
	my_ajax.requestFile		= "ajax-logout.php";
	my_ajax.onLoading		= function(){ 
								getElemRefs('dynamic-content').innerHTML = "";
								showLayer('site-overall');
								showLayer('dynamic-content-holder');
								showLayer('dynamic-content');
								showLayer('ajax-loading-bar');
							};
	my_ajax.onError			= function(){ alert("Ett fel har uppstått!\n"); };
	my_ajax.onCompletion	= function(){ 
								alert(my_ajax.response);
								hideLayer('site-overall');
								hideLayer('dynamic-content-holder');
								hideLayer('dynamic-content');
								hideLayer('ajax-loading-bar');
								window.location.href = "./";		
							};
	my_ajax.runAJAX();
}
//-->
/*
----------------------------------------------------------------------------------
- SIGNUP
----------------------------------------------------------------------------------
*/
<!--
function initSignup() {
	my_ajax = new sack();
	my_ajax.requestFile		= "ajax-signup.php";
	my_ajax.onLoading		= function(){ 
								getElemRefs('dynamic-content').innerHTML = "";
								showLayer('site-overall');
								setHeight('site-overall');
								showLayer('dynamic-content-holder');
								showLayer('dynamic-content');
								showLayer('ajax-loading-bar');
							};
	my_ajax.onError			= function(){ alert("Ett fel har uppstått!\n"); };
	my_ajax.onCompletion	= function(){ 
								getElemRefs('dynamic-content-topic').innerHTML = "Signup as a new customer";
								getElemRefs('dynamic-content').innerHTML = my_ajax.response;
								hideLayer('ajax-loading-bar');
							};
	my_ajax.runAJAX();
}
//-->
<!--
function startSignup() {	
	getElemRefs('signup-form').className = 'transparency-20';
	getElemRefs('dynamic-content-header').innerHTML = "";
	showLayer('site-overall');
	showLayer('dynamic-content-holder');
	showLayer('ajax-loading-bar');
}
//-->
<!--
function completeSignup(response) {
	showLayer('content-postresult');
	getElemRefs('content-postresult').innerHTML = response;
	getElemRefs('content-postresult').className = 'transparency-80';
	hideLayer('ajax-loading-bar');
}
//-->
<!--
function restartSignup() {	
	getElemRefs('signup-form').className = '';
	getElemRefs('dynamic-content-header').innerHTML = "<a href=\"#\" onclick=\"closeContent(); return false;\"><img src=\"pics/delete2.png\" alt=\"Close\" /></a>";
	hideLayer('content-postresult');
}
//-->
/*
----------------------------------------------------------------------------------
- PASSWORD RECOVERY
----------------------------------------------------------------------------------
*/
<!--
function initRecovery() {
	getElemRefs('dynamic-content').innerHTML = "";
	showLayer('site-overall');
	showLayer('dynamic-content-holder');
	showLayer('dynamic-content');
	showLayer('ajax-loading-bar');
	return true;
}
//-->
<!--
function completeRecovery(response) {
	if(response && response == "postback-success"){
		alert("An E-mail has been sent to you with your new password.\n");
		window.location.href = "./";
	}else if(response && response == "postback-failure"){
		alert("Due to technical issues the E-mail could not be send, please try again or contact us at support@rakemenot.com.\n");
	}else{
		alert(response);
	}
	getElemRefs('dynamic-content').className = "";
	getElemRefs('dynamic-content').innerHTML = "";
	hideLayer('dynamic-content-holder');
	hideLayer('dynamic-content');
	hideLayer('site-overall');
	hideLayer('ajax-loading-bar');
}
//-->
/*
----------------------------------------------------------------------------------
- NEWS
----------------------------------------------------------------------------------
*/
<!--
<!--
function deleteNews(newsid) {
	if(confirm("Vill du ta bort nyheten?\n")){
		my_ajax = new sack();
		my_ajax.requestFile		= "ajax-news.php?newsid=" + newsid;
		my_ajax.onLoading		= function(){ 
									showLayer('site-overall');
									showLayer('dynamic-content-holder');
									showLayer('dynamic-content');
									showLayer('ajax-loading-bar');
								};
		my_ajax.onError			= function(){ alert("Ett fel har uppstått!\n"); };
		my_ajax.onCompletion	= function(){ 
									hideLayer('site-overall');
									hideLayer('dynamic-content-holder');
									hideLayer('dynamic-content')
									hideLayer('ajax-loading-bar');
									alert(my_ajax.response);
									window.location.href = "./news.php";
								};
		my_ajax.runAJAX();
	}
	return false;
}
//-->
<!--
function newsAdminInit() {
	showLayer('site-overall');
	showLayer('dynamic-content-holder');
	showLayer('dynamic-content');
	showLayer('ajax-loading-bar');
}
//-->
<!--
function newsAdminCallback(response){
	hideLayer('site-overall');
	hideLayer('dynamic-content-holder');
	hideLayer('dynamic-content')
	hideLayer('ajax-loading-bar');
	alert(response);
	window.location.href = "./news.php";
}
//-->
<!--
/*
function startSignup() {	
	getElemRefs('signup-form').className = 'transparency-40';
	getElemRefs('dynamic-content-header').innerHTML = "";
	showLayer('site-overall');
	showLayer('dynamic-content-holder');
	showLayer('ajax-loading-bar');
}
*/
//-->
<!--
/*
function completeSignup(response) {
	showLayer('content-postresult');
	getElemRefs('content-postresult').innerHTML = response;
	getElemRefs('content-postresult').className = 'transparency-80';
	hideLayer('ajax-loading-bar');
}
*/
//-->
/*
----------------------------------------------------------------------------------
- OFFERS / SITEREG
----------------------------------------------------------------------------------
*/
<!--
function siteRegInit() {	
//	getElemRefs('dynamic-content').innerHTML = "";
//	setHeight('site-overall');
//	showLayer('site-overall');
	hideLayer('signup-form')
	showLayer('ajax-loading-bar');
}
//-->
<!--
function siteRegCallback(response) {
	showLayer('regsite-holder');
	getElemRefs('regsite-holder').innerHTML = response;
	hideLayer('ajax-loading-bar');
}
//-->
<!--
function resetRegsite() {	
	hideLayer('regsite-holder');
	showLayer('signup-form');
}
//-->
/*
----------------------------------------------------------------------------------
- MISC
----------------------------------------------------------------------------------
*/
<!--
function setHeight(obj){
	var obj = getElemRefs(obj);
	if (parseInt(navigator.appVersion) >= 3){
		if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)<5){
			var tools = new Packages.java.awt.Toolkit.getDefaultToolkit();
			screen=tools.getScreenSize();
		}
		y = screen.height;
	}
	var h = getElemRefs('site-container').scrollHeight;
	if(obj && obj.css) obj.css.height = h + "px";
}
//-->
<!--
function exec(text, caller) {
	if(text && text == "terms"){
		var text_topic = "Terms and Conditions";
	}else if(text && text == "privacy"){
		var text_topic = "Privacy Policy";
	}
	if(caller && caller == "footer"){
		var closebtn = "<a href=\"#\" onclick=\"closeContent(); return false;\"><img src=\"pics/delete2.png\" alt=\"Close\" /></a>";
	}else if(caller == ""){
		var closebtn = "<a href=\"#\" onclick=\"backToReg(); return false;\"><img src=\"pics/arrow-back.png\" alt=\"Back\" /></a>";
	}
	my_ajax = new sack();
	my_ajax.requestFile		= "exec-text.php?txt=" + text;
	my_ajax.onLoading		= function(){ 
								getElemRefs('static-content').innerHTML = "";
								getElemRefs('static-content').style.width = "640px";
								getElemRefs('static-content').style.height = "453px";
								getElemRefs('static-content').className = "attach-scrollbar";
								
								hideLayer('dynamic-content');
								setHeight('site-overall');
								showLayer('site-overall');
								showLayer('dynamic-content-holder');
								showLayer('static-content');
								showLayer('ajax-loading-bar');
							};
	my_ajax.onError			= function(){ alert("Ett fel har uppstått!\n"); };
	my_ajax.onCompletion	= function(){
								window.scrollTo(0, 0);
								hideLayer('ajax-loading-bar');
								getElemRefs('dynamic-content-topic').innerHTML = text_topic;
								getElemRefs('dynamic-content-header').innerHTML = closebtn;
								getElemRefs('static-content').innerHTML = my_ajax.response;
								getElemRefs('static-content').style.background = "../pics/ajax-window-back-2.png";
							};
	my_ajax.runAJAX();
}
//-->
<!--
function backToReg(){
	hideLayer('static-content');
	showLayer('dynamic-content');
	getElemRefs('dynamic-content-header').innerHTML = "<a href=\"#\" onclick=\"closeContent(); return false;\"><img src=\"pics/delete2.png\" alt=\"Close\" /></a>";
}
//-->
<!--
function closeContent(){
	getElemRefs('dynamic-content').className = "";
	getElemRefs('dynamic-content').innerHTML = "";
	getElemRefs('static-content').className = "";
	getElemRefs('static-content').innerHTML = "";
	hideLayer('ajax-loading-bar');
	hideLayer('dynamic-content-holder');
	hideLayer('dynamic-content');
	hideLayer('static-content');
	hideLayer('content-postresult');
	hideLayer('site-overall');
	setHeight('site-overall');
}
//-->
/*
----------------------------------------------------------------------------------
- ACCOUNT ACTIVATION
----------------------------------------------------------------------------------
*/
<!--
function closeActivation(uname){
	getElemRefs('username').value = uname;
	getElemRefs('userpasswd').style.border = "1px #FF0000 solid;";
	hideLayer('dynamic-content-holder');
	hideLayer('dynamic-content');
	hideLayer('content-postresult');
	hideLayer('site-overall');
}
//-->
<!--
function activateAccount(account) {
	var account = account;
	if(account){
		my_ajax = new sack();
		my_ajax.requestFile		= "ajax-activate-account.php?key=" + account;
		my_ajax.onLoading		= function(){ 
									getElemRefs('dynamic-content').innerHTML = "";
									showLayer('site-overall');
									showLayer('dynamic-content-holder');
									showLayer('dynamic-content');
									showLayer('ajax-loading-bar');
								};
		my_ajax.onError			= function(){ alert("Ett fel har uppstått!\n"); };
		my_ajax.onCompletion	= function(){ 
									getElemRefs('dynamic-content-topic').innerHTML = "Account Activation";
									getElemRefs('dynamic-content').innerHTML = my_ajax.response;
									hideLayer('ajax-loading-bar');
								};
		my_ajax.runAJAX();
	}
}
//-->
/*
----------------------------------------------------------------------------------
- MY ACCOUNT
----------------------------------------------------------------------------------
*/
<!--
function initChangepass(){
	hideLayer('form-updatepass-holder');
	showLayer('myaccount-updatepass-holder');
	getElemRefs('myaccount-updatepass-holder').innerHTML = "<p class=\"align-the-loader\" style=\"margin-top: 40px;\"><img src=\"pics/loading_animation.gif\" alt=\"loading-bar\" /></p>";
	return true;
}
//-->
<!--
function callbackChangepass(response){
	getElemRefs('myaccount-updatepass-holder').innerHTML = response
}
//-->
<!--
function nlchangestate(userid, obj){
	if(obj && obj == "newsletter-state"){
		var stateval = "mmail";
	}else if(obj && obj == "active-state"){
		var stateval = "activate";
	}
	if(getElemRefs(obj).innerHTML == "YES"){
		var state	= 2;
		var result	= "NO";
	}else{
		var state = 1;
		var result	= "YES";
	}
//	alert("Göra vad: " + state + "\nGöra med: " + stateval);
//	return false;

	my_ajax = new sack();
	my_ajax.requestFile		= "ajax-update-account.php?state=" + stateval + "&value=" + state + "&userid=" + userid;
	my_ajax.onLoading		= function(){ /* showLayer('ajax-loading-bar'); */ getElemRefs(obj).innerHTML = "<img src=\"pics/loading_animation.gif\" alt=\"loading-bar\" />\n"; };
	my_ajax.onError			= function(){ alert("Ett fel har uppstått!\n"); };
	my_ajax.onCompletion	= function(){ 
								getElemRefs(obj).innerHTML = result;
								hideLayer('ajax-loading-bar');
								//alert(my_ajax.response);
							};
	my_ajax.runAJAX();
}
//-->
<!--
function dateChanged(){
	var userid = getElemRefs('affected_account').innerHTML;
	var y = calendar.date.getFullYear();
	var m = calendar.date.getMonth();     // integer, 0..11
	var d = calendar.date.getDate();      // integer, 1..31
	m = m + 1;

	var datestr = y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);

	my_ajax = new sack();
	my_ajax.requestFile		= "ajax-update-account.php?state=tfield&fieldname=birthdate&content=" + datestr + "&userid=" + userid;
	my_ajax.onLoading		= function(){ };
	my_ajax.onError			= function(){ alert("HTTP 500!\n"); };
	my_ajax.onCompletion	= function(){ };
	my_ajax.runAJAX();

	calendar.hide();
}
//-->
<!--
function loadStats(){ 
	var accountid	= getElemRefs('accountid').value;
	var statsite	= getElemRefs('statsite').options[getElemRefs('statsite').selectedIndex].value;
	var statyear	= getElemRefs('statyear').options[getElemRefs('statyear').selectedIndex].value;
	var statmonth	= getElemRefs('statmonth').options[getElemRefs('statmonth').selectedIndex].value;
	if(accountid && (statsite && !(statsite == "foo")) && (statyear && !(statyear == "foo")) && (statmonth && !(statmonth == "foo"))){
		my_ajax = new sack();
		my_ajax.requestFile		=	"ajax-load-stats.php?" +
									"accountid=" + accountid + "&" +
									"statsite=" + statsite + "&" +
									"statyear=" + statyear + "&" +
									"statmonth=" + statmonth;
		my_ajax.onLoading		= function(){
												hideLayer('account-mystats-form');
												showLayer('account-mystats-loader');
											};
		my_ajax.onError			= function(){ alert("HTTP 500!\n"); };
		my_ajax.onCompletion	= function(){
												getElemRefs('account-my-stats').innerHTML = my_ajax.response;
												hideLayer('account-mystats-loader');
												showLayer('account-mystats-form');
											};
		my_ajax.runAJAX();
	}
}

//-->
/*
----------------------------------------------------------------------------------
- ADMINISTRATION
----------------------------------------------------------------------------------
*/
<!--
function searchUsers(){
	var searchstr = getElemRefs('searchstr').value;
	if(searchstr){
		my_ajax = new sack();
		my_ajax.requestFile		=	"ajax-admin-users.php?" +
									"searchstr=" + searchstr;
		my_ajax.onLoading		= function(){
												getElemRefs('search-user-result').innerHTML = "<img src=\"pics/loading_animation.gif\" alt=\"loading...\" />";
											};
		my_ajax.onError			= function(){ alert("HTTP 500!\n"); };
		my_ajax.onCompletion	= function(){
												getElemRefs('search-user-result').innerHTML = my_ajax.response;
											};
		my_ajax.runAJAX();
	}
}
//-->
<!--
function loadSiteparams(userid, rbuid, siteid){
	my_ajax = new sack();
	my_ajax.requestFile		=	"ajax-admin-user-site.php?" +
								"userid=" + userid + "&" +
								"rbuid=" + rbuid + "&" +
								"siteid=" + siteid;
	my_ajax.onLoading		= function(){	hideLayer('myaccount-sites-holder');
											showLayer('myaccount-siteadm-holder');
											getElemRefs('myaccount-siteadm-holder').innerHTML = "<p class=\"align-the-loader\"><img src=\"pics/loading_animation.gif\" alt=\"loading-bar\" /></p>";
										};
	my_ajax.onError			= function(){ alert("HTTP 500!\n"); };
	my_ajax.onCompletion	= function(){
											getElemRefs('myaccount-siteadm-holder').innerHTML = my_ajax.response;
										};
	my_ajax.runAJAX();
}
//-->
<!--
function initManagesite(){
	hideLayer('myaccount-sites-holder');
	hideLayer('myaccount-siteadm-holder');
	showLayer('myaccount-postresult-holder');
	getElemRefs('myaccount-postresult-holder').innerHTML = "<p class=\"align-the-loader\"><img src=\"pics/loading_animation.gif\" alt=\"loading-bar\" /></p>";
}
//-->
<!--
function callbackManagesite(response){
	getElemRefs('myaccount-postresult-holder').innerHTML = response
}
//-->
<!--
function initExportList(){
	return true;
}
//-->
<!--
function callbackExportList(response){
	alert(response);
}
//-->
<!--
function editOffer(siteid){
	my_ajax = new sack();
	my_ajax.requestFile		=	"admin-offer-edit.php?" +
								"ot_parentid=" + siteid;
	my_ajax.onLoading		= function(){	showLayer('offer-edit-loader');
											showLayer('offer-edit-cover');
											hideLayer('offer-edit-container');
										};
	my_ajax.onError			= function(){ alert("HTTP 500!\n"); };
	my_ajax.onCompletion	= function(){
											getElemRefs('offer-edit-container').innerHTML = my_ajax.response;
											hideLayer('offer-edit-loader');
											hideLayer('offer-edit-cover');
											showLayer('offer-edit-container');
										};
	my_ajax.runAJAX();
}
//-->
<!--
function initOfferedit(){
	showLayer('offer-edit-loader');
	showLayer('offer-edit-cover');
//	hideLayer('offer-edit-container');
}
//-->
<!--
function callbackOfferedit(response){
	hideLayer('offer-edit-loader');
	if(response && response == "success=insert"){
		alert("The text was Inserted.\n");
		return false;
	}else if(response && response == "success=update"){
		alert("The text was updated.\n");
		return false;
	}
	getElemRefs('offer-edit-container').innerHTML = response;
	hideLayer('offer-edit-cover');
}
//-->
<!--
function vbCode(style, formobj){
	if(style && style == "bold"){
		bld = prompt("Please enter the Bold text.", "");
		if(bld != null){
			formobj.value += "[b]" + bld + "[/b]";
		}
	}
	if(style && style == "italic"){
		bld = prompt("Please enter the Italic text.", "");
		if(bld != null){
			formobj.value += "[i]" + bld + "[/i]";
		}
	}
	if(style && style == "uline"){
		bld = prompt("Please enter the Underlined text.", "");
		if(bld != null){
			formobj.value += "[u]" + bld + "[/u]";
		}
	}
	if(style && style == "url"){
		bld = prompt("Please enter your URL.", "http://");
		if(bld != null){
			txt = prompt("Please enter a Title for your URL", "");
			if(txt != null){
				formobj.value += "[url=" + bld + "]" + txt + "[/url]";
			}
		}else{
			formobj.value += "[url=" + txt + "]" + txt + "[/url]";
		}
	}
	if(style && style == "image"){
		bld = prompt("Please enter the path to your picture.", "");
		if(bld != null){
			formobj.value += "[img]" + bld + "[/img]";
		}
	}
}
//-->
<!--
function preview_offer(action){
	window.scrollTo(0, 0);
	setHeight('site-overall');
	if(action && action == "view"){
		showLayer('site-overall');
		showLayer('edit-site-preview');
	}else if(action && action == "close"){
		hideLayer('site-overall');
		hideLayer('edit-site-preview');
	}
}
//-->