


function showasoffline(state,ismember) {


	if (!ismember) {
		payedfeature('Det kræver plus profil at blive vist som offline');
		return false;
	}

	// Clear status
	statusMsg();	
	$.get('/xsite/ajax.php?action=showasoffline&state=' + state,
        function(data) {
					var msg;
					if (data==1) {
						$('#a-showasoffline').html('Offline<span style="color:#a00">&nbsp;&#9679;</span>');
						$('#a-showasoffline')[0].onclick = function () { showasoffline(0,ismember); return false; };
						$('#a-showasoffline').parents('li')[0].style.background='#e88';
						msg="Du står nu som offline";
					} else {
						$('#a-showasoffline').html('Online<span style="color:#0a0">&nbsp;&#9679;</span>');
						$('#a-showasoffline')[0].onclick = function () { showasoffline(1,ismember); return false; };
						$('#a-showasoffline').parents('li')[0].style.background='#8e8'; 
						msg="Du står nu som online";
					}
					statusMsg(msg);
					// setTimeout( function() { statusMsg(); }, 10000);
        });

}

function payedonly(state) {


	// Clear status
	statusMsg();	
	$.get('/xsite/ajax.php?action=payedonly&state=' + state,
        function(data) {
					var msg;
					if (data==1) {
						$('#a-payedonly').html('Kontakt fra: Kun plus');
						$('#a-payedonly')[0].onclick = function () { payedonly(0); return false; };
						$('#a-payedonly').parents('li').addClass('enable').removeClass('disable');
						msg="Nu kan kun plus profiler og dine favoritter kontakte dig. <br/>Har du skrevet til en uden plus profil, kan vedkommende stadigvæk sende svar.";
					} else {
						$('#a-payedonly').html('Kontakt fra: Alle');
						$('#a-payedonly')[0].onclick = function () { payedonly(1); return false; };
						$('#a-payedonly').parents('li').addClass('disable').removeClass('enable');
						msg="Nu kan profiler uden plus kontakte dig.";
					}
					statusMsg(msg);
					// setTimeout( function() { statusMsg(); }, 10000);
        });

}


function payedfeature(msg) {

	var paymsglink = '<a href="/xsite/?p=payCentral" class="hover ga">Klik her for at købe</a>';
	statusMsg();
	statusMsg (msg);
	statusMsg (paymsglink);

}

function statusMsg(msg) {


	if (msg) {
		$('#statusMsgCont').slideDown('fast');

	} else {
		// $('#statusMsg').text('');
		$('#statusMsgCont').slideUp('fast');
		$('#statusMsg').html('');
		msg = '';
	}
		
	$('#statusMsg').append( '<p>' + msg + '</p>');
}

function notification(msg) {
	msg += '<br/><br/><br/><a href="#" class="hover button" onclick="$(\'#newMsgCont\').slideUp(\'slow\');return false"> Luk </a>';

  // msg += '<title>Ny besked...</title>';
	$("#newMsg").html(msg);
	$("#newMsgCont")[0].style.zIndex = "999";
	$("#newMsg")[0].style.background = "#ace";
	$("#newMsgCont")[0].style.position = "absolute";
	$("#newMsgCont")[0].style.top = (document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px";
	$("#newMsgCont")[0].style.left = "0px";
	
	// $("#newMsgCont").show(1000);
	$("#newMsgCont")[0].style.float = "right";
	$("#newMsgCont").slideDown(1000);
	
	//setTimeOut ("document.title='new message';",3000);
	document.title='Ny besked!';

	setTimeout ( function() { document.title = '....'; }, 4000);
	setTimeout ( function() { document.title = 'Ny besked!' }, 6000);

}

function toggle(id,display) {
      elid = document.getElementById(id);
			if (!elid) { return false; }
			if (display == null) {
      	elid.style.display=elid.style.display == 'none' ? 'block' : 'none';
			} else {
      	elid.style.display=display ? 'block' : 'none';
			}
      return false;
    }

function profilepicon(url) {
  p_scrollTop = document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
  if (p_scrollTop < 105) { p_scrollTop = p_scrollTop + (105 - p_scrollTop); }
  document.getElementById('profileIMGDIV').style.top=p_scrollTop + "px";
  document.getElementById('profileIMGDIV').style.display='block';
  document.getElementById('profileIMG').src="http://pics1.xklub.dk/img/loading.gif";
  document.getElementById('profileIMG').src=url;
}

function profilepicoff() {
  document.getElementById('profileIMGDIV').style.display='none';
  document.getElementById('profileIMG').src='http://pics1.xklub.dk/img/loading.gif';
  // document.getElementById('profileIMG').src='http://';
}

function popup(url) {
  popupwin = window.open (url,'_blank','fullscreen=no,toolbar=no,status=yes,menubar=no,scrollbars=yes, resizable=yes,directories=no,location=no');
}

function gourl(url) {
	document.location = url;
	return false;
}

function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit) // if too long...trim it!
  field.value = field.value.substring(0, maxlimit);
  // otherwise, update 'characters left' counter
  else
  countfield.value = maxlimit - field.value.length;
}

function poppic(picid) {
	window.open('http://' + picid + '.foto.xklub.dk','xkpic','width=790, height=720, fullscreen=no,toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,directories=no,location=no');
}

function popprofile(profileid) {
	window.open('http://xklub.dk/?po=showProfile&profileID=' + profileid,'xkprofile','width=790, height=720, fullscreen=no,toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,directories=no,location=no');
}

function findPos(obj) {
  var fcurleft = fcurtop = 0;
  if (obj.offsetParent) {
    fcurleft = obj.offsetLeft
    fcurtop = obj.offsetTop
	  while (obj = obj.offsetParent) {
      fcurleft += obj.offsetLeft
      fcurtop += obj.offsetTop
    }
  }

  return [fcurleft,fcurtop];
}

function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
