/* MULTI Onload function */

function addOnloadEvent(fnc){
  if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", fnc, false );
  else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", fnc );
  }
  else {
    if ( window.onload != null ) {
      var oldOnload = window.onload;
      window.onload = function ( e ) {
        oldOnload( e );
        window[fnc]();
      };
    }
    else 
      window.onload = fnc;
  }
}


/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 * ex: <a href="image.jpg" class="preview" title="Great looking landscape">Roll over to preview</a>
 */
 
this.imagePreview = function(){	
	/* CONFIG */
		
		pxOffset = 10;
		pyOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - pxOffset) + "px")
			.css("left",(e.pageX + pyOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - pxOffset) + "px")
			.css("left",(e.pageX + pyOffset) + "px");
	});			
};

// starting the script on page load
$(document).ready(function(){
	imagePreview();
});

/*********************************************************************************************************************/

/*Links With URL Preview
* ex: <a href="http://www.cssglobe.com" class="screenshot" rel="cssg_screenshot.jpg" title="Web Standards Magazine">Css Globe</a>
*
*
*/

this.screenshotPreview = function(){	
	/* CONFIG */
		
		sxOffset = 240;
		syOffset = -100;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		$("#screenshot")
			.css("top",(e.pageY - sxOffset) + "px")
			.css("left",(e.pageX + syOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - sxOffset) + "px")
			.css("left",(e.pageX + syOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	screenshotPreview();
});

/*********************************************************************************************************************/

/*Image Preview Gallery
* ex: <a href="http://cssglobe.com" class="tooltip" title="Web Standards Magazine">Roll over for tooltip</a>
*
*
*/

this.tooltip = function(){	
	/* CONFIG */		
		txOffset = 10;
		tyOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - txOffset) + "px")
			.css("left",(e.pageX + tyOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - txOffset) + "px")
			.css("left",(e.pageX + tyOffset) + "px");
	});			
};



// starting the script on page load
$(document).ready(function(){
	tooltip();
});

/*********************************************************************************************************************/


/*
	*	ADD games to favorites
	* Dynamically add favorites games to user account
	*	(c) JAPMedia.com 2010
	* For Jeux-Filles.com
*/
//Browser Support Code
function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('FavDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	var queryString = "?id=" + gid + "&uid=" + uid ;
	ajaxRequest.open("GET", "inc/addfav.php" + queryString, true);
	ajaxRequest.send(null); 
}

/*********************************************************************************************************************/

/*
	*	Count link exchange partner
	* Dynamically count outbound links click
	*	(c) JAPMedia.com 2010
	* For Jeux-Filles.com
*/
//Browser Support Code
function ajaxOutlink(siteid){
	var ajaxRequest;  // The variable that makes Ajax possible!

	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	var queryString = "?id=" + siteid ;
	ajaxRequest.open("GET", "inc/linkout.php" + queryString, true);
	ajaxRequest.send(null); 
}


/*********************************************************************************************************************/

/*
	*	Ajax Multilevel Dropdown
	* Create a horizontal multilevel dropdown navigation menu
	*	(c) JAPMedia.com 2010
	* For Jeux-Filles.com
*/

function mainmenu(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}
 
 $(document).ready(function(){					
	mainmenu();
});


