/**
* SAFEBOY SCRIPT 1.0
*/

var arg_sid = "";


var iedom=document.all||document.getElementById;
var total = new Array();
var current = new Array()
var clink = new Array()
var step = new Array();
var sm_conn = new Array();
var sm_last= new Array();
var sm_club= new Array();

function thisMovie(movieName) {
   if (navigator.appName.indexOf("Microsoft") != -1) { return window[movieName]; } else { return document[movieName]; }
}

function fixPNG(img) // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
	if (ie55up)
		 {
/*       http://homepage.ntlworld.com/bobosola/pnginfo.htm
*/
		 var strNewHTML = "<img src=/images/1010.gif align=absbottom border=0 width="+ img.width + " height=" + img.height
						+ " style=\"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
						+ "(src=\'" + img.src + "\', sizingMethod='image');\">"
		 img.outerHTML = strNewHTML

		 }
   }

window.saveNavigator = window.navigator;

navigator.OS    = '';
navigator.family  = '';

var platform;
if (typeof(window.navigator.platform) != 'undefined')
{
 platform = window.navigator.platform.toLowerCase();
 if (platform.indexOf('win') != -1)
   navigator.OS = 'win';
 else if (platform.indexOf('mac') != -1)
   navigator.OS = 'mac';
 else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
   navigator.OS = 'nix';
}

var i = 0;
var ua = window.navigator.userAgent.toLowerCase();

if (ua.indexOf('opera') != -1)
{
 navigator.family  = 'opera';
}
else if ((i = ua.indexOf('msie')) != -1)
{
 navigator.version  = parseFloat('0' + ua.substr(i+5), 10);
 if (navigator.version < 4)
   navigator.family = 'ie3';
 else
   navigator.family = 'ie4'
}
else if (ua.indexOf('gecko') != -1)
{
 navigator.family = 'gecko';
}
else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1))
{
 navigator.family = 'nn' + parseInt(navigator.appVersion);
}
else if ((i = ua.indexOf('aol')) != -1 )
{
 navigator.family  = 'aol';
}
else if ((i = ua.indexOf('hotjava')) != -1 )
{
 navigator.family  = 'hotjava';
}
// ****************************************************************** UPDATE LAYER
function upDate(text, lelayer) {
  switch(navigator.family) {
	case 'nn4':
		var lyr = document.layers[lelayer].document;
		lyr.open();
		lyr.write(text);
		lyr.close();
		break;
	case 'ie4':
		document.all[lelayer].innerHTML=text;
		break;
	case 'gecko':
		divel=document.getElementById(lelayer);
		divel.innerHTML=text;
		break;
  }
}

// ************************************* CHARGEMENT EXTERNES
this.scriptnum = 0;

function runScript(url) {
  scriptnum++;
  scriptid = "runscript" + scriptnum;
  /*
  var thescript=document.createElement('span');
  thescript.setAttribute('id',scriptid);
  thescript.innerHTML="<script type='text/javascript' src='"+url+"'><\/script>"
  */
  var thescript=document.createElement('script');
  thescript.setAttribute("defer", 'false');
  thescript.setAttribute('id',scriptid);
  thescript.setAttribute("type",'text/javascript');
  thescript.setAttribute('src',url);
  document.body.appendChild(thescript);
  setTimeout('removeObject("'+scriptid+'");',60000);
}

function removeObject(objid) {
  var obj = document.getElementById(objid);
  document.body.removeChild(obj);
}

   var foo = new Array();
   var galup = new Array();
   var radio_toreset = new Array();
   function m_step(thename, thestep) {
	  var the_file = window.eval(thename);
	  current[thename] += thestep;
	  if (current[thename]< 1) current[thename]=total[thename];
	  if (current[thename]>(total[thename])) current[thename]=1;
	  for (i=0; i<step[thename]; i++) {
			  j = ( (current[thename]+i)%total[thename] ) ;
			  uid = the_file[j][0];
			  clink[thename][i] = uid;
			  //Ajoute le text
			  populate(thename,i,the_file[j][2]);
			  //Place l'image
			  //alert("editonewsuser"+uid)
			  galup[uid] = document.getElementById("img_"+thename+i);
			  foo[uid] = new Image;
			  foo[uid].src = the_file[j][1];
			  //foo[uid].onload=new Function("fooy=foo["+uid+"].height;foox=foo["+uid+"].width;galup["+uid+"].height=fooy/2;galup["+uid+"].width=foox/2;galup["+uid+"].style.display='block';");
			  resizePic(uid,0);
			  galup[uid].src=foo[uid].src;
	  }
	  return i;
   }

