var corners = Array('top-left', 'bottom-left', 'top-right', 'bottom-right'); var directions = Array('up', 'left', 'down', 'right'); /*INIT*/ //window position if(typeof chatParams.corner == 'undefined' || !in_array(chatParams.corner, corners)) chatParams.corner = 'bottom-right';//default if(typeof chatParams.direction == 'undefined' || !in_array(chatParams.direction, directions)) chatParams.direction = 'up';//default //moving step if(typeof chatParams.movingSpeed == 'undefined' || !parseInt(chatParams.movingSpeed)) chatParams.movingSpeed = 20;//default //acceleration if(typeof mv_acc == 'undefined' || !parseInt(mv_acc)) mv_acc = 100;//default //popup delay if(typeof chatParams.chatpop_delay == 'undefined' || !parseInt(chatParams.chatpop_delay)) chatParams.chatpop_delay = 1;//default //target url if(typeof chatParams.target_url == 'undefined') chatParams.target_url = 'http://www.mykodial.com/?module=guest_mykodial_subscribe&fromchat=1'; //sound on/off if(typeof chatParams.runsound == 'undefined') chatParams.runsound = true; else{ if(chatParams.runsound == 1) chatParams.runsound = true; else chatParams.runsound = false; } //window properties var chat_w = 455; var chat_h = 225; var chatLeft = 0; var chatTop = 0; var chatwinLeft = -500; var chatwinTop = -500; //container properties //may be set bigger thatn the flash inside var chatContW = 455; var chatContH = 225; var chatContLeft = 0; var chatContTop = 0; //fake chat object var chat_win; var chat_win_container; var subscribe_frame; //get page size var d = dimension_detect(); var end_border = 0; var closing = false; var flash_created = false; var makesound = false; //subscr iframe static dimensions for easy calculation of positions var subscrFrameW = 475; var subscrFrameH = 360; //allow repositioning of the chat window on page resize var reposChatAllowed = false; //... var chatClosed = false; /*FUNCTIONS*/ function init_chat(create_chat){//undefined -> true, defined only when false //session cookie if(typeof chatParams.affichage != 'undefined' && chatParams.affichage == 'once'){//show once is set //check if cookie exists if(document.cookie.indexOf('myko_chat_cookie=') == -1){//not exists //create a cookie document.cookie = 'myko_chat_cookie=1;path=/;'; } else if(document.cookie.indexOf('myko_chat_cookie=1') != -1){//there is a cookie -> stop here return true; } } if(typeof create_chat == 'undefined'){ //draw the chat popup without the flash createChat(); //put the flash inside create_flashOBJ(); //correct wrong directions checkDirection(); //var subscribe_frame = document.getElementById('subscribe_frame'); if(chatParams.corner == 'bottom-right'){ //container chatContTop = d.viewH - chatContH; chatContLeft = d.viewW - chatContW; chat_win_container.style.bottom = '0'; chat_win_container.style.right = '0'; subscribe_frame.style.right = 0; subscribe_frame.style.bottom = 0; } else if(chatParams.corner == 'top-left'){ //container chatContTop = 0; chatContLeft = 0; chat_win_container.style.left = '0'; chat_win_container.style.top = '0'; subscribe_frame.style.top = '0'; subscribe_frame.style.left = '0'; } else if(chatParams.corner == 'bottom-left'){ //container chatContTop = d.viewH - chatContH; chatContLeft = - 3; chat_win_container.style.bottom = '0'; chat_win_container.style.left = '0'; subscribe_frame.style.left = '0'; subscribe_frame.style.bottom = '0'; } else if(chatParams.corner == 'top-right'){ //container chatContTop = -3; chatContLeft = d.viewW - chatContW; chat_win_container.style.top = '0'; chat_win_container.style.right = '0'; subscribe_frame.style.right = '0'; subscribe_frame.style.top = '0'; } else return false; if(chatParams.direction == 'up'){ //the moving win chatTop = chat_h; // chatTop += 20; chatLeft = 0; end_border = 0; } else if(chatParams.direction == 'left'){ chatTop = 0; chatLeft = chat_w; end_border = 0; } else if(chatParams.direction == 'down'){ chatTop = -chat_h; chatLeft = 0; end_border = 0; } else if(chatParams.direction == 'right'){ chatTop = 0; chatLeft = -chat_w; end_border = 0; } else return false;//no direction specified or initialized chat_win_container.style.visibility = 'visible'; }//if init for first time //position the chat window chat_win.style.left = chatLeft + 'px'; chat_win.style.top = chatTop + 'px'; chat_win.style.visibility = 'visible'; //enter the moving loop if(typeof create_chat == 'undefined'){ setTimeout('chatwinMove("'+chatParams.direction+'")',chatParams.chatpop_delay * 1000);//delay time before showing the popup with the chat } else{ chatwinMove(chatParams.direction);//no wait -> for closing it } setTimeout('reposChat()',500); }//init_chat() //closes the chat window by moving it to its first position function close_chatWin(){ //switch the direction if(chatParams.direction == 'up'){ chatParams.direction = 'down'; end_border = chat_h; } else if(chatParams.direction == 'left'){ chatParams.direction = 'right'; end_border = chat_w; } else if(chatParams.direction == 'down'){ chatParams.direction = 'up'; end_border = -chat_h; } else if(chatParams.direction == 'right'){ chatParams.direction = 'left'; end_border = -chat_w; } else return false; closing = true; //init_chat(false); chatwinMove(chatParams.direction); chatClosed = true; return true; }//close_chatWin() //check then chosen direction and set it to allowed if wrong function checkDirection(){ //just to be sure if(typeof chatParams.corner == 'undefined' || typeof chatParams.direction == 'undefined') return false; if(chatParams.corner == 'top-left'){ if(chatParams.direction == 'left' || chatParams.direction == 'up') chatParams.direction = 'down'; } else if(chatParams.corner == 'bottom-left'){ if(chatParams.direction == 'left' || chatParams.direction == 'down') chatParams.direction = 'up'; } else if(chatParams.corner == 'bottom-right'){ if(chatParams.direction == 'right' || chatParams.direction == 'down') chatParams.direction = 'up'; } else if(chatParams.corner == 'top-right'){ if(chatParams.direction == 'right' || chatParams.direction == 'up') chatParams.direction = 'down'; } else return false; return true; }//checkDirection() function chatwinMove(direction){ if(typeof direction == 'undefined') return false; makesound = true; if(direction == 'up'){ //check if the popup reached the final position or not if(parseInt(chat_win.style.top) <= end_border ){ chat_win.style.top = end_border; return checkClosed(); } //move it up and away chatwinTop = parseInt(chat_win.style.top); if(chatwinTop - chatParams.movingSpeed < end_border) chat_win.style.top = end_border; else chat_win.style.top = chatwinTop - chatParams.movingSpeed + 'px'; } else if(direction == 'left'){ //check if the popup reached the final position or not if(parseInt(chat_win.style.left) <= end_border ){ chat_win.style.left = end_border; return checkClosed(); } //move it to the left chatwinLeft = parseInt(chat_win.style.left); if(chatwinLeft - chatParams.movingSpeed < end_border) chat_win.style.left = end_border; else chat_win.style.left = chatwinLeft - chatParams.movingSpeed + 'px'; } else if(direction == 'down'){ //check if the popup reached the final position or not if(parseInt(chat_win.style.top) >= end_border ){ chat_win.style.top = end_border; return checkClosed(); } //move it down chatwinTop = parseInt(chat_win.style.top); if(chatwinTop + chatParams.movingSpeed > end_border) chat_win.style.top = end_border; else chat_win.style.top = chatwinTop + chatParams.movingSpeed + 'px'; } else if(direction == 'right'){ //check if the popup reached the final position or not if(parseInt(chat_win.style.left) >= end_border ){ chat_win.style.left = end_border; return checkClosed(); } //move it to the right chatwinLeft = parseInt(chat_win.style.left); if(chatwinLeft + chatParams.movingSpeed > end_border) chat_win.style.left = end_border; else chat_win.style.left = chatwinLeft + chatParams.movingSpeed + 'px'; } else return false; //continue moving setTimeout('chatwinMove("'+direction+'")', /*100 - (mv_acc * 5)*/1 ); //chatwinMove(direction); }//chatwinMove() function checkClosed(){ if(chatClosed){ chat_win.style.visibility = 'hidden'; } return chatClosed; } function createChat(){ //decide which skin to use from the flash skin var html_skin_num = 3; /*DRAW THE POPUP*/ document.write('\ \
\
 
