// es muss immer als erster Parameter die Sid und als zweiter der referer übergeben werden (bzw. sowerden sie beim Aufruf immer übergeben -> also muss die Funktion dementsprechend so aufgebaut sein)

function openAVSPlayer()
{
  F1 = window.open('../chataccounts/avsPlayer/avsPlayer.php?kundennummer=<?=$kundenid;?>', 'Avs_Player', 'toolbar=no,scrollbars=no,resizable=no,width=500,height=500,screenX=100,screenY=100,left=100,top=100');
  F1.focus();
}

// öffnet webmaster-area in popup
function open_wmarea(sid, hostname)
{
  F1 = window.open('http://' + hostname + '/?sid=' + sid, 'WM_Area', 'toolbar=no,scrollbars=yes,resizable=yes,width=956,height=835,screenX=50,screenY=50,left=50,top=50');
  F1.focus();
}


function open_senderreg(sid, referer)
{
  F1 = window.open('/sender/registrierung/index.php?sid=' + sid + '&referer=' + referer, 'Sender_Registration', 'toolbar=no,scrollbars=yes,resizable=no,width=500,height=550,screenX=100,screenY=100,left=100,top=100');
  F1.focus();
}

function open_senderarea(sid, referer)
{
  F1 = window.open('/sender/senderarea/login/index.php?sid=' + sid + '&referer=' + referer, 'Sender_Area', 'toolbar=no,scrollbars=yes,resizable=no,width=900,height=600,screenX=100,screenY=100,left=100,top=100');
  F1.focus();
}

function closeMainpeanChat()
{  
  parent.parent.location.href = "http://www.flirtfriends.net/?referer=170";	
}

function layer_hide(id)
{
	document.getElementById(id).style.visibility="hidden";
}

// wenn chat bzw. livevorschau als popup genutzt werden soll:
function goToChat(sid, referer, steckbriefid, modus)
{
	F1 = window.open('/memberbereich/chat/chat.php?sid=' + sid + '&referer=' + referer + '&steckbriefid=' + steckbriefid + '&' + modus, 'Chat', 'toolbar=no,scrollbars=auto,resizable=yes,width=650,height=700,screenX=100,screenY=100,left=100,top=100');
    F1.focus();	
}

function goToLivevorschau(sid, referer, steckbriefid)
{
	F1 = window.open('/spezial_cams/comm/livescreen/livescreen_start.php?sid=' + sid + '&referer=' + referer + '&steckbriefid=' + steckbriefid, 'Chat', 'toolbar=no,scrollbars=no,resizable=no,width=400,height=400,screenX=100,screenY=100,left=100,top=100');
    F1.focus();	
}

function openFirewallHelp(sid, referer)
{
	F1 = window.open('/platform/docs/Firewall-FreischaltungWindowsXP.pdf', 'FirewallHelp', 'toolbar=no,scrollbars=yes,resizable=no,width=800,height=600,screenX=100,screenY=100,left=100,top=100');
    F1.focus();	
}

function openWindow(url, hoehe, breite)
{
	F1 = window.open(url, 'F1', 'toolbar=no,scrollbars=yes,resizable=no,width='+ breite +',height='+ hoehe +',screenX=100,screenY=100,left=100,top=100');
    F1.focus();	
}

function openWindow_NoScrolling(url, hoehe, breite)
{
	F1 = window.open(url, 'F1', 'toolbar=no,scrollbars=no,resizable=no,width='+ breite +',height='+ hoehe +',screenX=100,screenY=100,left=100,top=100');
    F1.focus();	
}

function openProfileHelp(sid, referer, hoehe, breite)
{
	F1 = window.open('sender_steckbrief_help.php?sid=' + sid + '&referer=' + referer, 'F1', 'toolbar=no,scrollbars=auto,resizable=no,width='+ breite +',height='+ hoehe +',screenX=100,screenY=100,left=100,top=100');
    F1.focus();	
}

function getLayerRef ( /* String */ id, /* optional HTML-Object */ document) 
{
	  if (!document)
		document = window.document;
	
	  if (document.layers) {
		for (var l = 0; l < document.layers.length; l++)
		  if (document.layers[l].id == id)
			return document.layers[l];
		for (var l = 0; l < document.layers.length; l++) {
		  var result = getLayerRef(id, document.layers[l].document);
		  if (result)
			return result;
		}
		return null;
	  } else if (document.all) {
		return document.all[id];
	  } else if (document.getElementById) {
		return document.getElementById(id);
	  }
}

