﻿var isMSIE=(document.all)?true:false;
var isJS12=(window.screen)?true:false;
function goGenikids() {
	if ( typeof(top.index) == "undefined" )
	{
		top.location.href = "http://www.genikids.fr";
	}
	top.index.location.href = "/index.asp";
}

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) { //v3.0
  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&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

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_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 MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function showHideLayers(objL, v) { //v3.0
if ((obj=document.getElementById(objL))!=null) {
    if (obj.style) { obj=obj.style; v=(v=='show')?'':(v='hide')?'none':v; }
    obj.display=v; }
}

function callError(msg, url, linenumber){
	alert(msg+"\n"+ url +"\n"+ linenumber)
	//if ( typeof(top.hidBottom) != "undefined" ) top.hidBottom.document.location.href = "/ScriptError.asp?msg=" +escape(msg) + "&url=" + escape(url) +"&linenumber="+linenumber;
	return true;
}
//window.onerror=callError;

function getPayFactures(tno, refsfp) {
	window.open("/EspaceParents/PayFactures.asp?TNO="+tno+"&CRefsfp="+refsfp,"PayHistory","width=800, height=850,scrollbars=yes");
}

var winX, winY
var screenCenter = function(objX, objY){
	if (parseInt(navigator.appVersion) >= 4) {
		winX = ((screen.availWidth*.5)-(objX*.5));
		winY = ((screen.availHeight*.5)-(objY*.5));
	}
	//alert(winX + "|" + winY)
}

function MiniPop(num) {
	popupwinX = "280";
	popupwinY = "260";

	if(num==1) imgName = "FindAccount.gif";
	else imgName = "NoEmail.gif";

	SimpleImgPop("/image/"+ imgName, 280,  260 );
}

function SimpleImgPop(imgSrc, imgWidth, imgHeight){
	screenCenter(Number(imgWidth),Number(imgHeight));
	var p = window.open("","","width="+ imgWidth +", height="+ imgHeight +", left= "+ winX +",top="+ winY);
	var d = p.document.open();

	d.write("<html><body leftmargin='0' topmargin='0'><img src='"+ imgSrc +"' width='"+ imgWidth +"' height='"+ imgHeight +"' style='cursor:hand' onclick='window.close();'></body></html>");
	d.close();
}

var MainPop = function(popupwinX,popupwinY,strSrc) {
	screenCenter(Number(popupwinX),Number(popupwinY));
	var objWin = window.open(strSrc,"MainPop","width="+ popupwinX +", height="+ popupwinY +", left="+ winX +" ,top="+ winY);
	if(!objWin){
		alert("Veuillez désactiver l'option de blocage des fenêtres\nsurgissantes (pop-up) du navigateur.");
	}else{
		objWin.focus();
	}

}

var findPassword = function() {
	//location.href = "/Inscription/getPassword.asp";
	MainPop(460,350,'/Inscription/getPassword.asp');
}

function getCookie( name ){
	var nameOfCookie = name + "=";
  	var x = 0;
	while ( x <= document.cookie.length ){
		var y = (x+nameOfCookie.length);
	    if ( document.cookie.substring( x, y ) == nameOfCookie ) {
				if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
					endOfCookie = document.cookie.length;
				return unescape( document.cookie.substring( y, endOfCookie ) );
			}
	    x = document.cookie.indexOf( " ", x ) + 1;
	    if ( x == 0 )
				break;
	}
	return "";
}

function go_url(url)
{
	var child = null;
	child = window.open(url,'Notice','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,width=418,height=270,left=0,top=0');
	child.focus();
}

function moneyPage() {
	top.index.document.location.href = "/Inscription/getMemberinfo.asp";
}

function lastLevelGame() {
	//alert("LastLevelGame");
	//Hanja My Level Go Button
	pageReload();
}





function contentView(str) {
//	location.href = "/Contents/ContentsList.asp?strLink="+str;
	top.index.location.href = "/Contents/"+str;
}

function clickHelp(url) {
	popupwinX = "520";
	popupwinY = "400";
	screenCenter(Number(popupwinX),Number(popupwinY));
	//geniHelp = window.open("http://partner.genikids.com/help.asp?url="+url,"geniHelp","width=520, height=400, left=" + winX + ",top=" + winY);
	geniHelp = window.open("/HelpGuide/help.asp?url="+url,"geniHelp","width="+ popupwinX +", height="+ popupwinY +", left=" + winX + ",top=" + winY);
	geniHelp.focus();
}

function GameOpenFocus(gameURL) {	//--o
	secWin = window.open(gameURL,'gamewindow','fullscreen=1'); //location=1
	if ( ! isMSIE ) secWin.moveTo(0,0); secWin.resizeTo(screen.width,screen.availHeight);

	if (!(secWin)){
		alert("Vous avez installé un logiciel qui empêche la lecture des contenus flash.\n\nVeuillez contacter le service client par e-mail.");
	} else {
		secWin.focus();
	}
//	secWin = window.open(gameURL,'gamewindow','fullscreen=0');
}

// game count
function Update_FeedStr(p,p2) {
	//alert(p + "|" + p2);
	arrCurrentPage = document.URL.split("/");
	PathInfo = arrCurrentPage[arrCurrentPage.length-2];
	intDotIndex = arrCurrentPage[arrCurrentPage.length-1].lastIndexOf(".");
	PageInfo = arrCurrentPage[arrCurrentPage.length-1].substring(0, intDotIndex);

	switch (PathInfo){
		case "Contents" :
			switch (PageInfo){
				case "GeniEnglish" :
					if ( typeof(MM_findObj('mainswf')) == 'undefined' ){ return; break;}
					mainswf.SetVariable("gcount0"+p, p2);
					mainswf.TCallLabel("/","view_init");
					break;
				case "ThemeCorner" : break;
				case "Dinosaur" : break;
				case "KoreanLangPrintOut" : break;
				case "WorldTour" :
					if ( !document.getElementById("mainswf") ){
						return false;
						break;
					}
					adocument.getElementById("mainswf").SetVariable("setCountByWeb", p+"_"+p2);
					break;
				default :
					if (!document.getElementById("c" + p)) {
						if ( !document.getElementById("mainswf") ){
							return false;
						}
						document.getElementById("mainswf").SetVariable("gcount0"+p, p2);
						document.getElementById("mainswf").TCallLabel("/","view_init");
						return false;
					}
					//alert(document.getElementById("c" + p).GetVariable("gameCount"));
					document.getElementById("c" + p).SetVariable("gameCount",p2);
					document.getElementById("c" + p).SetVariable("gameIndex",1);
					document.getElementById("c" + p).TCallLabel("/","view_init");
			}
			break;
	}
}

function reSize(objSel)
{
	var objFrame = objSel;
	var objBody = objFrame.document.body;
	objFrame.style.height = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);
//	alert(objBody.offsetHeight +'-'+ objBody.clientHeight+'+'+objBody.scrollHeight);
}