function bookmarksite(title,url){
if (window.sidebar){ // firefox
	window.sidebar.addPanel(title, url, "");
}
	else if(window.opera && window.print){// opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
	else if(document.all){// ie
		window.external.AddFavorite(url, title);
	} 
	else if(window.chrome){
		alert('Touches CTRL+D pour ajouter aux Favoris (Command+D = Macs) après avoir cliqué OK');
	}
}

function handleError(){
		return true;
}
window.onerror = handleError;
addOnloadEvent(loadSite);

/* PUSH ONLINE FRIENDS AJAX TECHNOLOGIE */
/*****************************************************************************************************/

/* ZOOM IMAGE SLIDER */
function shrinkpic() {
	document.getElementById("textbox").innerHTML=""
	if (i>0) {
		i-=step
		document.getElementById("picdiv").style.width=i+"px"
		document.getElementById("picdiv").style.height=i*(imgheight/imgwidth)+"px"
		document.getElementById("picdiv").style.left=imgwidth/2-(i/2)+"px"
		document.getElementById("picdiv").style.top=(imgwidth/2-(i/2))*(imgheight/imgwidth)+"px"
		tmr=setTimeout("shrinkpic()",5)
	}
	else {
		i_imgurl++
		if (i_imgurl>=imgurl.length) {
			i_imgurl=0
		}
		document.getElementById("picdiv").style.background="url("+imgurl[i_imgurl]+")"
		i=1
		tmr=setTimeout("enlargepic()",5)
	}
}

function enlargepic() {
	if (i<=imgwidth) {
		i+=step
		document.getElementById("picdiv").style.width=i+"px"
		document.getElementById("picdiv").style.height=i*(imgheight/imgwidth)+"px"
		document.getElementById("picdiv").style.left=imgwidth/2-(i/2)+"px"
		document.getElementById("picdiv").style.top=(imgwidth/2-(i/2))*(imgheight/imgwidth)+"px"
		tmr=setTimeout("enlargepic()",5)
	}
	else {
		i=imgwidth
		showmessage()
	}
}

function showmessage() {
	document.getElementById("textbox").innerHTML='<span class="textboxbackgroundstyle">'+message[i_imgurl]+'</span>'
	tmr=setTimeout("shrinkpic()",stillstand)
}

function gotothislink(){
	document.location.href=thislink[i_imgurl]
}

/* END ZOOM IMAGE SLIDER */
/*****************************************************************************************************/


function shrinkpic2() {
	document.getElementById("textbox2").innerHTML=""
	if (j>0) {
		j-=step2
		document.getElementById("picdiv2").style.width=j+"px"
		document.getElementById("picdiv2").style.height=j*(imgheight2/imgwidth2)+"px"
		document.getElementById("picdiv2").style.left=imgwidth2/2-(j/2)+"px"
		document.getElementById("picdiv2").style.top=(imgwidth2/2-(j/2))*(imgheight2/imgwidth2)+"px"
		tmr2=setTimeout("shrinkpic2()",5)
	}
	else {
		j_imgurl2++
		if (j_imgurl2>=imgurl2.length) {
			j_imgurl2=0
		}
		document.getElementById("picdiv2").style.background="url("+imgurl2[j_imgurl2]+")"
		j=1
		tmr2=setTimeout("enlargepic2()",2)
	}
}

function enlargepic2() {
	if (j<=imgwidth) {
		j+=step2
		document.getElementById("picdiv2").style.width=j+"px"
		document.getElementById("picdiv2").style.height=j*(imgheight2/imgwidth2)+"px"
		document.getElementById("picdiv2").style.left=imgwidth2/2-(j/2)+"px"
		document.getElementById("picdiv2").style.top=(imgwidth2/2-(j/2))*(imgheight2/imgwidth2)+"px"
		tmr=setTimeout("enlargepic2()",2)
	}
	else {
		j=imgwidth2
		showmessage2()
	}
}

function showmessage2() {
	document.getElementById("textbox2").innerHTML='<span class="textboxbackgroundstyle">'+message2[j_imgurl2]+'</span>'
	tmr=setTimeout("shrinkpic2()",stillstandj)
}

function gotothislink2(){
	document.location.href=thislink2[j_imgurl2]
}

// PopUp to first visit only
function GetCookie(name) {
  var arg=name+"=";
  var alen=arg.length;
  var clen=document.cookie.length;
  var i=0;
  while (i<clen) {
    var j=i+alen;
    if (document.cookie.substring(i,j)==arg)
      return "here";
    i=document.cookie.indexOf(" ",i)+1;
    if (i==0) break;
  }
  return null;
}