/**
 * Konstruktorfunktion des Objektes
 * Die Parameter der Funktion können weggelassen werden, 
 * nicht vorhanden Werte werden mit 0 initialisiert
 *
 * @param    x: x-Wert (numerischer Wert erwartet, isNaN(x) == false)
 *           y: y-Wert (numerischer Wert erwartet, isNaN(y) == false)
 * @methods  toString()
 *           equals( Coord aCoord )
 */

function Coord(/*in: Number*/ x, /*in: Number*/ y)
{
	  this.x = (!x)?0:x;
	  this.y = (!y)?0:y;
	  
	  this.toString = objToString;
	  this.equals = equalsCoord;
}

/**
 * liefert eine Stringrepräsentation des Objektes Coord
 * einschießlich seiner Daten, 
 * ausschließlich seiner Methoden 
 * 
 * @return: String
 */ 
function objToString()
{
	  var ret = "{";
	  for(p in this ){
		if (typeof this[p] == "function" || typeof this[p] == "object") 
		  continue;
		if(ret.length > 1)
		  ret += ",";
		ret += p + ":" + this[p];
	  }
	  return ret + "}";
}

/**
 * vergleicht 2 Coord-Objekte. Diese sind genau dann gleich,
 * wenn seine x- und y-Eigenschaften gleiche Werte enthalten.
 * 
 * @return: boolean (true, false)
 */ 
function equalsCoord(/*in: Coord*/ c){
  return (this.x == c.x && this.y == c.y);
}						

function getMouseXY(ev) 
{
  var pos = new Coord(0,0);
  if(ev.pageX){
	pos.x = ev.pageX;	
	pos.y = ev.pageY;
  } else if(window.event && window.event.clientX) {
	var isStrictMode = document.compatMode 
		&& document.compatMode != 'BackCompat' ? true : false;
	var scrollX = isStrictMode ? 
		document.documentElement.scrollLeft : document.body.scrollLeft;
	var scrollY	= isStrictMode ? 
		document.documentElement.scrollTop : document.body.scrollTop;
	pos.x = window.event.clientX + scrollX;
	pos.y = window.event.clientY + scrollY;
  }
  return pos;
}

/* Initialisierung der Mausueberwachung */
function MouseInit()
{
	/* MSIE, Konqueror, Opera : */
	  if (document.all)
		window.onmousemove=MouseMove;
		
	/* Netscape, Mozilla : */
	  else
	  {
	
	/* Netscape6, Mozilla : */
		if (typeof(document.addEventListener)=="function")
		  document.addEventListener("mousemove",MouseMove,true);
	
	/* Netscape4 : */
		else
		{
		  window.captureEvents(Event.MOUSEMOVE);
		  window.onmousemove=MouseMove;
		}
	  }
}

function getvideo(sid, referer, video, steckbriefid,geschl) 
{
 	var oben = (screen.height/2)-320;
	var links = (screen.width/2)-219;
	window.open('/memberbereich/video/video_details.php?sid='+sid+'&referer='+referer+'&video='+video+'&geschl='+geschl+'&steckbriefid='+steckbriefid,'_blank','width=488,height=590, top='+oben+'. left='+links+', resizable=no, scrollbars=no');
}


/*
function open_support(sid, referer)
{
  F1 = window.open('/platform/support.php?sid=' + sid + '&referer=' + referer, 'Support', 'toolbar=no,scrollbars=no,resizable=no,width=500,height=450,screenX=100,screenY=100,left=100,top=100');
  F1.focus();
}

function open_impressum(sid, referer)
{
  F1 = window.open('/platform/impressum.php?sid=' + sid + '&referer=' + referer, 'Impressum', 'toolbar=no,scrollbars=no,resizable=no,width=500,height=600,screenX=100,screenY=100,left=100,top=100');
  F1.focus();
}

function open_faq(sid, referer)
{
  F1 = window.open('/platform/faq_index.php?sid=' + sid + '&referer=' + referer, 'Impressum', 'toolbar=no,scrollbars=no,resizable=no,width=500,height=500,screenX=100,screenY=100,left=100,top=100');
  F1.focus();
}
*/



try 
{
  var in_frame_Y = parent.document.getElementById("mainframe");
  
  in_frame_Y.height = 2000;
} 
catch (e) 
{
  var in_frame_Y = false;
}



function iframeSize()  
{
	  var container = document.getElementById("container");

	  if(in_frame_Y && container) 
	  {    		  
		   px = container.style.height.replace("px", "");		
		   
		   in_frame_Y.height = parseInt(px) + 300;
	  }
}