function closeALRabbit() {
	AlRabbitPop.TCallLabel("/","unload");
	document.all['ALRabbit'].style.visibility = "hidden";
}

function openPop() {
	document.all['ALRabbit'].style.visibility = "";
}

function initPop(opt, level, sub) {
	if ( opt == "" ) {
		opt = "0";
	} else if ( opt == "9" ) {
		level = ( Math.floor(Math.random()*10) % 2 ) + 1;
	}
	if (level == "" ) {
		level = "4";
	}

	AlRabbitPop.SetVariable("opt",opt);
	AlRabbitPop.SetVariable("level",level);
	AlRabbitPop.SetVariable("sub",sub);
	AlRabbitPop.TCallLabel("/","view_init");
	openPop();
}

function initStudyTimePop(opt, level, sub, BreathingEndTime) {
	var A = document.getElementById("AlRabbitPop")
	A.SetVariable("BreathingEndTime",BreathingEndTime);
	initPop(opt, level, sub);
}

function alertLogin() {
	alert('Veuillez saisir votre Pseudo et mot de passe');
}
function ChangeCategory( str_idx, sel_idx, max_idx ) {
	for ( i=0; i < max_idx; i++ ) {
		if ( sel_idx == i ) {
			document.all[str_idx+i].style.display = '';
		} else {
			document.all[str_idx+i].style.display = 'none';
		}
	}
}