function populate(thename, id,texte){
	texte = "<table><tr><td nowrap>"+texte+"</td></tr></table>";
	cross_marquee=document.getElementById("ie_"+thename+""+id);
	cross_marquee.innerHTML=texte;
	return;
}
function setCheckbox(thisForm, checkObj, img, val) {
	if (document.forms[thisForm][checkObj].value=="1") {
		document.forms[thisForm][checkObj].value = "";
		document.images[img].src = "/club/images/checkbox_uncheck.png";
	}
	else {
		document.forms[thisForm][checkObj].value = "1";
		document.images[img].src = "/club/images/checkbox_check.png";
	}
	return;
}
function setRadio(thisForm, checkObj, Val, Default) {
	if (typeof radio_toreset[checkObj] == "undefined") {
	  if (Default=='') radio_toreset[checkObj]=-99;
	  else radio_toreset[checkObj] = Default;
	}
	if (radio_toreset[checkObj] == Val) {
	  var obj_to_unset = Val;
	  var obj_to_set = Default;
	} else {
	  var obj_to_unset = radio_toreset[checkObj];
	  var obj_to_set = Val;
	}

	radio_toreset[checkObj] = obj_to_set;
	document.forms[thisForm][checkObj].value = obj_to_set;

	if (typeof document.images['img_'+checkObj+"_"+obj_to_unset] != "undefined") document.images['img_'+checkObj+"_"+obj_to_unset].src = "/club/images/checkbox_uncheck.png";
	if (typeof document.images['img_'+checkObj+"_"+obj_to_set]   != "undefined") document.images['img_'+checkObj+"_"+obj_to_set].src = "/club/images/checkbox_check.png";
	return;
}

function resizePic(id,i) {
	if (!foo[id].complete) setTimeout("resizePic("+id+","+(i+1)+")",10);
	else {
		fooy=foo[id].height;foox=foo[id].width;galup[id].height=fooy/2;galup[id].width=foox/2;galup[id].style.display='block';
	}
}


var preloadFlag = false;
function WindowPopUp(x,y,nom,st,sb) {
   windowMedia = window.open('',nom,'resizable=yes,toolbar=no,left=30,top=30,status='+ st +',scrollbars='+ sb +',width=' + x + ',height=' + y)
}
function newImage(img) {
	if (document.images) { rslt = new Image(); rslt.src = img; return rslt; }
	return;
}
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			if (typeof document[changeImages.arguments[i]] !== 'undefined') document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
function preloadImages() {
	if (document.images) {preloadFlag = true;}
	return preloadFlag;
}
var qcchat; function openChat2() {
	if (typeof qcchat!='object' || qcchat.closed) { qcchat = window.open('/club/chat/chat_cam.php?'+arg_sid+'mep_none=1&mep_limit=1','safeboywebcam','scrollbars=yes,resizable=yes,width=810,height=680'); }
	return qcchat;
}
var pfzchatwindow; function openChat3() {
	if (typeof pfzchatwindow!='object' || pfzchatwindow.closed) {
		var iWidth = screen.availWidth * 0.8 , iHeight = screen.availHeight * 0.6;
		if (iWidth<700) iWidth=700;if (iHeight<500) iHeight=500;
		pfzchatwindow = window.open('/club/cam/index.php?'+arg_sid+'&mep_none=1&mep_limit=1','safeboywebcam','scrollbars=yes,resizable=yes,width='+iWidth+',height='+iHeight);
	}
	return pfzchatwindow;
}
function openChat() {
	openChat3(); return false;
	if (typeof qcchat!='object' || qcchat.closed) { qcchat = window.open('/club/chat/chat_qcboy.php?'+arg_sid+'&mep_none=1&mep_limit=1','safeboywebcam','scrollbars=yes,resizable=yes,width=810,height=680'); }
}

function profil(thename, id) { window.open('http://www.safeboy.net/club/profils/profil.php?'+arg_sid+'&mep_limit=1&id_membre='+id,'SafeBoyAnnoncesFiche','toolbar=0,location=0,directories=0,status=0,scrollbars=yes,resizable=yes,copyhistory=0,menuBar=0,width=770,height=600'); };
function profil_bypos(thename, position) { profil (thename, clink[thename][position])}
function addContact(id,niveau) {
	var verifstr;
	if (niveau>0) verifstr = '&verif=1&niveau='+niveau; else verifstr = '';
	window.open('/club/compte/pop_contact.php?'+arg_sid+'&'+verifstr+'&id_membre='+id,'SafeBoyAnnoncesFiche','toolbar=0,location=0,directories=0,status=0,scrollbars=yes,resizable=yes,copyhistory=0,menuBar=0,width=770,height=700');
}
function showUser(id) { window.open('/club/profils/profil.php?'+arg_sid+'&mep_limit=1&id_membre='+id,'SafeBoyAnnoncesFiche','toolbar=0,location=0,directories=0,status=0,scrollbars=yes,resizable=yes,copyhistory=0,menuBar=0,width=770,height=700'); };