\
\ '); chat_win_container = document.getElementById('chatwin_container'); chat_win = document.getElementById('chatwin'); subscribe_frame = document.getElementById('subscribe_frame'); }//createChat() function create_flashOBJ(){ if(flash_created) return true; //load the flash and make the notifying sound var flashVars = 'nickname=VIANAPOLEONE&thumb=http%3A%2F%2Fwww.keumzone.com%2Fmembers%2F5002%2F500230%2F120x120%2Ff5c7b65d901eef44a8badf4f5c89d575.jpg&years=37 ans &lang='+chatParams.lang+'&visitor=Moi&xmlpath=http://media.mykodial.com/corner2/sentences_'+chatParams.lang+'.xml'+'&flashskin='+chatParams.skin; var so = new SWFObject("http://media.mykodial.com/corner2/tchat.swf?"+flashVars, "player1", chat_w, chat_h, "8", "0"); so.addParam("allowScriptAccess", "always"); so.addParam("wmode", "transparent"); so.write("chatwin"); //check the flash creation here... //.... flash_created = true; return flash_created; } function checkTime(){ return (chatParams.runsound && makesound); } function subscribeFromChat(){ reposSubscribe(); //hide the flash document.getElementById('chatwin').style.visibility = 'hidden'; //subscribe_frame = document.getElementById('subscribe_frame'); subscribe_frame.style.visibility = 'visible'; } function reposSubscribe(){ //break the loop if not needed if(chatClosed){ return true; } setTimeout('reposSubscribe()',200); //var subscribe_frame = document.getElementById('subscribe_frame'); //do not reposition while the form is hidden if(subscribe_frame.style.visibility == 'hidden') return true; //position the iframe d = dimension_detect(); var iframeLeft = 0; var iframeTop = 0; if(chatParams.corner == 'bottom-right'){ iframeLeft = d.viewW - subscrFrameW; iframeTop = d.viewH - subscrFrameH; } else if(chatParams.corner == 'bottom-left'){ iframeLeft = 0; iframeTop = d.viewH - subscrFrameH; } else if(chatParams.corner == 'top-left'){ iframeLeft = 0; iframeTop = 0; } else if(chatParams.corner == 'top-right'){ iframeLeft = d.viewW - subscrFrameW; iframeTop = 0; } else return false; //Firefox if(BrowserDetect.browser == "Firefox"){ //calculate the scrollbars if any if(chatParams.corner == 'bottom-right' || chatParams.corner == 'top-right'){ if (document.body.clientHeight < document.body.scrollHeight) { var w = getScrollBarWidth(); iframeLeft -= w; } if (document.body.clientWidth < document.body.scrollWidth) { var h = getScrollBarWidth(); iframeTop -= h; } } } //the scrollbars offset iframeLeft += d.left; iframeTop += d.top; iframeLeft += 'px'; iframeTop += 'px'; subscribe_frame.style.top = iframeTop; subscribe_frame.style.left = iframeLeft; return true; }//reposSubscribe() function closeSubscribe(){ //hide the iframe subscribe_frame.style.visibility = 'hidden'; //show the flash document.getElementById('chatwin').style.visibility = 'visible'; } function reposChat(){ //break the loop if not needed if(chatClosed){ return true; } setTimeout('reposChat()',200); //recalculate the window dimensions d = dimension_detect(); //get the new positions if(chatParams.corner == 'bottom-right'){ //container chatContTop = d.viewH - chatContH; chatContLeft = d.viewW - chatContW; } else if(chatParams.corner == 'top-left'){ //container chatContTop = 0; chatContLeft = 0; } else if(chatParams.corner == 'bottom-left'){ //container chatContTop = d.viewH - chatContH; chatContLeft = 0; } else if(chatParams.corner == 'top-right'){ //container chatContTop = 0; chatContLeft = d.viewW - chatContW; } //Firefox if(BrowserDetect.browser == "Firefox"){ //calculate the scrollbars if any if(chatParams.corner == 'bottom-right' || chatParams.corner == 'top-right'){ if (document.body.clientHeight < document.body.scrollHeight) { var w = getScrollBarWidth(); chatContLeft -= w; } if (document.body.clientWidth < document.body.scrollWidth) { var h = getScrollBarWidth(); chatContTop -= h; } //..calculated dynamically from borders padding etc.. chatContLeft -= 5; chatContTop -= 5; } } chatContLeft += d.left; chatContTop += d.top; //position the chat container chat_win_container.style.left = chatContLeft + 'px'; chat_win_container.style.top = chatContTop + 'px'; //window.status = 'repositioning: left='+chatContLeft+', top='+chatContTop; return true; }//reposChat() function getScrollBarWidth () { if(BrowserDetect.browser == "Explorer"){ return 17; } else{ return 16; } // var inner = document.createElement('p'); inner.style.width = "100%"; inner.style.height = "200px"; var outer = document.createElement('div'); outer.style.position = "absolute"; outer.style.top = "0px"; outer.style.left = "0px"; outer.style.visibility = "hidden"; outer.style.width = "200px"; outer.style.height = "150px"; outer.style.overflow = "hidden"; outer.appendChild (inner); document.body.appendChild (outer); var w1 = inner.offsetWidth; outer.style.overflow = 'scroll'; var w2 = inner.offsetWidth; if (w1 == w2) w2 = outer.clientWidth; document.body.removeChild (outer); return (w1 - w2); } function getScrollBarHeight () { if(BrowserDetect.browser == "Explorer"){ return 17; } else{ return 16; } // var inner = document.createElement('p'); inner.style.width = "200px"; inner.style.height = "100%"; var outer = document.createElement('div'); outer.style.position = "absolute"; outer.style.top = "0px"; outer.style.left = "0px"; outer.style.visibility = "hidden"; outer.style.width = "200px"; outer.style.height = "150px"; outer.style.overflow = "hidden"; outer.appendChild (inner); document.body.appendChild (outer); var w1 = inner.offsetHeight; outer.style.overflow = 'scroll'; var w2 = inner.offsetHeight; if (w1 == w2) w2 = outer.clientHeight; document.body.removeChild (outer); return (w1 - w2); } function dimension_detect(){ var d={'viewW':0,'viewH':0,'docH':0,'docW':0,'left':0,'top':0}; if (document.body.scrollHeight>document.body.offsetHeight){ d.docW=document.body.scrollWidth; d.docH=document.body.scrollHeight; } else { d.docW=document.body.offsetWidth; d.docH=document.body.offsetHeight; } if (self.innerWidth){ d.viewW=self.innerWidth; d.viewH=self.innerHeight; d.left=window.pageXOffset; d.top=window.pageYOffset; } else { var ie=(document.compatMode&&document.compatMode!='BackCompat')?document.documentElement:document.body; d.viewW=ie.clientWidth; d.viewH=ie.clientHeight; d.left=ie.scrollLeft; d.top=ie.scrollTop; } return d; }//dimension_detect function in_array(needle, haystack) { for (j=0; j0){ alert("Les champs en rouge sont obligatoires pour l'inscription!"); return; } //if OK var form_email = document.getElementById('chat_subscr_email').value; var form_nickname = document.getElementById('chat_subscr_nickname').value; var form_age = document.getElementById('chat_subscr_age').value; var form_pass = document.getElementById('chat_subscr_password').value; var url = chatParams.target_url + "preSubscribe=1&email="+form_email+"&nickname="+form_nickname+"&age="+form_age+"&password="+form_pass; url += "&id="+chatParams.id+"&tracker="+chatParams.tracker+"&langue="+chatParams.lg; //url += "¶m="+chatParams.param;//not needed now url += "&create_user=1&origin=webmaster"; window.open(url); }//checkForm() //preload the thumb var pre_img = new Image(); pre_img.src = 'http%3A%2F%2Fwww.keumzone.com%2Fmembers%2F5002%2F500230%2F120x120%2Ff5c7b65d901eef44a8badf4f5c89d575.jpg'; //start init_chat();