function PrintJSSWF(strURL, strwidth, strheight){
	document.open();
	//document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+ strwidth + '" height="'+ strheight + '">\r' );
	document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="/JScript/swflash.cab#version=9,0,28,0" width="'+ strwidth + '" height="'+ strheight + '">\r' );
	document.write( '<param name="movie" value="'+ strURL + '">\r' );
	document.write( '<param name="quality" value="high">\r' );
	document.write( '<param name="wmode" value="transparent">\r' );
//	document.write( '<param name="menu" value="false">\r' );
	document.write( '<param name="allowScriptAccess" value="always">\r' );
	document.write( '<param name="scale" value="exactfit">\r' );
	document.write( '<embed src="'+ strURL + '" quality="high" allowScriptAccess="always" allowFullScreen="false" scale="exactfit" devicefont="false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+ strwidth + '" height="'+ strheight + '"wmode="transparent">\r' );
	document.write( '</embed>' );
	document.write( '</object>' );
	document.close();
}



function PrintJSSWFID(strURL, strwidth, strheight, strID){
	document.open();
	if(isMSIE){document.write( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="/JScript/swflash.cab#version=9,0,28,0" width="'+ strwidth + '" height="'+ strheight + '" id="'+ strID +'" style="border:0px red solid;">\r' );
	document.write( '<param name="movie" value="'+ strURL + '">\r' );
	document.write( '<param name="quality" value="high">\r' ); //--
	if(strID != "GAMESWF") document.write( '<param name="wmode" value="transparent">\r' );
	document.write( '<param name="menu" value="false">\r' );
	document.write( '<param name="allowScriptAccess" value="always">\r' );
	document.write( '<param name="scale" value="exactfit">\r' );
	document.write( '</object>' );
	}else{
	document.write( '<embed src="'+ strURL + '" quality="high" allowScriptAccess="always" allowFullScreen="false" scale="exactfit" devicefont="false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+ strwidth + '" height="'+ strheight + '" id="'+ strID + '"wmode="transparent">\r</embed>' );
	}

	document.close();
}

function PrintObj(id) {
	document.open();
	document.write(id.innerHTML); delete(id);
	document.close();
}

function ParentAuthOff(){
	top.hidBottom.document.location.href = "/EspaceParents/EP_AuthOff.asp"
}

//==============================================================================================================

function setMemberinfo() {
	location.href = "/Inscription/getMemberinfo.asp";
}

function setEPMemberinfo() {
	parent.location.href = "/Inscription/getMemberinfo.asp";
}

function setPlanDeSitePage() {
	ParentAuthOff();
	location.href = "/PlanDeSite/PlanDeSite.asp";
}



function setMonCarnetPage() {
	//onPopupAuth('/MonCarnet/MonCarnet.asp');
	location.href = "/MonCarnet/MonCarnet.asp";
}

function setMonCarnetPointPage() {
	location.href = "/MonCarnet/Mespoints.asp";
}



function checkReturn(objForm, e) {
	if ( e.keyCode == 13 ) {
		formCheck();
	}
}
// EspaceParents Link START

function setMonCompteback() {
	location.href = "/EspaceParents/EP_main.asp?strStep=2&isFactures=1";
}

function setEspaceParentsPage() {
	ParentAuthOff();
	location.href = "/EspaceParents/EP_main.asp";
}

function goEspaceParentsPage(val) {
	location.href = "/EspaceParents/EP_main.asp?strStep="+val;
}

function goEspaceParents(val) {
	location.href = "/EspaceParents/EP_main.asp?strStep="+val;
}

function goEPMon() {
	location.href = "/EspaceParents/EP_2_Moncompte.asp?strStep=2&strSub=1";
}

function goEPModifier() {
	location.href = "/EspaceParents/EP_2_Modifier.asp?strStep=2&strSub=2&subProcess=3";
}

function goEPForum(val){
	location.href = "/EspaceParents/EP_List.asp?strStep=3&strSub="+val;
}

function goEPPedagogie(val){
	location.href = "/EspaceParents/EP_3_Pedagogie.asp?strStep=3&strSub="+val;
}

function goEPHistorique() {
	location.href = "/EspaceParents/EP_4_His.asp?strStep=4&strSub=1";
}
function goEPStatistiques() {
	location.href = "/EspaceParents/EP_4_Sta.asp?strStep=4&strSub=2";
}
function goEPJoues() {
	location.href = "/EspaceParents/EP_4_Les.asp?strStep=4&strSub=3";
}
function goEPHorloge() {
	location.href = "/EspaceParents/EP_4_Hor.asp?strStep=4&strSub=4";
}
// EspaceParents Link END

// ServiceClient Link START
function setServiceClientPage() {
	ParentAuthOff();
	location.href = "/ServiceClient/SC_main.asp";
}


function goSCFAQ() {
	location.href = "/ServiceClient/SC_FAQ.asp?strStep=1";
}

function goSCContact() {
	location.href = "/ServiceClient/SC_Contact.asp?strStep=2";
}


function goSCOption() {
	location.href = "/ServiceClient/SC_Option.asp?strStep=3";
}

function goSCContactLink() {
	location.href = "/ServiceClient/SC_main.asp?strStep=2";
}
// ServiceClient Link END

//Login Check Form
function formCheck()
{
	var loginID = document.login.loginID.value;
	var password = document.login.password.value;
	var arrCurrentPage = document.URL.split("/")[3];
	var refer_url = document.URL.replace('http://www.genikids.fr','');
	document.login.refer_url.value = refer_url.replace(/&/g,'@');

	if (loginID.length == 0){
		alert("Veuillez saisir votre Pseudo");
		document.login.loginID.focus();
		return false
	}

	if (password.length == 0){
		alert("Veuillez saisir votre mot de passe");

		document.login.password.focus();
		return false
	}

	if (arrCurrentPage == "EspaceParents" || arrCurrentPage == "ServiceClient" ){
		var parentcode = document.login.parentcode.value;
		if (parentcode == ""){
			alert( AltMemText9 );
			$("divParentCode").style.display = "none";
			document.login.parentcode.focus();
			return false
		}
	}

	document.login.target = "LOGIN_SOCKET";
	document.login.action = "/Inscription/LoginSocket.asp"
	document.login.submit();
}

var logout = function() {
	location.href = "/Inscription/LogOut.asp";
}

var setHomepage = function(val) {
	//if(window.sidebar){ // FF
		//alert("FF");
	//}else if(window.external){ //IE
		obj = document.Homepage;
		obj.style.behavior='url (#default#homepage)';
		obj.setHomePage('http://www.genikids.fr');
	//}else{
	//	alert("Press CTRL+, (Safari)");
	//}
}

var MakeShortCut = function() {
	if ( confirm('Installation d\'un raccourci Genikids sur le bureau.\n\nCliquez sur "OK" pour télécharger ou exécuter l\'installation') ) location.href = "/DownLoads/GeniFranceShortCut.exe";
}

var addFavorite = function() {
//	top.bottom.location.href = "addLoginLog.asp?pageCode=AddFavor";
	var winTitle = ":::: www.genikids.fr - le site des petits génies";
	var winSite = "http://www.genikids.fr/";

	if(window.sidebar){// firefox
		window.sidebar.addPanel(winTitle,winSite, "");
	}else if(window.external){
		window.external.AddFavorite(winSite, winTitle);
	}else{
		alert("Appuyez sur les touches \"Ctrl + D\" pour ajouter le site dans vos favoris.");
	}


}

function pageReload(queryStr) {
	//alert(queryStr);
	//--var current_page = document.URL;
	var current_page = document.location.href;
	queryStr_index = current_page.lastIndexOf("?");
	if (queryStr_index == -1)	{
		url = current_page;
	} else {
		url = current_page.substring(0,queryStr_index);
	}
	splited_url = url.split("/");

	if ( splited_url[3] != 'Payment' )	location.href = url+"?"+queryStr;
	if ( splited_url[3] == 'Contents')
	{
		if ( parent.ifrm ){
			parent.closeALRabbit();
		}
	}
}

function pageLoad(str) {
	splited_url = page_url.split("/");
	location.href = str;
	if ( splited_url[3] == 'Contents')
	{
		if ( parent.ifrm )
		{
			parent.closeALRabbit();
		}
	}
}

//wide contents
function getScreenHeightResolution(){
	var strReturn = "100%";
	var isJS12=(window.screen)?true:false;
	if(isJS12){
		var SCRate = screen.width / screen.height;
		if( SCRate >= 1.6 ){
			//strReturn = String(Math.floor(screen.height * 1.3));
			strReturn = "81%";
		}
	}
	return strReturn;
}

var onPresentation = function(){
	MainPop(800,600,'/Popup/PresentationGenikids.htm');
}

var onPresentation_village = function(){
	MainPop(800,600,'/Popup/PresentationVillage.htm');
}

var bluring = function(){
	if(event.srcElement.tagName == "A" || event.srcElement.tagName == "IMG") document.body.focus();
}
document.onfocusin = bluring;

var onPopupAuth = function(tLink){
	//alert(tLink)
	MainPop(357,324,'/EspaceParents/EP_Auth.asp?target_link='+tLink.replace(/&/g,'$'));
}

var setPaymentPage = function(){
	ParentAuthOff();
	location.href = "/Inscription/getMemberinfo.asp";
}
var setInformations = function(){
	onPopupAuth('/EspaceParents/EP_main.asp?strStep=2&strSub=1');
}

var setInfoModifier = function(){
	onPopupAuth('/EspaceParents/EP_main.asp?strStep=2&strSub=2&subProcess=3');
}

var setInscription = function(){
	//location.href = "/Inscription/getMemberinfo.asp";
	//goInscriptionLink(1);
	//location.href = "/Inscription/getMemberinfo.asp?subProcess=1&isButFree=1";
	location.href = "/Inscription/InscriptionGratuits.asp";
}
var setHorloge = function(){
	//onPopupAuth('/EspaceParents/EP_main.asp?strStep=4&strSub=4&strPage=Hor');
	onPopupAuth('/EspaceParents/EP_main.asp?strStep=4&strSub=4&strPage=Hor');
}

var setOutils = function(val){
	onPopupAuth('/EspaceParents/EP_main.asp?strStep=4&strSub=4&strPage='+val);
}

var setAnglais = function(){
	location.href = "/Contents/Anglais.asp";
}

var goInscriptionLink = function(val){
	location.href = "/Inscription/getMemberinfo.asp?subProcess="+val;
}

var goResilierPage = function(val){
	parent.location.href = "/Inscription/getMemberinfo.asp?subProcess=0&sType=4&TNO="+val;
}

var goResilierOk = function(val){
	top.hidBottom.document.location.href = "/Inscription/ResilierAuth.asp?TNO="+val;
}

var goAddEnglish = function(){
	parent.location.href = "/Inscription/getMemberinfo.asp";
}

var setForum = function(val){
	location.href = "/EspaceParents/EP_main.asp?strStep=3&target_link="+val.replace(/&/g,'$');
}

var setServiceClient = function(val){
	location.href = "/ServiceClient/SC_main.asp?strStep=1&target_link="+val.replace(/&/g,'$');
}

var swfExit = function(){
	window.close();
}

var goJeuxGratuits = function(){
	location.href = "/ServiceClient/JeuxGratuits.asp";
}

var goHorloge = function() {
	Member.isLogin ? setHorloge() : alert(AltLoginText4);
}

var offerUnOfferte = function() {
	location.href = "/Inscription/Inscription1Journee.asp";
}
