if (typeof console == "undefined") { var console = {log:function(dummy){}}; }
/**
* Functions for controlling the suggestion stuff
*/
var didyoumean_states={};
function switch_didyoumean(element_id) {
if (didyoumean_states[element_id]==undefined || didyoumean_states[element_id]=='short') {
$("#short_"+element_id).css({display:'none'});
$("#extended_"+element_id).css({display:'inline'});
didyoumean_states[element_id]='extended';
$("#"+element_id+"_switch").text("less...");
} else if (didyoumean_states[element_id]=='extended') {
$("#short_"+element_id).css({display:'inline'});
$("#extended_"+element_id).css({display:'none'});
didyoumean_states[element_id]='short';
$("#"+element_id+"_switch").text("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').removeClass().addClass('offTab javaTab');
element.className = 'overTab javaTab';
$('#what_who_input').attr('value', "who");
$('#search_details_what').hide();
$('#search_details_who').css({display:"inline"});
$('#header_search').attr('action', $('#action_who').attr('value'));
$('#searchwhat').attr('name', 'name');
var whoVal = get_cookie('saved_input_name');
$('#searchwhat').text((whoVal)? whoVal : "");
}
function click_what(element){
$('#searchwhat').focus();
element.className = 'overTab javaTab';
$('#who_tab').removeClass().addClass('offTab javaTab');
$('#what_who_input').text("what");
$('#search_details_what').css({display:"inline"});
$('#search_details_who').hide();
$('#header_search').attr('action', $('#action_what').attr('value'));
$('#searchwhat').attr('name', 'searchwhat');
var whatVal = get_cookie('saved_input_searchwhat');
$('#searchwhat').text((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).html($data.html);
}
var loaded_scripts=[];
/**
* 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;
}
/**
* 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={
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);
},
image_enlarge_switch:function($additionalParams) {
var json = new JSON;
var params = ['popup_content_square_popup_'+popupIds, 'image_enlarge', ['Image Enlarge', 'square']];
inlinePopups[params[0]] = false;
// Only attaching the Extra Params If the $additionalParams is set as an array
if(typeof $additionalParams == 'object'){ params[3] = $additionalParams; }
var json = new JSON;
json.async = false;
json.request('popup_content',params,function($data){$('#popup_content_square_popup_'+(popupIds-1)).html($data.html);},'','/libs/JSON/misc_actions.php');
},
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])[0]){
if($section_type == 'listing_details'){
if($('#images_content').is(":hidden")){
change_tabs($('#images')[0]);
$('#images').click();
}
}
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])[0]){
if($section_type == 'listing_details'){
if($('#videos_content').is(":hidden")){
change_tabs($('#videos')[0]);
$('#videos').click();
}
}
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])[0]){
if($section_type == 'listing_details'){
if($('#reviews_content').is(":hidden")){
change_tabs($('#reviews')[0]);
$('#reviews').click();
}
}
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')[0]){
$('#bug').attr('value', $('#bug').attr('value')+"
"+$additionalParams[0]);
$('#bug_error_display').html($('#bug_error_display').html()+"
"+$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);
},
choose_image:function($additionalParams) {
this.display('square', 'choose_image', 'CHOOSE AN IMAGE', $additionalParams);
},
fade_out:function() {
if(document.body.firstChild.id != 'popupWrapper'){
// Making the height of the white out the same as the height of the wrapper
$('#fadeOver').height($(document).height());
// Calling the Appear for the fadeOver image
$('#fadeOver').css({display:"block", opacity:0})
$('#fadeOver').fadeTo("fast", 0.5);
$('#fadeOver').dblclick(popup_close_all);
popupWrapper = document.createElement('div');
popupWrapper.className = 'popup_wrapper';
popupWrapper.id = 'popupWrapper';
document.body.insertBefore(popupWrapper, document.body.firstChild);
} else {
$("#popupWrapper").fadeIn();
$("#fadeOver").fadeIn();
}
},
/**
* 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
popup.fade_out();
// 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');
newPopup.className = 'popup_element';
newPopup.id = thisElementID;
if($popupType == 'circle'){
var thisElementClass = 'circle_element';
}else{
var thisElementClass = 'square_element';
}
// Setting up the base Div HTML Structure
var thisElementContent = ' | ';
thisElementContent += ' | |
';
// Writing the HTML to the DIV
newPopup.innerHTML = thisElementContent;
newPopup.style.display='none';
newPopup.style.width="100%";
// Writing the Popup Div to popup div holder
popupWrapper.appendChild(newPopup);
$("#"+thisElementID).show("normal");
// Making the AJAX call for the HTML content of the popup
var params = [newPopup.id, $contentType, [$h1_str, $popupType]];
inlinePopups[params[0]] = false;
// 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');
}
videoBox_stopVideo('0');
}
};
/* 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):
case(ERR_DELETED):
case(ERR_DISABLED):
case(ERR_FAILED):
case(ERR_MISSING):
case(ERR_LOGIN_INCORRECT):
case(ERR_DENIED):
alert(error_string);
break;
default:
popup.report_bug(["AJAX error: "+error_string+"(#"+error_id+")"]);
break;
}
return false;
}
var JSON_timeout = [];
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;
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));
}
}
// 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() {
//alert('type 1' + window.pageXOffset+" "+window.pageYOffset);
return [window.pageXOffset,window.pageYOffset];
}
}else if (document.documentElement && (typeof(document.documentElement.scrollLeft)=='number' || typeof(document.documentElement.scrollTop)=='number')) {
//IE6 standards compliant mode
getScrollVal = function() {
//alert("Type stupid: " + document.documentElement.scrollLeft+" "+document.documentElement.scrollTop);
return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
}
}else if (document.body && (typeof(document.body.scrollLeft) == 'number' || typeof(document.body.scrollTop)=='number')) {
//DOM compliant (IE isn't DOM compliant...Have to put the IE6 one first)
getScrollVal = function() {
return [document.body.scrollLeft,document.body.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){
$("#"+lastTab.id+"_content").hide();
}
$("#"+liThis.id+"_content").show();
}
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).text(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 = {};
/**
* If the element this is called on is inside a popup, it'll return the ID of the popup its in. Otherwise it'll false.
* This is an upgraded version so that it can be used on -any- element inside a popup, instead of only the form element.
* @param element $element A element (hopefully) inside of a popup
*/
function getPopUpWrapperId($element){ // Yuck.
if ($element.id && ( $element.id.substr(0,13) == 'square_popup_' || $element.id.substr(0,13) == 'circle_popup_' )) {
return $element.id;
} else if ($element.parentNode) {
return getPopUpWrapperId($element.parentNode);
} else {
return false;
}
}
/**
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) {
case('add_image'): popup.add_image($additionalParams); break;
case('add_video'): popup.add_video($additionalParams); break;
case('add_review'): popup.add_review($additionalParams); break;
}
}
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;
}
popup_close = function ($elementID) {
if (typeof $elementID == 'undefined') {
what = this;
} else {
console.log('Deprecated use of popup_close. Please revise.');
what = "#"+$elementID;
}
$(what).fadeOut("normal", function(){ $("#popupWrapper").fadeOut("normal", function() { $('#fadeOver').fadeOut("normal"); } ).remove() });
}
/**
* 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' and puts the popup on the top
*
* @param array $data [elementID, html]
*/
function callback_popupContentDisplay($data){
if($data){
if($data.err_code){
// popup_close_all();
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.html($data.html);
var top = getScrollVal()[1] + 20;
popup_element.css({visibility:"visible", opacity:0.1,"top":top});
popup_element.animate({opacity:1}, "normal");
if($('#username')[0]) $('#username').focus();
popup.css({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);
popup[0].close = popup_close;
}
}
}
/**
* 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_all();
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_all();
error_handler_by_id($data.err_code, $data.err_str);
}else{
if(!$('#image_enlarge')[0]){
$data.html = ''+$data.html+'
';
callback_popupContentDisplay($data);
$("#"+$data.elementID).css({visibility:"hidden"});
}else{
popup_close_all();
$('#image_enlarge').html($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_all();
error_handler_by_id($data.err_code, $data.err_str);
}else{
if(!$('#video_enlarge')[0]){
$data.html = ''+$data.html+'
';
callback_popupContentDisplay($data);
}else{
popup_close_all();
$('#video_enlarge').html($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_all();
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').append(rating);
}
}
}
function flashSetRating(value) {
$('#rating').attr('value', value);
}
// Closes all open popup windows.
function popup_close_all(e){
var use_event = null;
if (typeof e != 'undefined') {
use_event = e;
} else if (typeof window.event != 'undefined') {
use_event = window.event;
}
if (use_event) {
if (typeof use_event.preventDefault != 'undefined') {
use_event.preventDefault();
}
}
try {
$('#popupWrapper').children().each(function(that){ if (typeof this.close == "function") { this.close(); } else { $(this).fadeOut(); } });
} catch (E){console.log(E);}
$("#fadeOver").fadeOut('normal', function() {
$("#popupWrapper").fadeOut('normal', function() {
$("#popupWrapper").remove();
})
});
}
// 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] && typeof title=="undefined" ) {
title = tags_right_col[section][type]['title'];
tags = tags_right_col[section][type]['data'];
}
$('#rcol_tags_title').text(title);
var tagList ='';
for( i=0; i'+ tags[i].name +''+"\n";
}
$('#rcol_tags_list').html(tagList);
}
}
}
// Used for adding a favourite
function submit_add_favourites($element){
var params = new Array();
params[0] = $('#tags').attr('value');
params[1] = $('#public_private').attr('value');
params[2] = $('#fav_type').attr('value');
params[3] = $('#type_id').attr('value');
params[4] = $('#type').attr('value');
params[5] = $('#from_id').attr('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_all();
}else{
var redirectLocation = '/members/';
if($('#referer')[0]){ redirectLocation = $('#referer').attr('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();
// 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').attr('value');
params[1] = $('#public_private').attr('value');
params[2] = $('#fav_type').attr('value');
params[3] = $('#id').attr('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_all();
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("