
var popupLinkConfig = new Array;

popupLinkConfig["vrPop"] = new Array ( "vrHelp", "width=400,height=400,scrollbar=no,menubar=no,resizable=not" );
popupLinkConfig["goldChatPop"] = new Array ( "goldChatroom", "width=640,height=480,scrollbar=no,menubar=no,resizable=yes" );
popupLinkConfig["stdChatPop"] = new Array ( "stdChatroom", "width=600,height=400,scrollbar=no,menubar=no,resizable=not" );

function initPage() {
  initPopupLinks();
  externalLinks();
	
	if (typeof document.attachEvent!='undefined') {
		init();
		document.attachEvent('onmousemove',moveMouse);
		document.attachEvent('onclick',checkMove); }
	else {
		init();
		document.addEventListener('mousemove',moveMouse,false);
		document.addEventListener('click',checkMove,false);
	}
}
/*
// Holla stuff
var holla_number = 12;
var holla_timer = null;
var holla_color = 0;
var holla_fade_dir = 0;

var hollaAdminColor = new Array(holla_number);
hollaAdminColor[0]="#000000";
hollaAdminColor[1]="#111111";
hollaAdminColor[2]="#222222";
hollaAdminColor[3]="#333333";
hollaAdminColor[4]="#444444";
hollaAdminColor[5]="#555555";
hollaAdminColor[6]="#666666";
hollaAdminColor[7]="#777777";
hollaAdminColor[8]="#888888";
hollaAdminColor[9]="#999999";
hollaAdminColor[10]="#aaaaaa";
hollaAdminColor[11]="#bbbbbb";
hollaAdminColor[12]="#cccccc";
hollaAdminColor[13]="#dddddd";

var hollaUserColor = new Array(holla_number);
hollaUserColor[0]="#FF0410";
hollaUserColor[1]="#FF1421";
hollaUserColor[2]="#FF2831";
hollaUserColor[3]="#FF3842";
hollaUserColor[4]="#FF4D52";
hollaUserColor[5]="#FF5D63";
hollaUserColor[6]="#FF7173";
hollaUserColor[7]="#FF828C";
hollaUserColor[8]="#FF929C";
hollaUserColor[9]="#FFA6AD";
hollaUserColor[10]="#FFB6BD";
hollaUserColor[11]="#FFCBCE";
hollaUserColor[12]="#FFDBDE";
hollaUserColor[13]="#FFEFEF";

function changeHollaColor(hollaType) {
	clearTimeout( holla_timer );
	if (holla_fade_dir == 0) {
		holla_color = holla_color + 1
	} else {
		holla_color = holla_color - 1;
	}
	
	if( hollaType == 'ADMIN' ) { document.getElementById('hollaBox').style.color = hollaAdminColor[holla_color]; }
	if( hollaType == 'USER' ) { document.getElementById('hollaBox').style.color = hollaUserColor[holla_color]; }
	
	var a = document.getElementById('hollaBox').getElementsByTagName("A");
	for(var i=0;i<a.length;i++){
		if( hollaType == 'ADMIN' ) { a[i].style.color = hollaAdminColor[holla_color]; }
		if( hollaType == 'USER' ) { a[i].style.color = hollaUserColor[holla_color]; }
	}
	if (holla_color == 13) { holla_fade_dir = 1; }
	if (holla_color == 0) { holla_fade_dir = 0; }
	if (holla_color == 0) { 
		holla_timer = setTimeout("changeHollaColor('"+hollaType+"')", 5000);
	} else {
		holla_timer = setTimeout("changeHollaColor('"+hollaType+"')", 100);
	}
}
*/
function initHolla(hollaType) {
	if( hollaType == 'ADMIN' ) { document.getElementById('hollaBox').style.color = hollaAdminColor[holla_color]; }
	if( hollaType == 'USER' ) { document.getElementById('hollaBox').style.color = hollaUserColor[holla_color]; }
	
	var a = document.getElementById('hollaBox').getElementsByTagName("A");
	for(var i=0;i<a.length;i++){
		if( hollaType == 'ADMIN' ) { a[i].style.color = "#000000"; }
		if( hollaType == 'USER' ) { a[i].style.color = "#000000"; }
	}
	holla_timer = setTimeout("changeHollaColor('"+hollaType+"')", 5000);
}
// End Holla stuff

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function clearField( e, str ) {
	if( e.value == str ) { e.value = ''; }
}

