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('\ \