/** * Functions for controlling the suggestion stuff */ var didyoumean_states=new Array(); function switch_didyoumean(element_id) { if (didyoumean_states[element_id]==undefined || didyoumean_states[element_id]=='short') { $("short_"+element_id).style.display='none'; $("extended_"+element_id).style.display='inline'; didyoumean_states[element_id]='extended'; $(element_id+"_switch").innerHTML="less..."; } else if (didyoumean_states[element_id]=='extended'){ $("short_"+element_id).style.display='inline'; $("extended_"+element_id).style.display='none'; didyoumean_states[element_id]='short'; $(element_id+"_switch").innerHTML="more..."; } } /** * Functions that control the styles of the header tabs and the value of the what_who_input field */ var tabs={ selected:false, lasttab:false, over:function (element) { element.className = 'overTab javaTab'; }, out:function (element) { if (element!=tabs.selected) { element.className = 'offTab javaTab'; } }, click:function (element,action) { tabs.selected=element; action(element); } }; function click_who(element) { $('what_tab').className = 'offTab javaTab'; element.className = 'overTab javaTab'; $('what_who_input').value = "who"; $('search_details_what').style.display = "none"; $('search_details_who').style.display = "inline"; $('header_search').action = $('action_who').value; $('searchwhat').setAttribute('name', 'name'); var whoVal = get_cookie('saved_input_name'); $('searchwhat').value = (whoVal)? whoVal : ""; } function click_what(element){ $('searchwhat').focus(); element.className = 'overTab javaTab'; $('who_tab').className = 'offTab javaTab'; $('what_who_input').value = "what"; $('search_details_what').style.display = "inline"; $('search_details_who').style.display = "none"; $('header_search').action = $('action_what').value; $('searchwhat').setAttribute('name', 'searchwhat'); var whatVal = get_cookie('saved_input_searchwhat'); $('searchwhat').value = (whatVal)? whatVal : ""; } /* FILE: cookies.js */ // The Domain must be declared for cookies to work // The spec for cookies, an rfc older than the hills, calls for 2 dots var domain = ".n49.ca"; /* Function: This function loading in a cookie from the uses system */ function get_cookie(cookie_name){ var results = document.cookie.match (cookie_name + '=(.*?)(;|$)'); if (results){ return(unescape(results[1])); }else{ return null; } } /* Function: This function sets a cookie to the uses system */ function set_cookie(name, value, expires){ var cookie_string = name + "=" + escape(value); var today = new Date(); today.setTime(today.getTime()); if (!expires){ var expires = 365; } expires = expires * 60 * 60 * 24 * 1000; var expires_date = new Date( today.getTime() + (expires) ); cookie_string += "; expires=" + expires_date.toGMTString(); cookie_string += "; path="+ '/'; cookie_string += "; domain=" + domain; document.cookie = cookie_string; } function delete_cookie(cookie_name){ var cookie_date = new Date (); // current date & time cookie_date.setTime (cookie_date.getTime() - 1); document.cookie = cookie_name + "=; expires=Thu, 01-Jan-1970 00:00:01 GMT"; return false; } function setMail(id, name, gloablDomain, domainName, changeHTML) { // Kind of obfuscates an email...mostly. var aTag = document.getElementById(id); var emAd = name+"@"+domainName+"."+gloablDomain aTag.innerHTML = (changeHTML) ? changeHTML : emAd; aTag.href = "mailto:"+emAd; return false; } /** * This will take the data from a JSON response and place it into a specified DIV * @params {object} $data array returned from the call [elementID, html] */ function callback_populateContent($data){ if(!$data) { error_handler_by_id('No data, probably an error in the Json file.'); return false; } ($data.err_code) ? error_handler_by_id($data.err_code) : $($data.elementID).innerHTML = $data.html; } var loaded_scripts= new Array(); /** * This function loads in a js file and adds to to be DOM * @params {string} $sourse Location of new JS file */ function loadScript($source) { if (!loaded_scripts[$source]) { loaded_scripts[$source]=true; newScript = document.createElement('script'); newScript.src = $source; document.body.appendChild(newScript); } return false; } var IEFlag = (document.all) ? 1 : 0; var X = 0; // The Mouses X Possistion var Y = 0; // The Mouses Y Possistion var L = 0; // The Current Divs Left var T = 0; // The Current Divs Top var X_dif = 0; // The Diffrence between the mouse location and the left of the div on click var Y_dif = 0; // The Diffrence between the mouse location and the top of the div on click var dragObject = false; var currentDraggableElement = false; function setDraggable(element){ currentDraggableElement = element; } function clearDraggable(element){ currentDraggableElement = false; } /** * Registers a DIV as a dragable object * @params {event} $stageEvent the event that the browser catches */ function createDragObject($stageEvent) { // If there is a Drag Element Being Hovered Over if(dragObject = $(currentDraggableElement)) { // Getting the Stage Event Based On Wether they are in IE or Not var ev = $stageEvent || window.event; // Getting the X and Y of the Mouse var mouseLocation = mouseCoords(ev); X = mouseLocation[0]; Y = mouseLocation[1]; // Getting the top and left of the Dragable Div T = dragObject.offsetTop; L = dragObject.offsetLeft; // Setting the number to subtract from the mouse location when placing the div X_dif = X-L; Y_dif = Y-T; // Putting the dragObject on the top :) dragObject.style.zIndex = popupTopZIndex; popupTopZIndex ++; } } function clearDragObject() { dragObject = false; currentDraggableElement = false; } function moveDragObject(stageEvent) { // If there is a Drag Element clicked on if(dragObject){ // Getting the Stage Event Based On Wether they are in IE or Not var ev = stageEvent || window.event; // Getting the X and Y of the Mouse var mouseLocation = mouseCoords(ev); X = mouseLocation[0]; Y = mouseLocation[1]; dragObject.style.left = (X-X_dif)+"px"; dragObject.style.top = (Y-Y_dif)+"px"; } } // if (!IEFlag) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP); if (!IEFlag){ window.addEventListener('mousedown', createDragObject, false); window.addEventListener('mousemove', moveDragObject, false); window.addEventListener('mouseup', clearDragObject, false); }else{ document.onmousedown = createDragObject; document.onmousemove = moveDragObject; document.onmouseup = clearDragObject; } /* FILE: drop-down.js */ function dropDown(o) { // var subMenu = new Object(); o.sub = o.parentNode.getElementsByTagName('ul')[0]; o.sub.style.visibility = 'visible'; o.sub.style.display = ''; // actions if(o.sub.ddDelayKey!=null) { window.clearTimeout(o.sub.ddDelayKey); o.sub.ddDelayKey=null; } if (o.href.substr(o.href.length-1,1) == "#") o.onclick = function() { return false; } o.onmouseout = function() { if(!this.sub.ddDelayKey) this.sub.ddDelayKey = window.setTimeout(function() { o.sub.style.visibility='hidden'; o.sub.style.display = 'none'; } , 300); } o.sub.onmouseover = function() { if(o.sub.ddDelayKey!=null) { window.clearTimeout(o.sub.ddDelayKey); o.sub.ddDelayKey=null; } o.sub.style.visibility = 'visible'; o.sub.style.display = ''; o.sub.style.listStyle = 'none'; } o.sub.onmouseout = function() { if(!this.ddDelayKey) this.ddDelayKey = window.setTimeout(function() { o.sub.style.visibility='hidden'; o.sub.style.display = 'none'; } , 300); } } function error_handler_by_id(error_id, error_string) { switch(error_id) { case(ERR_LOGIN): // Case makes the popup call for the login Element popup.login(); break; case(ERR_INPUT): alert(error_string); break; default: popup.report_bug(["AJAX error: "+error_string+"(#"+error_id+")"]); break; } return false; } var JSON_timeout = new Array(); var JSON = function () { this.xmlhttp=false; this.async=true; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { try { this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { this.xmlhttp = false;}} @end @*/ if (!this.xmlhttp && typeof XMLHttpRequest!='undefined') {try {this.xmlhttp = new XMLHttpRequest();} catch (e) {this.xmlhttp=false;}} if (!this.xmlhttp && window.createRequest) {try {this.xmlhttp = window.createRequest();} catch (e) {this.xmlhttp=false;}} } JSON.prototype.request = function ($data_type,$params_z,callback,section_type,file) { if (!file) file="/libs/JSON/JSON_actions.php"; var string=""; params_length=$params_z.length; string = "type="+$data_type+"¶ms="+JSON_parser.encode($params_z); if( section_type ) string += "§ion_type="+section_type; string += "&cookies="+escape(document.cookie); var tempxmlhttp=this.xmlhttp; tempxmlhttp.open("POST",file, this.async); tempxmlhttp.setRequestHeader('Content-Type', "application/x-www-form-urlencoded"); //tempxmlhttp.setRequestHeader("Content-Length", string.length); tempxmlhttp.onreadystatechange=function() {if (tempxmlhttp.readyState==4) {if (tempxmlhttp.status!=404) {callback(JSON_parser.decode(tempxmlhttp.responseText));} else {alert("JSON Call Failed!");}}} if (this.async) { if (JSON_timeout[$data_type]) clearTimeout(JSON_timeout[$data_type]); var timeoutFunc = function() { tempxmlhttp.send(string); } JSON_timeout[$data_type]=setTimeout(timeoutFunc,200); } else { tempxmlhttp.send(string); callback(JSON_parser.decode(tempxmlhttp.responseText)); } } function getElementsByClass(searchClass,node,tag) { var classElements = new Array(); if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)'); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } } return classElements; } function $(element) { // Mostly an alias for document.getElementById(). if (arguments.length > 1) { for (var i = 0, elements = [], length = arguments.length; i < length; i++) elements.push($(arguments[i])); return elements; } if (typeof element == 'string') element = document.getElementById(element); return element; } function forceRerendering($element) { // Force the browser to re-render an element. Mostly for IE6 bugs. try { element = $($element); var n = document.createTextNode(' '); element.appendChild(n); element.removeChild(n); } catch(e) { } }; // Lazy function definition pattern: http://www.klauskomenda.com/code/javascript-programming-patterns/#lazy // Neat. var mouseCoords = function(ev) { if(ev.pageX || ev.pageY){ mouseCoords=function(ev) {return [ev.pageX, ev.pageY];} }else{ mouseCoords=function(ev) { var X = ev.clientX + document.body.scrollLeft - document.body.clientLeft; var Y = ev.clientY + document.body.scrollTop - document.body.clientTop; return [X, Y]; } } return mouseCoords(ev); } // This gets the top left positions of the clients scrolled window from the documents top left // Also uses lazy function definition pattern. It shows considerable speed improvements over not using it. var getScrollVal = function() { if (typeof(window.pageXOffset) == 'number') { //Netscape compliant getScrollVal = function() { return [window.pageXOffset,window.pageYOffset]; } }else if (document.body && (typeof(document.body.scrollLeft) == 'number' || typeof(document.body.scrollTop)=='number')) { //DOM compliant getScrollVal = function() { return [document.body.scrollLeft,document.body.scrollTop]; } }else if (document.documentElement && (typeof(document.documentElement.scrollLeft)=='number' || typeof(document.documentElement.scrollTop)=='number')) { //IE6 standards compliant mode getScrollVal = function() { return [document.documentElement.scrollLeft, document.documentElement.scrollTop]; } } return getScrollVal(); } /** * This will regester a function to execute after the page load is completed * * @param {function} func the function that will be executed */ function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } /** * Function to control tab change * and handling a function as a parameter and it's own parameters * * @param object Element which triggered the action ( this ) * @param string [optional] Function name, it must be already set in the page when this is triggered * @param mixed [optional] All parameters that should be passed to the function * */ function change_tabs() { if( arguments[1] && ( 'function' == typeof eval('window.' + arguments[1]) ) ) { myFunction = eval('window.' + arguments[1]); myArray = new Array(); for(var i=2; i< arguments.length; i++) myArray[i-2] = arguments[i]; myFunction( myArray ); } var li = new Object(); li = arguments[0]; // Tab Management Here if(li.parentNode.nodeName=="UL") { if( typeof(ul_li)!='object') { var ul = li.parentNode; var ul_li = ul.getElementsByTagName('LI'); for(i=0 ; i< ul_li.length ; i++) { ul_li[i].pos = i; if( ul_li[i].className.indexOf('onTab') !=-1) ul_li[i].parentNode.cur_tab = i; ul_li[i].onmouseout = function() { if( this.parentNode.cur_tab!= this.pos) this.className = "offTab"; } } } } if( li.className.indexOf('onTab') ==-1 ) li.className = "overTab"; if( li.on_click == undefined) { li.on_click = ( li.onclick != undefined ) ? li.onclick : function() {}; li.onclick = function() { activatetab( ul_li, this ); return this.on_click(); } } } function activatetab( ul_ar, liThis ) { if(liThis.id){ var lastTab = ul_ar[liThis.parentNode.cur_tab]; if(lastTab.id){ var last_content=$(lastTab.id+"_content"); if (last_content) last_content.style.display = "none"; } var this_content=$(liThis.id+"_content"); if (this_content) this_content.style.display = "block"; } liThis.parentNode.cur_tab = liThis.pos; liThis.className = "onTab"; for(i=0 ; i< ul_ar.length ; i++) { if( liThis.parentNode.cur_tab!= ul_ar[i].pos) ul_ar[i].className = "offTab"; } } var videoBox_ar = new Array(); function videoBox_stopVideo($listing_id) { // Looping though all flash elements that need to be set as logged in var videoBox_length = videoBox_ar.length; for(f=0; f maxlimit) field.value = field.value.substring(0, maxlimit); else $(cntfield).innerHTML = maxlimit - field.value.length; } // Read The Function Name :) It should be on the onmouseover of the div the embed is inside of function focusFlashMovie($element){ if($element.firstChild){ if(flashElements_ar[$element.id]){ flashElements_ar[$element.id] = false; flashElements_ar[$element.id+"_embed"] = $element.id+"_embed"; } $element.firstChild.id = $element.id+"_embed"; forceRerendering($element.id); if(typeof $element.focus == 'function') { $element.focus() } } } // The following array will have items added to them to indicate if: // There were written on page load (AKA. Inline in the html) - Will return true when called for // Or if the item in a pop up window (written by javascript) - Will return false when called for var inlinePopups = new Array(); /** * Returns the ID of the popup holder (must be called on a element inside/child of the element with class="contentHolder") * @param element $element A element inside of the contentHolder */ function getPopUpWrapperId($element){ // Yuck. return $element.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id; } /** God damnit. This needs to be included for compatibility with the flash box It uses the old stuff instead of the new stuff...ugh */ function popup_call($type, $additionalParams) { switch($type) { // This Case Will Display The PopUp Window For Adding An Image // It first checks to see if the form is on stage though case('add_image'): if($('add_image_form_'+$additionalParams[1])){ if($section_type == 'listing_details'){ if($('images_content').style.display == "none"){ change_tabs($('images')); $('images').onclick(); } } window.location.href = '#add_image_form_'+$additionalParams[1]+'_a'; }else{ loadScript('/js/content_display/images.js'); popup.display('square', 'add_image', 'ADD AN IMAGE', $additionalParams); } break; // This Case Will Display The PopUp Window For Adding a Video // It first checks to see if the form is on stage though case('add_video'): if($('add_video_form_'+$additionalParams[1])){ if($section_type == 'listing_details'){ if($('videos_content').style.display == "none"){ change_tabs($('videos')); $('videos').onclick(); } } window.location.href = '#add_video_form_'+$additionalParams[1]+'_a'; }else{ loadScript('/js/content_display/videos.js'); popup.display('square', 'add_video', 'ADD A VIDEO', $additionalParams, callback_add_video); } break; // This Case Will Display The PopUp Window For Posting A Review // It first checks to see if the form is on stage though case('add_review'): if($('review_buisness_form_'+$additionalParams[1])){ if($section_type == 'listing_details'){ if($('reviews_content').style.display == "none"){ change_tabs($('reviews')); $('reviews').onclick(); } } window.location.href = '#review_buisness_form_'+$additionalParams[1]+'_a'; }else{ loadScript('/js/content_display/add_review.js'); loadScript('/js/content_display/reviews.js'); popup.display('square', 'add_review', 'REVIEW THIS BUSINESS', $additionalParams, callback_reviewBusinessDisplay); } break; } } /** * All Pop Calls should be ported through this function * @param string $type Indicating the type of popup content * @param array $additionalParams These will be passed into the AJAX call and also contain the H1 of the popup */ var popup={ norton:function() { /* God damn norton... I can't fix the problem, only let people know their virus software sucks...a lot. */ alert("This functionality has been disabled because of Norton Internet Security.\n"+ "Please disable NIS or add n49.ca to your list of safe sites in order to\n"+ "enjoy n49.ca." ); return false; }, login:function() { loadScript('/js/content_display/login.js'); this.display('circle', 'login', 'LOGIN'); }, forgot_password:function() { this.display('circle', 'forgot_password', 'FORGOT PASSWORD?'); }, tags_what:function() { this.display('circle', 'tags_what', 'WHAT ARE TAGS?'); }, tags_why:function() { this.display('circle', 'tags_why', 'WHY USE TAGS?'); }, tags_edit:function($additionalParams) { this.display('circle', 'tags_edit', 'EDIT TAGS', $additionalParams ); }, image_enlarge:function($additionalParams) { loadScript('/js/content_display/images.js'); this.display('square', 'image_enlarge', 'IMAGE GALLERY', $additionalParams, callback_image_enlarge); }, video_enlarge:function($additionalParams) { loadScript('/js/content_display/videos.js'); this.display('square', 'video_enlarge', 'VIDEO GALLERY', $additionalParams, callback_video_enlarge); }, quick_quote:function($additionalParams) { loadScript('/js/content_display/quick_quote.js'); this.display('square', 'quick_quote', 'QUICK QUOTE', $additionalParams); }, email_business:function($additionalParams) { loadScript('/js/content_display/email_business.js'); this.display('square', 'email_business', 'EMAIL A BUSINESS', $additionalParams); }, add_image:function($additionalParams) { if($('add_image_form_'+$additionalParams[1])){ if($section_type == 'listing_details'){ if($('images_content').style.display == "none"){ change_tabs($('images')); $('images').onclick(); } } window.location.href = '#add_image_form_'+$additionalParams[1]+'_a'; }else{ loadScript('/js/content_display/images.js'); this.display('square', 'add_image', 'ADD AN IMAGE', $additionalParams); } }, add_video:function($additionalParams) { if($('add_video_form_'+$additionalParams[1])){ if($section_type == 'listing_details'){ if($('videos_content').style.display == "none"){ change_tabs($('videos')); $('videos').onclick(); } } window.location.href = '#add_video_form_'+$additionalParams[1]+'_a'; }else{ loadScript('/js/content_display/videos.js'); this.display('square', 'add_video', 'ADD A VIDEO', $additionalParams, callback_add_video); } }, add_review:function($additionalParams) { if($('review_buisness_form_'+$additionalParams[1])){ if($section_type == 'listing_details'){ if($('reviews_content').style.display == "none"){ change_tabs($('reviews')); $('reviews').onclick(); } } window.location.href = '#review_buisness_form_'+$additionalParams[1]+'_a'; }else{ loadScript('/js/content_display/add_review.js'); loadScript('/js/content_display/reviews.js'); this.display('square', 'add_review', 'REVIEW THIS BUSINESS', $additionalParams, callback_reviewBusinessDisplay); } }, review_comment:function($additionalParams) { loadScript('/js/content_display/reviews.js'); this.display('square', 'review_comment', 'COMMENT ON THIS REVIEW', $additionalParams); }, article_comment:function($additionalParams) { loadScript('/js/content_display/articles.js'); this.display('square', 'article_comment', 'COMMENT ON THIS ARTICLE', $additionalParams); }, attach_article:function($additionalParams) { loadScript('/js/content_display/articles.js'); this.display('square', 'attach_article', 'ATTACH THIS ARTICLE', $additionalParams); }, lead_comment:function($additionalParams) { loadScript('/js/content_display/leads.js'); this.display('square', 'lead_comment', 'EDIT COMMENT', $additionalParams); }, edit_elt_txt:function ($additionalParams) { loadScript('/js/content_display/edit_caption.js'); this.display('square', 'edit_elt_txt', 'EDIT CAPTION', $additionalParams); }, email_friend:function ($additionalParams) { loadScript('/js/content_display/email_friend.js'); this.display('square', 'email_friend', 'EMAIL TO FRIEND', $additionalParams); }, add_favourites:function ($additionalParams) { this.display('circle', 'add_favourites', 'ADD TO FAVOURITES', $additionalParams); }, add_friend:function ($additionalParams) { loadScript('/js/content_display/members.js'); this.display('square', 'add_friend', 'ADD A FRIEND', $additionalParams); }, inappropriate:function ($additionalParams) { loadScript('/js/content_display/inappropriate.js'); this.display('square', 'inappropriate', 'INAPPROPRIATE?', $additionalParams); }, directory_browser:function ($additionalParams) { loadScript('/js/content_display/directory_browser.js'); this.display('square', 'directory_browser', 'FIND A BUSINESS'); }, what_is_public_private:function ($additionalParams) { this.display('circle', 'what_is_public_private', 'WHAT ARE THESE?', $additionalParams); }, report_bug:function ($additionalParams) { if( $additionalParams[0] == 'Link from footer' || $additionalParams['force_display']) { if($('bug')){ $('bug').value += "
"+$additionalParams[0]; $('bug_error_display').innerHTML += "
"+$additionalParams[0]; }else{ $additionalParams[0] = "URL: "+window.location+"
Browser: "+navigator.userAgent+"
"+$additionalParams[0]; loadScript('/js/content_display/report_bug.js'); this.display('square', 'report_bug', 'REPORT A BUG', $additionalParams); } } else { // Bugs are automatically submitted var params = new Array(); params[0] = window.location.href; params[1] = navigator.userAgent; params[2] = navigator.platform; params[3] = $additionalParams[0]; var json = new JSON; json.request('report_bug',params,callback_report_bug,'','/libs/JSON/misc_actions.php') ; } }, feedback:function ($additionalParams) { loadScript('/js/content_display/feedback.js'); this.display('square', 'feedback', 'FEEDBACK', $additionalParams); }, delete_business:function ($additionalParams) { loadScript('/js/content_display/delete_business.js'); this.display('square', 'delete_business', 'DELETE BUSINESS', $additionalParams); }, copy_image:function ($additionalParams) { this.display('square', 'copy_image', 'COPY IMAGE', $additionalParams); }, send_sms:function ($additionalParams) { this.display('square', 'send_sms', 'SEND TO PHONE', $additionalParams); }, /** * Sets up the container for diplay and calls for the content using AJAX and JSON * * @param string $popupType Indicating the type of popup element(circle, square) * @param array $contentType Sent as params[1] to indicate the type of popup content * @param string $h1_str The H1 to display in the popup * @param array $additionalParams These are passed into the AJAX call as params[3] * @param function customCallBack Is sent in if the AJAX call needs a differnt callBack then callback_popupContentDisplay */ display:function ($popupType, $contentType, $h1_str, $additionalParams, customCallBack) { // Bringing In The White Out If There Is No Popup Already if(document.body.firstChild.id != 'popupWrapper'){ // Making the height of the white out the same as the height of the wrapper $('fadeOver').style.height = ($('wrapper').scrollHeight+190)+"px"; // Calling the Appear for the fadeOver image setOpacity('fadeOver', 5); $('fadeOver').style.display = "block"; // Creaing a virtual DIV to set popupWrapper = document.createElement('div'); // Setting the class for the popup holder popupWrapper.className = 'popup_wrapper'; // Setting the class for the popup holder popupWrapper.id = 'popupWrapper'; // Writing the Div to the document as the first element in the body document.body.insertBefore(popupWrapper, document.body.firstChild); } // Creating a new name for this DIV Popup var thisElementID = $popupType+'_popup_'+popupIds; popupIds ++; // Creaing a virtual DIV to set var newPopup = document.createElement('div'); // Setting the class for the popup newPopup.className = 'popup_element'; newPopup.onmouseover = function(){ setDraggable(newPopup.id); } newPopup.onmouseout = function(){ clearDraggable(); } // Adding porperites to our 'newPopup' newPopup.id = thisElementID; // Figuring out the classes for the popups circle or square element var thisElementClass = ''; if($popupType == 'circle'){ thisElementClass = 'circle_element'; }else{ thisElementClass = 'square_element'; } // Setting up the base Div HTML Structure var thisElementContent = ''; thisElementContent += '
'; thisElementContent += '
'; // Writing the HTML to the DIV newPopup.innerHTML = thisElementContent; // Writing the Popup Div to popup div holder $(popupWrapper).appendChild(newPopup); // Making the AJAX call for the HTML content of the popup var params = new Array(); params[0] = newPopup.id; inlinePopups[params[0]] = false; params[1] = $contentType; params[2] = [$h1_str, $popupType]; // Only attaching the Extra Params If the $additionalParams is set as an array if(typeof $additionalParams == 'object'){ params[3] = $additionalParams; } var json = new JSON; if(customCallBack){ json.request('popup_content',params,customCallBack,'','/libs/JSON/misc_actions.php'); }else{ json.request('popup_content',params,callback_popupContentDisplay,'','/libs/JSON/misc_actions.php'); } // Stopping all playing videos videoBox_stopVideo('0'); // Adding the flash H1 now that the div has been writen to stage } }; var popupIds = 0; var popupTopZIndex = 10000; function popup_display($popupType, $contentType, $h1_str, $additionalParams, customCallBack) { popup.display($popupType, $contentType, $h1_str, $additionalParams, customCallBack); } function callback_report_bug($data){ return true; } /** * The Callback actions for popup_display * Checks for errors and closes the popup that was created for it if there are any * If there are no errors it sets the HTML, the display to 'block', put the popup on the top, and calls the centerStage function * * @param array $data [elementID, html] */ function callback_popupContentDisplay($data){ if($data){ if($data.err_code){ popup_close($data.elementID); error_handler_by_id($data.err_code, $data.err_str); }else{ var popup = $($data.elementID); var popup_content = $('popup_content_'+$data.elementID); var popup_element = $('popup_element_'+$data.elementID); popup_content.innerHTML = $data.html; centerStage($data.elementID); popup_element.style.visibility = "visible"; // poup and preloader stuff //////////////////////////////// /* $('popup_preloader_'+$data.elementID).style.top = popup.style.top; remove_element($('popup_preloader_image_'+$data.elementID)); popupAnimation($data.elementID); */ if( $('username') ) $('username').focus(); popup.style.zIndex = popupTopZIndex; popupTopZIndex ++; var params = { wmode: "transparent", quality: "high" }; var flashvars = { title:$data.h1_str }; swfobject.embedSWF("/swf/popup_h1_"+$data.popupType+".swf", 'popup_h1_flash_'+$data.elementID, "100%", "26", "8", '', flashvars, params); } } } /** * The Custom Popup Callback actions for add_video * Checks for errors and closes the popup that was created for it if there are any * If there are no errors uses callback_popupContentDisplay to populate the popup * It then writes the flash video player and the stars * * @param array $data [html, video_id, path] */ function callback_add_video($data){ if($data){ if($data.err_code){ popup_close($data.elementID); error_handler_by_id($data.err_code, $data.err_str); }else{ callback_popupContentDisplay($data); var videoUploads = $('videoUploads'); if(videoUploads){ var add_video_upload_status = false; var params = { wmode:"transparent", quality:"high" }; var flashvars = { user_id:$data.member_id, type:$data.type, id:$data.type_id, loggedin:getLoginString()}; swfobject.embedSWF("/swf/video_uploader.swf", "videoUploads", "520", "180", "8", '', flashvars, params); } } } } /** * The Custom Popup Callback actions for image_enlarge * Checks for errors and closes the popup that was created for it if there are any * If there are no errors uses callback_popupContentDisplay to populate the popup * It then writes the stars * * @param array $data [html, image_id, path] */ function callback_image_enlarge($data){ if($data){ if($data.err_code){ popup_close($data.elementID); error_handler_by_id($data.err_code, $data.err_str); }else{ if(!$('image_enlarge')){ $data.html = '
'+$data.html+'
'; callback_popupContentDisplay($data); }else{ popup_close($data.elementID); $('image_enlarge').innerHTML = $data.html; } var params = { wmode: "transparent", quality: "high" }; var flashvars = {rating:$data.rating, id:$data.image_id, rating_type:"image", loggedin:getLoginString()}; var divID = "image_enlarge_stars"; swfobject.embedSWF("/swf/rating.swf", divID, "70", "15", "6", '', flashvars, params); flashElements_ar.push(divID); } } } /** * The Custom Popup Callback actions for video_enlarge * Checks for errors and closes the popup that was created for it if there are any * If there are no errors uses callback_popupContentDisplay to populate the popup * It then writes the flash video player and the stars * * @param array $data [html, video.video_id, video.path, video.rating] */ function callback_video_enlarge($data){ if($data){ if($data.err_code){ popup_close($data.elementID); error_handler_by_id($data.err_code, $data.err_str); }else{ if(!$('video_enlarge')){ $data.html = '
'+$data.html+'
'; callback_popupContentDisplay($data); }else{ popup_close($data.elementID); $('video_enlarge').innerHTML = $data.html; } callback_popupContentDisplay($data); var params = { wmode: "transparent", quality: "high" }; var flashvars = {video_path:$data.video.path, fullScreen:"false"}; var divID = "video_player_large"; swfobject.embedSWF("/swf/mediaplayer.swf", divID, "525", "415", "9.0.47", '', flashvars, params); videoBox_ar.push(divID); var flashvars = {rating:$data.video.rating, id:$data.video.video_id, rating_type:"video", loggedin:getLoginString()}; var divID = "video_enlarge_stars"; swfobject.embedSWF("/swf/rating.swf", divID, "70", "15", "6", '', flashvars, params); flashElements_ar.push(divID); } } } function callback_reviewBusinessDisplay($data){ if($data){ if($data.err_code){ popup_close($data.elementID); error_handler_by_id($data.err_code, $data.err_str); }else{ callback_popupContentDisplay($data); var params = { wmode: "transparent", quality: "high" }; var flashvars = {}; flashvars.rating = $data.rating; flashvars.rating_type = "hidden_field"; flashvars.loggedin = "true"; swfobject.embedSWF("/swf/rating.swf", "rating_element", "140", "30", "6", '', flashvars, params); var rating = document.createElement("input"); rating.id = "rating"; rating.name = "params[4]"; rating.type = "hidden"; if($data.rating){ rating.value = $data.rating; }else{ rating.value = 0; } rating.onMouseDown = function(){ clearDragObject(); } $('rating_hidden_holder').appendChild(rating); } } } function flashSetRating(value) { $('rating').value = value; } /** * This checks an element until it has a width * It centers it inside of its parent element if it does * If it doesnt it uses setTimeout to call itself again * * @param string $elementID [elementID, html] */ function centerStage($elementID){ var element = $($elementID); if(element.scrollWidth){ // Setting the left posistion of the element to make it centered var thisElementLeft = (element.parentNode.clientWidth-element.clientWidth)/2; element.style.left = thisElementLeft+"px"; // Getting the scroll amount on the page var scroll = getScrollVal(); // Setting the top posistion to 10 px from the scroll top var thisElementTop = scroll[1]+20; element.style.top = thisElementTop+"px"; }else{ setTimeout('centerStage('+$elementID+')', 250); } } // This closes an open popup window. function popup_close($elementID){ videoBox_stopVideo('0'); var elt = $($elementID); var popupWrapper = $('popupWrapper'); if (popupWrapper) { popupWrapper.removeChild(elt); if(!popupWrapper.hasChildNodes()){ setOpacity('fadeOver', 0); $('fadeOver').style.display = "none"; document.body.removeChild(popupWrapper); } } } // Closes all open popup windows. function popup_close_all(){ var popupWrapper = $('popupWrapper'); // How many popups are in it var elements_length = popupWrapper.childNodes.length; if(elements_length <= 0){ clearDragObject(); setOpacity('fadeOver', 0); $('fadeOver').style.display = "none"; document.body.removeChild(popupWrapper); }else{ for(e=elements_length-1; e>=0 ;e--){ popup_close(popupWrapper.childNodes[e].id); } } } // Used to populate the right column with tags function tags_populate_right_col(section,type,title,tags) { // tags_right_col => defined in the main page if( $('rcol_tags_title') ){ // if(!tags_right_col) var tags_right_col = new Array(); // Cache the data to prevent another JSON call if(!tags_right_col[section]) tags_right_col[section] = new Array(); if(!tags_right_col[section][type]) tags_right_col[section][type] = new Array(); if(!tags_right_col[section][type]['title']) { tags_right_col[section][type]['title'] = title; tags_right_col[section][type]['data'] = tags; } if( title || tags_right_col[section][type]['title'] ) { if( tags_right_col[section][type] && title==undefined ) { title = tags_right_col[section][type]['title']; tags = tags_right_col[section][type]['data']; } $('rcol_tags_title').innerHTML = title; var tagList =''; for( i=0; i'+ tags[i].name +''+"\n"; } $('rcol_tags_list').innerHTML = tagList; } } } // Used for adding a favourite function submit_add_favourites($element){ var params = new Array(); params[0] = $('tags').value; params[1] = $('public_private').value; params[2] = $('fav_type').value; params[3] = $('id').value; params[4] = $('type').value; params[5] = $('type_id').value; params[6] = getPopUpWrapperId($element); var json = new JSON; // alert(params); json.request('add_favourite',params,callback_submit_add_favourites,'','/libs/JSON/member_actions.php'); return false; } // The Callback from submit_report_bug() function callback_submit_add_favourites($data) { if ($data.err_code) { error_handler_by_id($data.err_code, $data.err_str) }else{ var url_ar = getCurrentURL(); if(url_ar['file'] != 'actions.php'){ // Close the login popup window popup_close($data.elementID); }else{ var redirectLocation = '/members/'; if($('referer')){ redirectLocation = $('referer').value; } window.document.location = redirectLocation; } } } // Deletes a listing from a member's favourites. function request_delete_favourites($type, $id, $element){ var answer = confirm('Are you sure you want to delete this favourite?'); if (answer){ enterPreLoader($element); $element.innerHTML += '

