function PremiumInfoAlert()
{
	if(confirm("Denna funktion kräver att du är Premium!\nVill du veta mer om hur du blir premiummedlem?"))
		window.location.href="/payments/defaultPayment.aspx";
}
function LoadBlog(param)
{
	var obj = document.getElementById(param);
	var val = obj.options[obj.selectedIndex].value;
	if(val!="0")
		window.location.href = "blogg.aspx?BlogId="+ val;
}

function DelConfirm()
{
	if(confirm("Är du verkligen säker på att du vill radera bloggen\noch eventuellt alla gamla dagboksinlägg som kan finnas i den här bloggen?"))
	{
		var obj = document.getElementById("DelInput");
		obj.value = "1";
		document.forms[0].submit();
	}
}
function OpenHide(id,obj,openName,closedName)
{
	var div = document.getElementById(id);
	if(div.className == openName)
	{
		div.className = closedName;
	}
	else
	{
		div.className = openName;
	}
}

function PopBlipomat(pDesination, pName){
	var tLoad = '';
	var tName = 'BlipWindow';

	if(pDesination != null){
		tLoad = arguments[0];
	}
	
	if(pName != null){
		tName = pName;
	}
						
	tWindow = window.open('/blipomat/blipomat_frameset.aspx?load=' + tLoad, tName, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=648,height=536');
	if (window.focus){
		tWindow.focus();
	}		
}

function popRadio(){
				eval(window.open('/radio/radio.html','BlipbeatRadio','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=648,height=536'));
}


function popNewMessage(){
	var pid = '';
	var type = '';
	var data = '';
	if(arguments[0]){
		pid = arguments[0];
	}
	if(arguments[1]){
		type = arguments[1];
	}
	if(arguments[2]){
		data = arguments[2];
	}
	tWindow = window.open('/blipomat/Blipomat_Mail.aspx?new=1&pop=1&user=' + pid + '&type=' + type + '&data=' + escape(data) + '&rnd=' + escape(Math.random(999999)), '_blank', 'location=0,toolbar=0,width=601,height=506,resizable=yes');
	if (window.focus){
		tWindow.focus();
	}
}

function AvatarPopup(){
	var userid = '';
	var avatar = '';
	var image = '';
	var gender = '';
	if(arguments[0]){
		userid = arguments[0];
	}
	
	if(arguments[1]){
		avatar = arguments[1];
	}
	
	if(arguments[2]){
		image = arguments[2];
	}
	
	if(arguments[3]){
		gender = arguments[3];
	}
	
	var url = '/member/AvatarPopup.aspx?userid=' + userid + '&avatar=' + avatar + '&image=' + image + '&gender=' + gender;
	
	tWindow = window.open(url, '_blank', 'location=0,toolbar=0,status=0,width=100,height=120,resizable=yes');
	if (window.focus){
		tWindow.focus();
	}		
}

function PopFormattingCodes(){
	var tag = '';
	if(arguments[0]){
		tag = arguments[0];
	}
	tWindow = window.open('/taghelp.aspx?tag=' + tag, '_blank', 'location=0,toolbar=0,width=710,height=475,resizable=yes');	
	if (window.focus){
		tWindow.focus();
	}
}

function popBlock(){
	tWindow = window.open('/person_block.aspx?user=' + arguments[0] + '&rnd=' + escape(Math.random(999999)), '_blank', 'location=0,toolbar=0,width=320,height=350,resizable=yes');	
	if (window.focus){
		tWindow.focus();
	}
}

function PopImage(){
	tWindow = window.open('/global/Bild_Zoom.html?image=' + arguments[0], 'enlarge_window', 'width=100,height=100,location=0,toolbar=0,resizable=yes');
	if (window.focus){
		tWindow.focus();
	}
}

function enlargeImage(){
	var picid = arguments[0];
	var url = 'http://images.blip.se/mms/' + picid.substr(0, 3).toLowerCase() + '/' + picid.toLowerCase() + '.jpg';
	PopImage(url);
}

function enlargePresImage(){
	var picid = arguments[0];
	var url = 'http://images.blip.se/photo/_large/' + picid.substr(0, 3).toLowerCase() + '/' + picid.toLowerCase() + '.jpg';
	PopImage(url);
}

function LoadTopAdSpace(){
	if(!arguments[2]){
		return;
	}
	if(arguments[2] != 'overload'){
		return;
	}
	var ord = '';
	if(arguments[1]){
		if(arguments[1] != ''){
			ord = '&ord=' + arguments[1];
		}
	}
	if(top.frames){
		if(top.frames['BLIPnav']){
			if(top.frames['BLIPnav'].document.getElementById('ifAds')){
				if(top.frames['BLIPnav'].IsBig){
					top.frames['BLIPnav'].document.getElementById('ifAds').src = 'http://blip.se/visa/show_html.aspx?pageid=tv4_' + arguments[0] + ord + '&type=18&r=0&cityid=4&bgcolor=B5CFDE';
				}else{
					top.frames['BLIPnav'].document.getElementById('ifAds').src = 'http://blip.se/visa/show_html.aspx?pageid=tv4_' + arguments[0] + ord + '&type=1&r=0&cityid=4&bgcolor=B5CFDE';
				}
			}
		}
	}
}

function DoReplace(){
	var inData = arguments[0];
	var lookFor = arguments[1];
	var replaceWith = arguments[2];
	for(var i=0;i<20;i++){
		inData = inData.replace(lookFor, replaceWith);
	}
	return inData;
}

function LoadBlipFrame(){
	var gotFrames = false;
	var tUrl = '';
	if (top.frames){
		if (top.frames.BLIPnav){
			gotFrames = true;
		}
	}
	if(gotFrames){
		tUrl = top.location.href.toLowerCase();
	}
		
	var nUrl = DoReplace(location.href, '?', '!');
	var nUrl = DoReplace(nUrl, '&', '$');
	nUrl = DoReplace(nUrl, 'http://blip.se/', '/');
	if((tUrl.indexOf('.blip.se') > -1) || (tUrl.indexOf('http://blip.se') > -1)){
		if(top.location.href == location.href){
			top.location.href = '/?load=' + nUrl;
		}
	}else{
		top.location.href = '/?load=' + nUrl;
	}
}

function ZeroInit(data){
	if(data.length == 1){
		return '0' + data;
	}else{
		return data;
	}
}

function LoadRightFrame(){
	var cid = arguments[0];
	var aco = funcLibGetCookie('aco');
	if(parseInt(cid) != parseInt(aco) || arguments[1]){
		funcLibSetCookie('aco', cid);
		if(!arguments[1]){
			if(parent.frames.ads.location.href.indexOf('?cat=' + cid) == -1){
				parent.frames.ads.location.href = '/ads/adframe.html?cat=' + cid + '&rnd=' + escape(Math.random(999999));
				LoadTopAdSpace(cid, '', 'overload');
			}
		}
	}
}

function PresentationPrinter(Object, Text, Location, Speed, Type, Loop){
	if(Type == 100){
		Location--
	}else{
		Location++;
	}
	
	if(Location <= Text.length){
		if(Location <= Text.length){
			if(Type == 2){
				document.getElementById(Object).innerHTML = funcLibReplace(Text.substring(Text.length - Location), '¬', '<br />');
			}else{
				document.getElementById(Object).innerHTML = funcLibReplace(Text.substring(0, Location), '¬', '<br />');
			}
		}else{
			Location = 0;
			document.getElementById(Object).innerHTML = '';
		}
		if(Type == 100 && Location == 0){
			if(Loop == 1){
				setTimeout("PresentationPrinter('" + Object + "', '" + Text + "', 0, " + Speed + ", 1, " + Loop + ")", (Speed * 2));
				return;
			}else{
				return;
			}
		}
		setTimeout("PresentationPrinter('" + Object + "', '" + Text + "', " + Location + ", " + Speed + ", " + Type + ", " + Loop + ")", Speed);
	}else if(Type == 1){
		setTimeout("PresentationPrinter('" + Object + "', '" + Text + "', " + Location + ", " + Speed + ", " + 100 + ", " + Loop + ")", Speed);
	}else if(Type == 0){
		if(Loop == 1){
			setTimeout("PresentationPrinter('" + Object + "', '" + Text + "', -1, " + Speed + ", " + Type + ", " + Loop + ")", (Speed * 8));
		}
	}/*else if(Type == 2){
		setTimeout("PresentationPrinter('" + Object + "', '" + Text + "', 0, " + Speed + ", 200, " + Loop + ")", Speed);
	}*/
}


function ShowImage(url)
{
	PopImage(url);
}


function ShowMoblogFlash()
{
var tmp = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"137\" height=\"108\" id=\"swf/moblog\" align=\"middle\" VIEWASTEXT>";
	tmp += "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
	tmp += "<param name=\"movie\" value=\"swf/moblog.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"scale\" value=\"noscale\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"bgcolor\" value=\"#ffffff\" /><embed src=\"swf/moblog.swf\" quality=\"high\" scale=\"noscale\" wmode=\"transparent\" bgcolor=\"#ffffff\" width=\"137\" height=\"108\" name=\"swf/moblog\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
	tmp += "</object>";
	document.write(tmp);
}



function ajaxpage(url, containerid){
	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
		try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch (e){}
		}
	}
	else
		return false

	page_request.onreadystatechange=function(){
		loadpage(page_request, containerid)
	}
	
	page_request.open('GET', url, true)
	page_request.send(null)
}

