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 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=550,height=500,resizable=yes,scrollbars=no');
 loadWin.window.location='chat.php';
}

var pID=1;

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

function showMovie(fil)
{ 

	var src = '<OBJECT ID="PlayerObjectEmbed" WIDTH="384" HEIGHT="357" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">'; 
	src += '<PARAM name="autoStart" value="true">';
	src += '<PARAM name="URL" value="' + fil  + '">';
	src += '<PARAM name="stretchToFit" value="true">';
	src += '<embed id="PlayerObjectEmbed" type="application/x-mplayer2" width="384" height="357"';
	src += 'src="' + fil  + '"';
	src += 'autostart="true"';
	src += 'showstatusbar="0"';
	src += 'clicktoplay="false"';
	src += 'autorewind="false"';
	src += 'stretchToFit="true"';
	src += 'url="' + fil  + '"';
	src += 'pluginspage="http://www.microsoft.com/Windows/MediaPlayer/">';
	src += '</embed>';
	src += '</OBJECT>';
					
	document.getElementById("imgdiv").innerHTML = src;					
}

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;
}   
   