deleting favourite

'; var params = new Array(); params[0] = $id; params[1] = $type; params[2] = $element.id; var json = new JSON; json.request('delete_favourite',params,callback_delete_favourites,'','/libs/JSON/member_actions.php') ; } } // The callback from request_delete_favourites function callback_delete_favourites($data){ if($data.err_code) { error_handler_by_id($data.err_code); } else { var element = $($data.elementID); remove_element(element); // Changing all the favourites count tags based on the favourites type var spans = document.getElementsByName('num_favouritess_'+$data.type); var length = spans.length; for(i = 0; i < length; i += 1){ spans[i].innerHTML = $data.count; } } } // Used for editing a favourite listing function submit_tags_edit($element){ var params = new Array(); params[0] = $('tags').value; params[1] = $('public_private').value; params[2] = $('fav_type').value; params[3] = $('id').value; params[4] = getPopUpWrapperId($element); var json = new JSON; // alert(params); json.request('submit_tags_edit',params,callback_submit_tags_edit,'','/libs/JSON/tags_actions.php'); return false; } // Used for editing a favourite listing function callback_submit_tags_edit($data){ if($data.err_code) { error_handler_by_id($data.err_code); } else { popup_close($data.elementID); window.location.reload(); } } // Removes a item from the DOM function remove_element($element){ if($element) { $element.parentNode.removeChild($element); } } // Edits the adword iframes function changeAdSense(){ var googleAds = document.getElementsByName('google_ads_frame'); var googleLen = googleAds.length; for(var i=0;i([\w\W]*)\
/;if(result.match(reg_json)){popup.report_bug(["JSON Repsonse error: "+RegExp.$1]);}else{return new Function("return "+json)();}}; }(); function rating_stars(swfPath,ratingType,ratingID,rating,image_id,width,height) { if(width==undefined) width=70; if(height==undefined) height=15; var params = { wmode: "transparent", quality: "high" }; var flashvars = {}; flashvars.rating = rating; flashvars.id = image_id; flashvars.rating_type = ratingType; flashvars.loggedin = getLoginString(); swfobject.embedSWF(swfPath, ratingID, width, height, "6", '', flashvars, params); } /** * SWFObject v2.1: Flash Player detection and embed - http://code.google.com/p/swfobject/wiki/documentation * * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License: * http://www.opensource.org/licenses/mit-license.php * */ var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("