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

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v9.0

	var posx = 0; 
	var posy = 0; 
	var e;
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) 
		with (document) 
			if (getElementById && ((obj=getElementById(args[i]))!=null)) 
			{ 
				v=args[i+2];
				
			    if (obj.style) 
				{ 
					obj=obj.style; 
					v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
				}
				
				e = args[i+4];
				
				if (!e) 
					e = window.event; 
				if (e.pageX || e.pageY){ 
					posx = e.pageX; 
					posy = e.pageY; 
				} 
				else if (e.clientX || e.clientY){ 
					posx = e.clientX + document.body.scrollLeft 
					+ document.documentElement.scrollLeft; 
					posy = e.clientY + document.body.scrollTop 
					+ document.documentElement.scrollTop; 
				}
	
			    obj.visibility=v; 
				obj.left= (posx) +"px";
				obj.top= (posy+5) +"px";
				document.getElementById("info-program").innerHTML  = args[i+3];
			}
}

function oppna2(){
 loadWin = window.open('','','width=650,height=800,resizable=no,scrollbars=no');
 loadWin.window.location='addsite.php?add=1';
}

function oppna_chat(){
 loadWin = window.open('','','width=560,height=600,resizable=yes,scrollbars=no');
 loadWin.window.location='chat.php';
}

var pID=1;

function showImage(img) 
{
	document.getElementById('imgdiv').innerHTML = '<img src="' + img + '" name="imgBild" border="0">';
}


function playMovie(file)
{
  var s1 = new SWFObject('./player.swf', 'playlist', '352', '326', '7');
	  s1.addParam('allowfullscreen',     'true');
	  s1.addVariable('width',            '352');
	  s1.addVariable('height',           '326');
	  s1.addVariable('displayheight',    '326');
	  s1.addVariable('file',              file);
	  s1.addVariable('overstretch',      'false'); // expands to fit h or v  "false" -will stretch them to fit
	  s1.addVariable('showdigits',       'true');
	  s1.addVariable('autostart',        'true');
	  s1.addVariable('shuffle',          'false');
	  s1.addVariable('repeat',           'list');
	  s1.addVariable('showicons',        'true');
	  s1.addVariable('thumbsinplaylist', 'true');
	  s1.addVariable('logo',             '');
	  s1.addVariable('backcolor',        '0xFFFFFF'); // face of buttons
	  s1.addVariable('frontcolor',       '0x404040'); // button symbols & playlist text
	  s1.addVariable('lightcolor',       '0x808080'); // highlighted playlist item
	  s1.addVariable('screencolor',      '0x000000'); // screen background color
	  s1.write('player');
};


function showMovie(fil)
{
   document.getElementById("imgdiv").innerHTML = '<div id=\"player\"></div>';	
   playMovie(fil);
}

function toPhone(i)
{
	loadWin = window.open('','','width=380,height=450,resizable=no,scrollbars=auto');
	loadWin.window.location='send_to_phone.php?i=' + i + '&p=' + pID;
}

function report_image(i)
{
	loadWin = window.open('','','width=420,height=250,resizable=no,scrollbars=auto');
	loadWin.window.location='report_image.php?id=' + i;
}

function loadlogo(form,c) {
  var url = form.list.options[form.list.selectedIndex].value;
  if (url != "") location.href = 'mobile.php?videopage=1&videocat=' + c +'&page=1&cat=' + url;
  return false;
}

function loadvideo(form,c) {
  var url = form.listvideo.options[form.listvideo.selectedIndex].value;
  if (url != "") location.href = 'mobile.php?page=1&cat=' + c + '&videopage=1&videocat=' + url;
  return false;
}

function get_mobile_content(url)
{
	loadWin = window.open('','','width=420,height=250,resizable=no,scrollbars=auto');
	loadWin.window.location= 'mobile_clickcount.php?url=' + url;
}

function SetAll(obj)
{
	var checked = false;
	if(obj.elements["cheAll"].checked)
		checked=true;
	
	var che = obj.elements["che[]"];
	for(i=0;i<che.length;i++)
	{
		che[i].checked=checked;
	}
}

   var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
			var result = http_request.responseText.split('||');
            document.getElementById('messages').innerHTML = result[0];
			document.getElementById('messsinbox').innerHTML = result[1];
			document.getElementById('messsaved').innerHTML = result[2];
			document.getElementById('messsent').innerHTML = result[3];
			document.getElementById('messtrash').innerHTML = result[4];
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function removeMessages(obj,page, folder) {
	var che = obj.elements["che[]"];
	var poststr = "";
	if(!che.length)
	{
		poststr = document.getElementById('che[]').value+',';
		alert(poststr);
	}
	else
	{
		for(i=0;i<che.length;i++)
		{
			if(che[i].checked)
			 poststr += che[i].value + ',';		 
		}	
	}
	
	poststr = "mess=" + encodeURI( poststr ) + "&page=" + page + "&folder=" + folder ;
	 
	 document.getElementById('removelinkdiv1').innerHTML = '<div align="center"><img src="images/loading.gif" border="0" height="32" width="32"></div>';
	 document.getElementById('removelinkdiv2').innerHTML = '<div align="center"><img src="images/loading.gif" border="0" height="32" width="32"></div>';
     makePOSTRequest('remove_messages.php', poststr);
   }
   
function WebCamPage(page)
{
	document.getElementById('webcam_div').innerHTML = '<div id="loadingdiv"><center><img src="images/ajax-loader.gif"></center></div>'; 
	var start = new Date();
	var url = "cams.php?page=" + page + "&t=" + start.getTime(); 		
	var myAjax = new Ajax.Request(url,{
		method: 'get',
		onComplete:function(transport)
		{ 
			document.getElementById('webcam_div').innerHTML = transport.responseText; 
		}
	});
	return false;
}  

function emoticon(text) {
    var txtarea = document.post.reply_post;
    text = ' ' + text + ' ';
    if (txtarea.createTextRange && txtarea.caretPos) {
        var caretPos = txtarea.caretPos;
        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
        txtarea.focus();
    } else {
        txtarea.value  += text;
        txtarea.focus();
    }
} 

function showLoginState(state)
{
   if(state==0)
   {
      var login  = "<div class=\"textfieldTitle\"><img src=\"images/text-field-title.gif\" alt=\"SnyggastNaken\" /></div>";
      login += "<form method=\"post\" action=\"login.php\">";
      login += "<input type=\"hidden\" name=\"login\" value=\"login\">";
      login += "<div><input name=\"UN\" type=\"text\" class=\"textfield\" /></div>";
      login += "<div><input name=\"PW\" type=\"password\" class=\"textfield\" /></div>";
      login += "<div class=\"SubBut\"><input type=\"image\" src=\"images/submit-but.gif\" alt=\"Logga in\" border=\"0\" title=\"Logga in\" /></div>";
      login += "<div class=\"SubBut\"><a href=\"lostpassword.php\" class=\"link01\">Glömt lösenord? >></a></div>";
      login += "</form>";	
      document.getElementById("LoginBox").innerHTML = login;
   }
   else
   {
      document.getElementById("LoginBox").innerHTML = '';
   }
}
   