function loadpage(page_request, containerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
		top.frames['bom_content'].document.getElementById(containerid).innerHTML=page_request.responseText
}

function replaceSmilies(s){	
	s = s.replace(/:\x29/g, "<img src='/elements/images/smileys/happy.gif' />");
	s = s.replace(/=\x29/g, "<img src='/elements/images/smileys/happy.gif' />");
	
	s = s.replace(/\x40 :-\3E/g, "<img src='/elements/images/smileys/innocent.gif' />");
	s = s.replace(/\x28A\x29/g, "<img src='/elements/images/smileys/innocent.gif' />");
	s = s.replace(/O :-\x29/g, "<img src='/elements/images/smileys/innocent.gif' />");
	
	s = s.replace(/\x3C(3)/g, "<img src='/elements/images/smileys/love.gif' />");
	
	s = s.replace(/:\x40/g, "<img src='/elements/images/smileys/mad.gif' />");
	s = s.replace(/=\x40/g, "<img src='/elements/images/smileys/mad.gif' />");
	
	s = s.replace(/:\x28/g, "<img src='/elements/images/smileys/sad.gif' />");
	s = s.replace(/=\x28/g, "<img src='/elements/images/smileys/sad.gif' />");
	
	s = s.replace(/=zzz/g, "<img src='/elements/images/smileys/sleep.gif' />");
	s = s.replace(/:zzz/g, "<img src='/elements/images/smileys/sleep.gif' />");
	
	s = s.replace(/;\x29/g, "<img src='/elements/images/smileys/winking.gif' />");
	s = s.replace(/;-\x29/g, "<img src='/elements/images/smileys/winking.gif' />");
	return s;
}