function initPopupLinks() {
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++) 
  {
    if (((pageLinks[i].className != null) && 
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) && 
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig) 
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp() {
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
} 


function chatPop__() {
	window.open( "http://www.amourmaghreb.com/userplane/chatroom/wc.php", "UserplaneChatWindow", "width=640,height=480,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=1" );
}
function guestChatPop() {
	var username = document.getElementById('chatUser').value;
	if( username == '' ) {
		alert( 'You have not entered a username' );
	} else {
		window.open( "http://www.amourmaghreb.com/userplane/chatroom/pu.php?username="+username, "UserplaneChatWindow", "width=728,height=600,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=1" );
}
}
function chatPop() {
	window.open( "http://www.amourmaghreb.com/userplane/chatroom/pu.php", "UserplaneChatWindow", "width=728,height=600,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=1" );
}

/* IM STUFF */
function moveDiv(e,x,y) {
	var elem = document.getElementById( e );
	elem.style.top = x;
	elem.style.left = y;
}

function centerDiv(e,width,height) {

	var windowWidth = 0;
	var windowHeight = 0;
	var layerOffset = 0;
	
	windowWidth = window.innerWidth;
	windowHeight = window.innerHeight;
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	
	//if (window.pageYOffset) {
	//	layerOffset = window.pageYOffset;
	//}
	//if (document.body && document.body.scrollTop) {
	//	layerOffset = document.body.scrollTop;
	//}
	
	if (document.documentElement && document.documentElement.scrollTop) {
		layerOffset = document.documentElement.scrollTop;
	} else if (document.body) {
		layerOffset = document.body.scrollTop
	} else {
	}
	
	var sx = (windowWidth / 2) - (width / 2);
	var sy = (windowHeight / 2) - (height / 2) + layerOffset;	
	
	var el = new getObj(e);
	el.style.left = sx+"px";
	el.style.top = sy+"px";
}
/* END IM STUFF */

function hideNoti(e) {
	var el = new getObj(e);
	el.style.top = "-1000px";
}

/* DHTML STUFF */
function getObj(name) {
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

/* BUDDY STUFF */
function showBuddyList() {
	var el = new getObj('buddyCont');
	el.obj.className = "shown";
	
	var el = new getObj('buddyLink');
	el.obj.innerHTML = '>> <a href="#" onclick="hideBuddyList();return false;">Cacher ma liste</a>';
}
function hideBuddyList() {
	var el = new getObj('buddyCont');
	el.obj.className = "hidden";
	
	var el = new getObj('buddyLink');
	el.obj.innerHTML = '>> <a href="#" onclick="showBuddyList();return false;">Voir ma liste d\'amis</a>';
}

/* FLIRT'01 STUFF */
function whosGoingPop() {
	window.open( "flirt01-whosGoing.php", "WhosGoingPop", "width=640,height=480,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=1,resizable=1" );
}

/* ORIGINAL IMAGE STUFF */
function originalImage(origImage,origWidth,origHeight) {
	if( origWidth > 400 || origHeight > 400 ) {
		ratio = origWidth / 400;
		newx = 400;
    newy = origHeight / ratio;
		origWidth = newx;
		origHeight = newy;
	}
 
	oImage = new getObj('originalImage');
	oImage.style.width = origWidth+'px';
	oImage.style.height = origHeight+'px';
	oImage.obj.innerHTML = "<a href=\"#\" onclick=\"hideOriginalImage(); return false;\"><img src=\""+origImage+"\" width=\""+origWidth+"\" height=\""+origHeight+"\" border=\"0\"></a><div><a href=\"#\" onclick=\"hideOriginalImage(); return false;\">fermer</a></div>";
	centerDiv('originalImage',origWidth,origHeight);
	
	var selects = document.getElementsByTagName("SELECT");
	for(var i=0;i<selects.length;i++){
		selects[i].style.display = 'none';
	}
}
function hideOriginalImage() {
	oImage = new getObj('originalImage');
	oImage.style.top = "-1000px";
	oImage.style.left = "-1000px";
	
	var selects = document.getElementsByTagName("SELECT");
	for(var i=0;i<selects.length;i++){
		selects[i].style.display = 'inline';
	}
}

function openVR() {
	var popupVR = null;
	popupVR = window.open( "profile-recordVideo.php", "vr", "width=660,height=416,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=1,resizable=1" );
}


window.onload = initPage;
