function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1) { c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; } function setCookie(c_name,value,expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); } var set_onlinness_array=new Array(); function new_set_onlinness() { var gotsome = 0; var pubids = ""; for(x in set_onlinness_array) { if(gotsome==1){pubids+="|"} pubids+=x; gotsome = 1; } if(gotsome==1) { var url = "xmlcheckifon2?pubids=" + pubids; //window.open(url); loadXMLDocnew_set_onlinness(url); } var t=setTimeout("new_set_onlinness()",5000); } function processReqChangenew_set_onlinness() { if (reqnew_set_onlinness.readyState == 4) { if (reqnew_set_onlinness.status == 200) { response = reqnew_set_onlinness.responseXML.documentElement; var result = response.getElementsByTagName("result")[0].firstChild.data; if(result == "ok") { var totalresults = response.getElementsByTagName("totalresults")[0].firstChild.data; var count = 0; while(count < totalresults) { count++; var this_pubid = response.getElementsByTagName("pubid_" + count)[0].firstChild.data; var this_onliner = response.getElementsByTagName("onliner_" + count)[0].firstChild.data; new_display_onlinness(this_pubid,this_onliner); } } } } } function new_display_onlinness(pubid,on_or_off) { if(on_or_off=='on') { picname = 'online.png'; word = 'online'; showonliner = '' + word; showonliner_nowords = ''; showonliner_showoffline = '' + word; } else if(on_or_off=='off') { picname = 'offline.png'; word = 'offline'; showonliner = ''; showonliner_nowords = ''; showonliner_showoffline = '' + word; } var alldivs = document.getElementsByTagName("div"); for(x in alldivs) { //alert(alldivs[x].id); if(alldivs[x].id!=null) { if(alldivs[x].id.indexOf("onliner_"+pubid)!=-1) { if(alldivs[x].id.indexOf("_nowords_")!=-1) {alldivs[x].innerHTML=showonliner_nowords;} else if(alldivs[x].id.indexOf("_showoffline_")!=-1) {alldivs[x].innerHTML=showonliner_showoffline;} else {alldivs[x].innerHTML=showonliner;} } } } } var max_allowed_face_divs=3; var auto_scroll_speed=70; //move face divs 1 px left every xx millisec var put_faces_container=false; var user_scroll_speed=0; //just a var to remember stuff var user_scroll_slower=5; //the higher this is the slower the user scroll will be var padding=0; var faces_pause_scroll=0; var faces_pause_scroll_button=0; var cookie_facespause=getCookie('facespause'); if(cookie_facespause=='1') {faces_pause_scroll_button=1;} //create array of face divs var face_divs=new Array(); var original_face_div; var original_face_div_width; var faces_willpause; var faces_timeout=5*60*1000; //font awesome icons var pause_button_html=''; var play_button_html=''; function newputfaces() { $('#put_faces').css({'height':'100px'}); //create original face div from ajax $.get('/newnewshowfaces',function(data){ var mysqlselect=Math.abs($(data).find('mysqlselect').text()); var buildstring = ''; var countpics=0; var count=0; var todisplay_onlinness = new Array; $(data).find('user').each(function(){ count++; var $node = $(this); var pubid = $node.find('pubid').text(); var screen_name = $node.find('screen_name').text(); var gender = $node.find('gender').text(); var official_picID = $node.find('official_picID').text(); var official_picserver = $node.find('official_picserver').text(); var online = $node.find('online').text(); countpics++; var showpic="http://"+official_picserver+"."+this_top_domain+"/thumbs/"+official_picID+"_thumb.jpg"; if(official_picID==0) {showpic="/new_pics/nopicface2_"+gender+".png"} var u_or_g=pubid.substr(0,1); var userID=pubid.substr(2); set_onlinness_array[pubid]="yes"; todisplay_onlinness[pubid]=online; var thisleft=(countpics-1)*(100+(padding*2)); var this_leads_vars=''; if (typeof force_harba_name !== 'undefined' && typeof force_harba_ref !== 'undefined') {this_leads_vars='&harba_name='+force_harba_name+'&harba_ref='+force_harba_ref;} buildstring+='
'; buildstring+=''; buildstring+=''; //buildstring+='
'+screen_name+'
'; //buildstring+='
'+screen_name+'
'; //buildstring+='
'+screen_name+'
'; //buildstring+='
'+screen_name+'
'; //buildstring+='
'+screen_name+'
'; buildstring+='
'+screen_name+'
'; buildstring+='
'; buildstring+="
"; buildstring+='
'; }); //to try to fix the empty ad bug: if(count==0) {buildstring+=mysqlselect;} original_face_div_width=(100+(padding*2))*countpics; //var play_pause_button_pic='/new_pics/pause.png'; var play_pause_button_icon=pause_button_html; if(faces_pause_scroll_button==1){ //var play_pause_button_pic='/new_pics/play.png'; var play_pause_button_icon=play_button_html; } //var play_pause_button=''; var play_pause_button='
'+play_pause_button_icon+'
'; $('#put_faces').html('
'+buildstring+'
'+play_pause_button); for(x in todisplay_onlinness) {new_display_onlinness(x,todisplay_onlinness[x]);} //add original face div to face_divs array original_face_div=document.getElementById("original_face_div"); face_divs.push(original_face_div); faces_auto_scroll(); faces_willpause = setTimeout(function(){faces_play_pause_toggle('pause',false)},faces_timeout); }); } function faces_play_pause_toggle(force_action,rememberwithcookie) { var togglebutton=document.getElementById("play_pause_toggle_button"); if((force_action=='pause' || faces_pause_scroll_button==0) && force_action!='play') { //pause it faces_pause_scroll_button=1; //togglebutton.src='/new_pics/play.png'; togglebutton.innerHTML=play_button_html; if(rememberwithcookie!=false){setCookie('facespause','1',365);} clearTimeout(faces_willpause); } else { //play faces_pause_scroll_button=0; faces_auto_scroll(); //togglebutton.src='/new_pics/pause.png'; togglebutton.innerHTML=pause_button_html; if(rememberwithcookie!=false){setCookie('facespause','0',365);} faces_willpause = setTimeout(function(){faces_play_pause_toggle('pause',false)},faces_timeout); } } function faces_auto_scroll() { if(faces_pause_scroll_button==0) { if(faces_pause_scroll==0) { var goforspeed=1; if(faces_user_scroll==1) {goforspeed=user_scroll_speed;} var count_face_divs=0; for(x in face_divs) { count_face_divs++; face_divs[x].style.left = face_divs[x].offsetLeft - goforspeed + "px"; } //run loop_it faces_loop_it(); } if(count_face_divs>max_allowed_face_divs) //if number of divs get too high, its bugging, just stop!! { //alert('number of face divs reached over '+max_allowed_face_divs+'. please warn the admin and make sure to mention also what browser/operating system you are on. Thank you!!'); } else {myVar = setTimeout(faces_auto_scroll,auto_scroll_speed);} } //$('#put_faces_debug').html(show_face_divs_array()); } // function show_face_divs_array() // { // var rezu=''; // for(x in face_divs) // {rezu+='
'+face_divs[x]+': x: '+x+', offsetLeft: '+face_divs[x].offsetLeft+'
';} // return rezu; // } function faces_loop_it() { //for every face div, find if they are fully outside of the container if(!put_faces_container) {put_faces_container=document.getElementById("put_faces");} var container_left_side=put_faces_container.offsetLeft; var container_right_side=put_faces_container.offsetLeft+put_faces_container.offsetWidth; ////if yes remove from page and face_divs array ////if not take note of zone covered of container in array var left_side_of_coverage=false; var right_side_of_coverage=null; var todelete=new Array; for(x in face_divs) { var face_div_left_side=face_divs[x].offsetLeft; var face_div_right_side=face_divs[x].offsetLeft+face_divs[x].offsetWidth; if( face_div_right_sidecontainer_right_side ) { //this face div is completely out of the zone... remove it! //put_faces_container.removeChild(face_divs[x]); todelete.push(face_divs[x]); //remove_object_from_array(face_divs,todelete); //put_faces_container.removeChild(todelete); } else { //calculate total coverage with leftest left and rightest right of all the face divs if(left_side_of_coverage===false || face_div_left_sideright_side_of_coverage) {right_side_of_coverage=face_div_right_side;} } } for(x in todelete) { put_faces_container.removeChild(todelete[x]); remove_object_from_array(face_divs,todelete[x]); } //$('#put_faces_debug2').html('left_side_of_coverage: '+left_side_of_coverage+', right_side_of_coverage: '+right_side_of_coverage+', original_face_div_width: '+original_face_div_width); //if not all container zone is covered add clone of original_face_div var leftofnewdiv=false; if(left_side_of_coverage>container_left_side) {leftofnewdiv=left_side_of_coverage-original_face_div_width;} if(right_side_of_coverageleft_side_of_coverage: '+left_side_of_coverage+', right_side_of_coverage: '+right_side_of_coverage+'
new face div added at position '+leftofnewdiv+'
'); } } function remove_object_from_array(array,object) { var countelements=0; //var debugstring=''; //debugstring+='
array before all: '+show_face_divs_array()+'
'; for(x in array) { //debugstring+='
'+array[x]+': x: '+x+', countelements: '+countelements+', id: '+array[x].id+'
'; if(array[x]==object) { //debugstring+='
array before: '+show_face_divs_array()+'
'; face_divs.splice(countelements,1); //debugstring+='
is same as object to be removed... remove....
'; //debugstring+='
array after: '+show_face_divs_array()+'
'; countelements--; } countelements++; } //debugstring+='
array after all: '+show_face_divs_array()+'
'; //$('#put_faces_debug3').html(debugstring); } //===========makeDraggable intercode.ca MODIFIED!!!================= var mouseX; var mouseY; var dragObject = null; var faces_user_scroll=0; //global variables that are needed if (document.addEventListener){document.addEventListener('mousemove',mouseMove,false);document.addEventListener('mouseup',mouseUp,false);} //event handlers else if (document.attachEvent){document.attachEvent('onmousemove',mouseMove);document.attachEvent('onmouseup',mouseUp);} //old ie fix!! function mouseMove(event) { if(dragObject) { //were dragging something var Xdifference=event.clientX-mouseX; var Ydifference=event.clientY-mouseY; //calculate movement dragObject.style.position = "absolute"; dragObject.style.left = dragObject.offsetLeft + Xdifference + "px"; dragObject.style.top = dragObject.offsetTop + Ydifference + "px"; //move the object that we are dragging } if(faces_user_scroll==1) { //faces user scroll, get needed speed!! if(!put_faces_container) {put_faces_container=document.getElementById("put_faces");} var put_faces_middle=(put_faces_container.offsetLeft+(put_faces_container.offsetLeft+put_faces_container.offsetWidth))/2; user_scroll_speed=Math.floor((event.clientX-put_faces_middle)/user_scroll_slower); } mouseX=event.clientX; mouseY=event.clientY; //update global variables about mouse position } function mouseUp(ev){dragObject = null;} //mouse up, stop dragging function makeDraggable_intercode(object){ //the function that makes an object draggable if (object.addEventListener){object.addEventListener('mousedown',function(){dragObject = object;},false);} else if (object.attachEvent){object.attachEvent('onmousedown',function(){dragObject = object;});} } //===========makeDraggable intercode.ca MODIFIED!!!=================