var ajaxInterpret;
// Ajax-Request senden
function setAjaxRequest(url, interpret) {
	// Request erzeugen
	if (window.XMLHttpRequest) {
		request = new XMLHttpRequest(); // Mozilla, Safari, Opera
	} else if (window.ActiveXObject) {
		try {
			request = new ActiveXObject('Msxml2.XMLHTTP'); // IE 5
		} catch (e) {
			try {
				request = new ActiveXObject('Microsoft.XMLHTTP'); // IE 6
			} catch (e) {}
		}
	}

	// überprüfen, ob Request erzeugt wurde
	if (!request) {
		return false;
	} else {
		//var url = "meinPhpScript.php";
		// Request öffnen	
		request.open('post', url, true);
		// Request senden
		request.send(null);
		// Request auswerten
		ajaxInterpret = interpret;
		request.onreadystatechange = interpretAjaxRequest;
	}
}

// Ajax-Request auswerten
function interpretAjaxRequest() {
	
	switch (request.readyState) {
		// wenn der readyState 4 und der request.status 200 ist, dann ist alles korrekt gelaufen
		case 4:
			if (request.status != 200) {
				return false;
			} else {
				var content = request.responseText;
				
				if(ajaxInterpret == 'contentTimeCheck')
				{
					if(content == 'false')
					{
						ErrorRedir997();
					}
					
				}
				  
			}
			break;
		default:
			break;
	}
}

function imgZoom(img ,width , height,  time , margin , i)
{
	faktor = 5;
	i = i *4.9;
	setTimeout(function() {
		
		//var pfad = "http://flirtfriends.net/bilder/vc/fsk16/weiblich/27282/vorschau/27282_vorschau.jpg";
		
		var pfad = img.src;
		var neu = pfad.split("fsk16");
		var rest = neu[1].split("/")
		
		var bild = neu[0] + "fsk16" + "/" + rest[1] + "/" + rest[2] + "/" + rest[2] + "_1.jpg"

		var check = new Image();
		
		check.src = bild;
		
		if(check.complete == false)
		{
			 bild = neu[0] + "fsk16" + "/" + rest[1] + "/" + rest[2] + "/" + rest[2] + "_2.jpg"
		}

		img.src = bild;
		img.width = width;
		img.height = height;
		img.style.position = "absolute";
		
		if(margin == 1)
		{
			img.style.margin = '0px 0 0 '+(-width*i /40)+'px';
		}
		
		
	}, time);
}



function setZoom(img , time)
{
	width = 412;
	height = 312;

	var coord = getCoords(img);
	var margin = 0;
	var breite = getBreite();
	
	//if(coord.x + "+" + window.innerWidth
	//alert(coord.x + "+" + window.innerWidth);
	if((breite - coord.x) <= 200)
	{
		margin = 1;
	}
	
	for(var i = 0; i <= 5; i++)
	{
		new_width = (width*(10+i))/20;
   		new_height = (height*(10+i))/20;

		imgZoom(img , new_width , new_height , (20*i) , margin ,i);
	}
}

function setzZoom(img , time , org_width , org_height)
{
	width = 412;
	height = 312;

	for(var i = 5; i >= 0; i--)
	{
		new_width = (width*(10+i))/20;
   		new_height = (height*(10+i))/20;

		imgZoom(img , new_width , new_height , 20* (5-i));
	}

	setTimeout(function() {
		img.width = org_width;
		img.height = org_height;
		img.style.position = "";
		img.style.margin = "0 0 0 0";
	}
	, 20* (5-i));
}

function getCoords(eo)
{
	if(eo){
		var coords = {x: 0, y: 0};
		var i = 0;
		var eo_original = eo;
		do {
			i++;
			if(eo.currentStyle){
				if(eo.currentStyle.position!='relative'){
					coords.x += eo.offsetLeft;
					coords.y += eo.offsetTop;
				}
			} else {
				coords.x += eo.offsetLeft;
				coords.y += eo.offsetTop;
			}
			eo = eo.offsetParent;
		} while(eo);

	return coords;
	
	} else {
		return null;
	}
}

function getBreite()
{
	var breite;
	
	 if (window.innerWidth) {
	 	
	  	breite = window.innerWidth;

	 }
	
	 else if (document.body.clientWidth) 
	 {
	   breite = document.body.clientWidth;
	}
	
	return breite;
}

function checkNav()
{
 /*	try
	{
		if(parent.frames.length == 0 || parent.frames.name == "main1" || parent.frames[0].name == "nav" || this.frames.name != "mainframe")
		{
			
			
		}
		else
		{
			var el = document.getElementById("membernav");
			
			if(el != null || el != undefined)
			{
				el.style.display = "none";
			}
		}
	}
	catch(err)
	{
		return true;
	}
	*/
	return true;
}
