function toggleContestRules() { var indicator = $("#indicator").attr('src'); if (indicator == '/images/indicator_up.png') { $('#contest_handle_container').animate({ marginTop: '100' }, 500, function() { $("#indicator").attr('src','/images/indicator_down.png'); }); } else { $('#contest_handle_container').animate({ marginTop: '292' }, 500, function() { $("#indicator").attr('src','/images/indicator_up.png'); }); } } function pinMenuToTop() { var scrolltop = $("body").scrollTop(); if (scrolltop==0) { scrolltop = $("html").scrollTop(); } if (scrolltop > 2500) { $("#footer").css('display','block'); } else { $("#footer").css('display','none'); } } /* --------------------------------------------------------------------------------------- */ $(document).ready(function() { $("#breeds_extra_menu ul li").hover( function () { $(this).children().css("display", "block"); }, function () { $(this).children().css("display", "none"); } ); }); /* --------------------------------------------------------------------------------------- */ function showBreedsExtra() { var visible = $("#breeds_extra_menu").css('display'); if (visible=='none') { $("#breeds_extra_btn").attr('src','/images/arrow_menu_extra_down.png'); $("#breeds_extra_menu").css('display','block').css('z-index','9999'); } else { $("#breeds_extra_btn").attr('src','/images/arrow_menu_extra_left.png'); $("#breeds_extra_menu").css('display','none').css('z-index','0'); } } /* --------------------------------------------------------------------------------------- */ function sendFeedback() { var error = 0; var error_msg = ''; var email = $("#feedback_email").val(); var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i); if (pattern.test(email)==false) { error_msg = error_msg+"• Invalid email address
"; error = 1; } var name = $("#feedback_name").val(); if (name=='') { error_msg = error_msg+"• Please provide your name
"; error = 1; } var message = $("#feedback_message").val(); if (message=='') { error_msg = error_msg+"• Please enter a message
"; error = 1; } if (error==1) { $("#feedback_form_error_msg").css('display','block').html(error_msg); } else { var captcha = $("input[name=captcha]").val(); $("#feedback_submit_btn").html("Processing..."); var request = $.ajax({ url: "/lib/captcha/captcha.php", type: "POST", data: {captcha : captcha}, async: false, dataType: "html" }); request.done(function(msg) { if (msg==1) { $("#captcha_error").css('display','none'); } else { error_msg = error_msg+"• Verification failed: please try again
"; error = 1; } $("#feedback_submit_btn").html("SEND FEEDBACK"); }); if (error==1) { $("#feedback_form_error_msg").css('display','block').html(error_msg); } if (error==0) { $("#feedback_form_error_msg").css('display','none'); $("#feedback_submit_btn").html("Processing..."); var user_id = $("#user_id").val(); var request = $.ajax({ url: "/ajax/feedback.php", type: "POST", data: { name : name, email : email, message : message, user_id : user_id }, dataType: "html" }); request.done(function(msg) { if (msg==1) { $("#myForm").remove(); $("#feedback_form").append("
Success: your message has been sent.
You can expect a reply within 48 hours.
Thank you, your input is valued to us!"); $("#feedback_submit_btn").html("Message sent!"); $("#feedback_submit_btn").removeAttr('onclick'); setTimeout('hideFeedbackForm()', 5000); } }); } } } /* --------------------------------------------------------------------------------------- */ function displayFeedbackForm() { $("#overlay").html(''); $("#back_to_top").css('display','none'); displayOverlay(); $("#feedback_form_container").css('display','block'); } /* --------------------------------------------------------------------------------------- */ function hideFeedbackForm() { hideOverlay(); $("#overlay").html('Loading...

'); $("#feedback_form_container").css('display','none'); } /* --------------------------------------------------------------------------------------- */ $(document).keyup(function(e) { if (e.keyCode == 27) { hideNotLoggedInMessage(); hideFeedbackForm(); hideUploadForm(); $("#autocompleteResults").remove(); $("#quiz_results_modal_container").css('display','none'); $("#suggest_a_name_modal").css('display','none'); } }); /* --------------------------------------------------------------------------------------- */ function keyUpFeedbackMessage() { var left = 350 - $('#feedback_message').val().length; console.log($('#feedback_message').val()); if (left < 0) { left = 0; var desc = $('#feedback_message').val(); var substr = desc.substring(0,350); $('#feedback_message').val(substr); } $('#feedback_word_count').text(left); } /* --------------------------------------------------------------------------------------- */ function jumpToAnchor(id,extra) { var distanceFromTop = $("#"+id).offset().top; if (id=='mystuff_1') { $('html, body').animate({ scrollTop: '0' }, 250); } else { if (extra==1) { var realDistanceFromTop = parseInt(distanceFromTop)-152; $('html, body').animate({ scrollTop: realDistanceFromTop }, 500); } else if (extra==2) { var realDistanceFromTop = parseInt(distanceFromTop)-62; $('html, body').animate({ scrollTop: realDistanceFromTop }, 500); } else { var realDistanceFromTop = parseInt(distanceFromTop)-222; $('html, body').animate({ scrollTop: realDistanceFromTop }, 500); } } } /* --------------------------------------------------------------------------------------- */ function switchPostToVideo(channel,video_id,image_id) { if (channel=='youtube') { var embed_code = ''; $("#image_container_"+image_id).html(embed_code); } else if (channel=='dailymotion') { var embed_code = ''; $("#image_container_"+image_id).html(embed_code); } else { var embed_code = ''; $("#image_container_"+image_id).html(embed_code); } } /* --------------------------------------------------------------------------------------- */ function showModalComingSoon() { var availWidth = screen.availWidth; var distanceFromLeft = (parseInt(availWidth) - 504) / 2; var scrolltop = $("html").scrollTop(); var distanceFromTop = parseInt(scrolltop) + 124; var distanceToMove = parseInt(scrolltop) - 124; $("#overlay").html(''); displayOverlay(); $("#coming_soon_modal").css('top',distanceToMove+'px').css('left',distanceFromLeft+"px"); $("#coming_soon_modal").animate({'opacity':1, 'top': distanceFromTop+"px"}, { duration:1000, easing: 'easeOutBounce', complete: function(){ //alert(distanceToMove); setTimeout(function(){ $("#coming_soon_modal").animate({'opacity':0, 'top':distanceToMove+'px'}, { duration:500, easing: 'easeInBack' }); hideOverlay2(); },3000); } }); } /* --------------------------------------------------------------------------------------- */ function hideModalComingSoon() { var scrolltop = $("html").scrollTop(); var distanceToMove = parseInt(scrolltop) - 124; $("#coming_soon_modal").animate({'opacity':0, 'top':distanceToMove+'px'}, { duration:500, easing: 'easeInBack', complete: function() { //alert(distanceToMove); hideOverlay2(); } }); } /* --------------------------------------------------------------------------------------- */ function likeDislike(id,type) { if (type=='1') { $("#button_like_"+id).html("Processing...").removeAttr('onclick'); } else { $("#button_dislike_"+id).html("Processing...").removeAttr('onclick'); } // AJAX MODIFIED var request = $.ajax({ url: "/ajax/likes.php", data: { photo_id: id, like_type: type}, type: "POST", dataType: "html" }); request.done(function(data) { if (type=='1') { var btn_id = "#button_like_"+id; var btn2_id = "#button_dislike_"+id; // ATTR CLASS MODIFIED if ($(btn_id).hasClass('button_liked')) { $(btn_id).removeClass('button_liked').addClass('button_like'); $(btn2_id).removeClass('button_disliked').addClass('button_dislike'); } else if ($(btn_id).hasClass('button_like')) { $(btn_id).removeClass('button_like').addClass('button_liked'); $(btn2_id).removeClass('button_disliked').addClass('button_dislike'); } } if (type=='0') { var btn_id = "#button_dislike_"+id; var btn2_id = "#button_like_"+id; // ATTR CLASS MODIFIED if ($(btn_id).hasClass('button_disliked')) { $(btn_id).removeClass('button_disliked').addClass('button_dislike'); $(btn2_id).removeClass('button_liked').addClass('button_like'); } else if ($(btn_id).hasClass('button_dislike')) { $(btn_id).removeClass('button_dislike').addClass('button_disliked'); $(btn2_id).removeClass('button_liked').addClass('button_like'); } } var likes = data.split(":"); var div_likes = "#nbLikes_"+id; $(div_likes).html(likes[0]); var div_dislikes = "#nbDislikes_"+id; $(div_dislikes).html(likes[1]); if (type=='1') { $("#button_like_"+id).html('').attr('onclick','likeDislike('+id+',1)'); } else { $("#button_dislike_"+id).html('').attr('onclick','likeDislike('+id+',0)'); } }); } /* --------------------------------------------------------------------------------------- */ function displayLoader() { var loader = '
Loading...

'; $("#left_container_content").append(loader); } /* --------------------------------------------------------------------------------------- */ function removeContestHelptext() { $("#contest_template").fadeOut(); $("#pictures_details_page_title_extra").fadeOut(); } /* --------------------------------------------------------------------------------------- */ function hideLoader() { $("#loader").remove(); } /* --------------------------------------------------------------------------------------- */ function viewMoreSearchResults() { var term = $("#s").val(); window.location='/search?term='+term; } /* --------------------------------------------------------------------------------------- */ function jumpToAdvancedSearch() { var term = $("#s").val(); window.location='/advanced_search?term='+term; } /* --------------------------------------------------------------------------------------- */ function loadAds() { // AJAX MODIFIED var request = $.ajax({ url: '/ajax/ads.php', type: "POST", dataType: "html" }); request.done(function(data) { $('#right_container').html(data); }); } /* --------------------------------------------------------------------------------------- */ function header_breed_search_focus(value) { if (value=='Breed name...') { $("#header_breed_search").val(''); } } /* --------------------------------------------------------------------------------------- */ function header_breed_search_blur(value) { if (value=='') { $("#header_breed_search").val('Breed name...'); } } /* --------------------------------------------------------------------------------------- */ function header_breed_search_selected() { var breed = $("#s").val(); var page = $("#page").val(); if (page=='/dog_pictures') { reloadListWithOptions(); } else { breed = breed.replace('/[a-zA-Z]|\s/', ''); breed = breed.replace(/\s/g, "_") window.location='/breed/'+breed; } } /* --------------------------------------------------------------------------------------- */ function displayUploadForm() { $("#overlay").html(''); displayOverlay(); $("#upload_form").css('display','block'); $("#upload_inner_container").css('display','block'); $("#upload_succes_message").html(''); } /* --------------------------------------------------------------------------------------- */ function displayUploadFormWithBreed(breed_id) { $("#overlay").html(''); displayOverlay(); $("#upload_form").css('display','block'); $("#upload_inner_container").css('display','block'); $("#upload_succes_message").html(''); var request = $.ajax({ url: "/ajax/get_single_breed_autocomplete.php", type: "POST", data: {id : breed_id}, dataType: "html" }); request.done(function(msg) { $("#upload_breeds").css("display","none"); $("#upload_breeds_selected").html( msg ); }); } /* --------------------------------------------------------------------------------------- */ function displayUploadFormForContest(id) { $("#overlay").html(''); $("#contest_id").val(id); displayOverlay(); $("#upload_form").css('display','block'); $("#upload_inner_container").css('display','block'); $("#upload_succes_message").html(''); } /* --------------------------------------------------------------------------------------- */ function hideUploadForm() { $("#upload_form").css('display','none'); hideOverlay(); $("#overlay").html('Loading...

'); $("#autocompleteResults").remove(); } /* --------------------------------------------------------------------------------------- */ function displayNotLoggedInMessage() { $("#overlay").html(''); displayOverlay(); $("#register").css('display','block'); } /* --------------------------------------------------------------------------------------- */ function hideNotLoggedInMessage() { $("#register").css('display','none'); hideOverlay(); $("#overlay").html('Loading...

'); } /* --------------------------------------------------------------------------------------- */ function displayOverlay() { $("#overlay").css('display','block'); } /* --------------------------------------------------------------------------------------- */ function hideOverlay() { $("#overlay").css('display','none'); } /* --------------------------------------------------------------------------------------- */ function hideOverlay2() { $("#overlay").fadeOut('slow', function() { $("#overlay").html('Loading...

'); }); } /* --------------------------------------------------------------------------------------- */ function fix_flash() { // loop through every embed tag on the site var embeds = document.getElementsByTagName('embed'); for (i = 0; i < embeds.length; i++) { embed = embeds[i]; var new_embed; // everything but Firefox & Konqueror if (embed.outerHTML) { var html = embed.outerHTML; // replace an existing wmode parameter if (html.match(/wmode\s*=\s*('|")[a-zA-Z]+('|")/i)) new_embed = html.replace(/wmode\s*=\s*('|")window('|")/i, "wmode='transparent'"); // add a new wmode parameter else new_embed = html.replace(//i)) new_object = html.replace(//i, ""); // add a new wmode parameter else new_object = html.replace(/<\/object\>/i, "\n"); // loop through each of the param tags var children = object.childNodes; for (j = 0; j < children.length; j++) { try { if (children[j] != null) { var theName = children[j].getAttribute('name'); if (theName != null && theName.match(/flashvars/i)) { new_object = new_object.replace(//i, ""); } } } catch (err) { } } // replace the old embed object with the fixed versiony object.insertAdjacentHTML('beforeBegin', new_object); object.parentNode.removeChild(object); } } } $(document).ready(function () { fix_flash(); }); /* --------------------------------------------------------------------------------------- */ function jumpToTop() { $('html, body').animate({ scrollTop: 0 }, 500); $("#back_to_top").css('display','none'); } function uploadInProgress() { var btn_text = $("#upload_submit_btn").html(); if ((btn_text=='SUBMIT PICTURE') || (btn_text=='SUBMIT VIDEO')) { $("#upload_submit_btn").html('UPLOAD IN PROGRESS, PLEASE WAIT...'); $("#upload_submit_btn").removeAttr('onclick'); } } function uploadComplete() { // ATTR CLASS MODIFIED if ($("#upload_box_top").hasClass('upload_box_top_1')) { $("#upload_submit_btn").html('SUBMIT PICTURE'); $("#upload_submit_btn").attr('onclick','return validateUploadForm();'); } else { $("#upload_submit_btn").html('SUBMIT VIDEO'); $("#upload_submit_btn").attr('onclick','return validateUploadForm();'); } } function uploadError() { $("#upload_submit_btn").html('UPLOAD ERROR, PLEASE REFRESH THE PAGE AND TRY AGAIN.'); } function validateUploadForm() { var error = 0; var title = $("#upload_title").val(); if (title=='') { $("#upload_title").css('border','1px solid #ff0000').focus(); error = 1; } else { if (title.length > 50) { var substr = title.substring(0,50); $("#upload_title").val(substr); } $("#upload_title").css('border','1px solid #dedede'); } var category = $(".upload_category_active").attr('id'); if (category==undefined) { $("#upload_error_message_category").html("You must choose a category"); error = 1; } else { $("#upload_error_message_category").html(''); } // ATTR CLASS MODIFIED if ($("#upload_box_top").hasClass('upload_box_top_1')) { // type = images var uploaded_file = $("#uploaded_file").val(); if (uploaded_file=='') { $("#upload_error_message_file").html("You must upload an image"); error = 1; } else { $("#upload_error_message_file").html(''); } } else { // type = videos var video_type = $(".upload_video_category_active").attr('id'); if (video_type==undefined) { $("#upload_error_message_file").html('You must choose either Embed, URL, or Upload'); error = 1; } else { $("#upload_error_message_file").html(''); if (video_type=='upload_video_category_1') { // video = url var video_url = $("#video_url").val(); if (video_url=='') { $("#upload_error_message_file").html('Please enter a valid URL'); error = 1; } else { // AJAX MODIFIED var request = $.ajax({ url: '/ajax/url_validator.php', type: "POST", data: { url: video_url }, dataType: "html" }); request.done(function(data) { if (data=='1') { $("#upload_error_message_file").html(''); } else { $("#upload_error_message_file").html('Please enter a valid URL'); error = 1; } }); } } if (video_type=='upload_video_category_2') { // video = embed var video_embed_code = $("#video_embed_code").val(); if (video_embed_code=='') { $("#upload_error_message_file").html('Please enter a valid embed code'); error = 1; } else { $.ajax({ url: '/ajax/embed_validator.php', type: "POST", data: { code: video_embed_code }, success: function(data) { if (data=='1') { $("#upload_error_message_file").html(''); } else { $("#upload_error_message_file").html('Please enter a valid embed code'); error = 1; } } }); $("#upload_error_message_file").html(''); } } if (video_type=='upload_video_category_3') { // video = upload var uploaded_file = $("#uploaded_file").val(); if (uploaded_file=='') { $("#upload_error_message_file").html("You must upload a video"); error = 1; } } } } if (error == '0') { // form fully validated, send to ajax > create_user_content.php // 1- type (image / video) // ATTR CLASS TO MODIFY if ($("#upload_box_top").hasClass('upload_box_top_1')) { var upload_type = 'image'; } else { var upload_type = 'video'; } // 2- title var title = $("#upload_title").val(); // 3- description var description = $("#upload_description").val(); // 4- breed(s) var breed_images = ''; var breeds = $(".selectedBreed").each( function() { var img = $(this).find('img').attr('src'); img = img.replace('/uploads/breed_pics/thumb/',''); breed_images = breed_images+img+'|'; }); // 5- if image, uploaded file if (upload_type=='image') { var video_url = ''; var video_embed_code = ''; var uploaded_file = $("#uploaded_file").val(); } // 6a- if video URL > url // 6b- if video embed > embed // 6c- if video upload > file if (upload_type=='video') { var video_url = ''; var video_embed_code = ''; var uploaded_file = ''; // ATTR CLASS MODIFIED if ($("#upload_video_category_1").hasClass('upload_video_category_active')) { video_url = $("#video_url").val(); } // ATTR CLASS MODIFIED if ($("#upload_video_category_2").hasClass('upload_video_category_active')) { video_embed_code = $("#video_embed_code").val(); } // ATTR CLASS MODIFIED if ($("#upload_video_category_3").attr('upload_video_category_active')) { uploaded_file = $("#uploaded_file").val(); } } // 7- category var category = $(".upload_category_active").attr('id'); //8- salt var salt = $("#salt").val(); //8- contest id var contest_id = $("#contest_id").val(); //9- pet_id var pet_id = $("#pet option:selected").val(); /* alert('UPLOAD TYPE = '+upload_type+'\r\n'+ 'TITLE = '+title+'\r\n'+ 'DESCRIPTION = '+description+'\r\n'+ 'BREEDS = '+breed_images+'\r\n'+ 'UPLOADED FILE = '+uploaded_file+'\r\n'+ 'VIDEO URL = '+video_url+'\r\n'+ 'CONTEST ID = '+contest_id+'\r\n'+ 'VIDEO EMBED CODE = '+video_embed_code+'\r\n'+ 'CATEGORY = '+category+'\r\n'+ 'PET ID = '+pet_id+'\r\n'+ 'SALT = '+salt); */ // AJAX MODIFIED var request = $.ajax({ url: "/ajax/create_user_content.php", type: "POST", data: { upload_type: upload_type, title: title, contest_id: contest_id, description: description, breed_images: breed_images, uploaded_file: uploaded_file, video_url: video_url, video_embed_code: video_embed_code, category: category, salt: salt, pet_id: pet_id }, dataType: "html" }); request.done(function(data) { if (data=='0') { alert('Upload failed, please try again'); // upload failed, notify user } else if (data=='1') { // upload success, notify user, set timeout to close window $("#upload_inner_container").css('display','none'); $("#upload_succes_message").css('color','#8bd0fc').html('UPLOAD WAS SUCCESSFUL'); $("#upload_submit_btn").html('CLOSE'); $("#upload_submit_btn").attr('onclick','hideUploadForm();'); setInterval(function(){ window.location.reload(); },3000); } else if (data=='2') { // file is too small $("#upload_error_message_file").css('color','#ff0000').html('This image is too small, please try another.'); $("#upload_submit_btn").attr('onclick','return validateUploadForm();'); $(".qq-upload-success").fadeOut(1500).remove(); } }); } } function selectVideoCategory(id) { $(".upload_video_category_active").removeClass('upload_video_category_active').addClass('upload_video_category'); var div = "#upload_video_category_"+id; $(div).addClass('upload_video_category_active').removeClass('upload_video_category'); if (id==3) { $("#upload_file_video_upload").css('display','block'); $("#upload_file_video_text_embed").css('display','none'); $("#upload_file_video_text_url").css('display','none'); var uploader2 = new qq.FileUploader({ element: document.getElementById('upload_file_video'), action: '/upload_video.php', allowedExtensions: ['mpg', 'mpeg', 'avi', 'mov', 'mp4'], onComplete: function(id, fileName, responseJSON){ $("#uploaded_file").val(responseJSON.filename); $("#salt").val(responseJSON.salt); } }); $("#upload_error_message_file").html(''); } else if (id==2) { $("#upload_file_video_upload").css('display','none'); $("#upload_file_video_text_embed").css('display','block'); // get salt and put in input $.ajax({ url: '/ajax/generate_salt.php', success: function(data) { $('#salt').val(data); } }); $("#upload_file_video_text_url").css('display','none'); $("#upload_error_message_file").html(''); } else if (id==1) { $("#upload_file_video_upload").css('display','none'); $("#upload_file_video_text_embed").css('display','none'); $("#upload_file_video_text_url").css('display','block'); // get salt and put in input $.ajax({ url: '/ajax/generate_salt.php', success: function(data) { $('#salt').val(data); } }); $("#upload_error_message_file").html(''); } } function removeThisBreed(id) { var div = "#selection_"+id; $(div).remove(); } function toggleImageVideoSelector(pos) { if (pos=='1') { $("#upload_box_top").removeClass('upload_box_top_2').addClass('upload_box_top_1'); $("#upload_file_image").css('display','block'); $("#upload_file_video_container").css('display','none'); $("#upload_submit_btn").html("SUBMIT PICTURE"); var uploader = new qq.FileUploader({ element: document.getElementById('upload_file_image'), action: '/upload_file.php' }); $("#uploaded_file").val(''); } else if (pos=='2') { $("#upload_box_top").removeClass('upload_box_top_1').addClass('upload_box_top_2'); $("#upload_file_image").css('display','none'); $("#upload_file_video_container").css('display','block'); $("#upload_submit_btn").html("SUBMIT VIDEO"); $("#uploaded_file").val(''); } } function selectCategory(id) { var div = "#upload_category_"+id; $(".upload_category_active").removeClass('upload_category_active').addClass('upload_category'); $(div).removeClass('upload_category').addClass('upload_category_active'); $("#upload_error_message_category").html(''); } $('#upload_description').keyup(function () { var left = 350 - $(this).val().length; if (left < 0) { left = 0; var desc = $('#upload_description').val(); var substr = desc.substring(0,350); $('#upload_description').val(substr); } $('#nb_chars_left').text(left); }); function upload_breed_search_focus(value) { if (value=='Type Breed Name...') { $("#upload_breeds").val(''); } } function upload_breed_search_blur(value) { if (value=='') { $("#upload_breeds").val('Type Breed Name...'); } } $(document).ready(function() { var uploader = new qq.FileUploader({ element: document.getElementById('upload_file_image'), action: '/upload_image.php', debug: true, allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'], onSubmit: function(id, fileName){ $(".qq-upload-success").remove(); }, onComplete: function(id, fileName, responseJSON){ //alert(responseJSON.success); $(".qq-upload-file").css('display','inline-block'); $("#uploaded_file").val(responseJSON.filename); $("#salt").val(responseJSON.salt); } }); }); function deleteParentElement(n) { n.parentNode.parentNode.removeChild(n.parentNode); $("#uploaded_file").val(''); }