$(window).scroll( function() { $(window).scrollTop() == 0 ? $('#scroll_to_top').hide() : $('#scroll_to_top').show(); } ); Array.prototype.last = function(){return this[this.length-1];} String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); } function close_popup(){ if($("#zoom").is(':visible')) history.replaceState(null,null,currentLocation); $('#fade,div.popup,div.window').fadeOut(function() { $('#fade, a.close').remove(); }); $('#zoomScroll').remove(); $('body').css('overflow','auto'); } var submit_form_ready=0; function preload_work(obj){ var err=0; var rand_no = Math.ceil(100000*Math.random()); $disabled=$(obj).find('.submit_div div'); if(submit_form_ready){ return true; } $disabled.show(); $(obj).find('input[type="submit"]').val('Saving...'); $('input,select,div').removeClass('error'); $('#popup-debug').hide(); if(obj.type.value=='http' && $('input.currslide').val()==''){ err=1; $('#slideshow').addClass('error'); } if(obj.type.value=='video' && (obj.image.value=='' || obj.videocode.value=='')){ err=1; $(obj.videocode).addClass('error'); } if(obj.title.value.trim()=='' || obj.title.value=='Work Title'){ $(obj.title).addClass('error'); err=1; } if(obj.category_id.value=='0'){ $(obj.category_id).addClass('error'); err=1; } if((obj.mode.value=='edit_work_action' || obj.image.value.indexOf("http://")==-1) && err){ $('.popup-debug').html('Please fix the error'); $('.popup-debug').show(); $disabled.hide(); $(obj).find('input[type="submit"]').val('Save'); }else if(obj.mode.value=='edit_work_action' || obj.image.value.indexOf("http://")==-1){ return true; } if(!err){ var img = new Image(); img.onload = img.onerror = function(){ if(!img.width){ $('.popup-debug').html('Sorry we could not fetch the image'); $('.popup-debug').show(); $disabled.hide(); $(obj).find('input[type="submit"]').val('Save'); }else{ submit_form_ready=1; setTimeout(function(){ $(obj).find('input[type="submit"]').click(); },100) } }; img.src = obj.image.value+'?'+rand_no; }else{ $('.popup-debug').html('Please fix the error'); $('.popup-debug').show(); $disabled.hide(); $(obj).find('input[type="submit"]').val('Save'); } return false; } function openwork(){ history.replaceState(null,this.title,this.href); $('body').css('overflow','hidden'); $(this).after('
'); $('div').click(function(e){ if($(this).attr('id')=='zoomScroll') close_popup(); e.stopPropagation(); }); $.post($(this).attr('href'),function(data){ $('#zoom').html(data); }); return false; } var resizecount=0; var row_head_width=0; function window_on_resize(){ var max_width; if(resizecount==0){ max_width=document.body.clientWidth-17; resizecount=resizecount+1; }else{ max_width=document.body.clientWidth; } var pin_margin=0,pin_width=300; var pins=Math.floor((max_width+pin_margin)/(pin_width+pin_margin)); var row_width=pins*pin_width+(pins-1)*pin_margin; var diff_width=max_width-row_width; row_head_width = row_width-10; $('.content').width(row_head_width+15); $('.row').css({'width':row_width+'px'}); var fix_width=290; $('.fix').css({'width':(row_width-fix_width)+'px'}); $('.mainbody.fix #container').css({'width':(row_width-fix_width)+'px'}); $('.row_head').css({'width':row_head_width+'px','padding-right':10+'px'}); if( window.nacmain_fixed_position){ $('#nacmain').css({'left':$('.head').offset().left+'px'}); } } var start_update=0; function updateRegion(country_code,current_state_code,current_city){ start_update=0; $('#state_code').show(); $('#selregion').show(); document.getElementById('state_code').options[0] = new Option('Loading...',''); $.post("/ajax/general.php",{country_code:country_code,mode:'regions'},function(data){ var obj = eval('(' + data + ')'); document.getElementById('state_code').options.length=0; if(!obj.rarr.length){ $('#state_code').hide(); $('#city').hide(); $('#selregion').hide(); $('#selcity').hide(); $('#other_city').hide(); } for(var i=0;i'; if(!$('#added_albums div').length) $('#added_albums').html(el_album); else $('#added_albums').append(el_album); $('#newalbum').val(''); } } function delnalbum(obj){ var title=$(obj).parent('div').find('span').html(); $('div.albums input[value="'+title+'"]').removeAttr('checked'); $(obj).parent('div').remove(); if(!$('#added_albums div').length) $('#added_albums').html('No added albums'); } function pre_reg_submit(){ if($('#added_albums div').length<0){ $('#error').show(); return false; }else{ var arr_albums=new Array(); $('#added_albums div>span').each(function(index) { $('#alb_cont').append(''); $('input[name="albums['+index+']"]').val($(this).text()); }); } } function countProperties(obj) { var prop; var propCount = 0; for(prop in obj){ propCount++; } return propCount; } function count_object(obj){ i=0; $.each(obj, function(){ i++; }); return i; } function like(obj,is_auth){ if(is_auth){ id=$(obj).attr('data'); link=$('#url4friend').val();//$(obj).attr('link'); act=$(obj).find('span').html(); total=parseInt($('.like'+id).html()); if(act=='Like'){ FB.getLoginStatus(function(response){ if(response.status==='connected' && fb_activity) { FB.api('/me/pictifycom:Like?artwork='+encodeURIComponent(link),'post',function(result){ //alert(result.toSource()); $(obj).attr('result',result.id); }); } }); new_act='Unlike'; total=total+1; }else{ if($(obj).attr('result')){ FB.getLoginStatus(function(response){ if(response.status==='connected') { FB.api($(obj).attr('result'),'delete'); } }); } new_act='Like'; total=total-1; } $('.like'+id).html(total) if(total){ $('.likebox'+id).find('.likes_0').hide(); $('.likebox'+id).find('.likes_stat').show(); }else{ $('.likebox'+id).find('.likes_0').show(); $('.likebox'+id).find('.likes_stat').hide(); } $(obj).find('span').html(new_act); $.post('/ajax/general.php',{mode:'like',id:id},function(data){ //alert(data); }) }else{ location.href='/login/'; } if($('#container').length) $container.masonry('reload'); } function likealbum(obj){ id=$(obj).attr('data'); act=$(obj).find('span').html(); total=parseInt($('.alike'+id).html()); link=$(obj).attr('link'); if(act=='Like'){ FB.getLoginStatus(function(response){ if(response.status==='connected' && fb_activity) { FB.api('/me/pictifycom:Like?album='+encodeURIComponent(link),'post',function(response){ $(obj).attr('result',response.id); }); } }); new_act='Unlike'; total=total+1; }else{ if($(obj).attr('result')){ FB.getLoginStatus(function(response){ if(response.status==='connected') { FB.api($(obj).attr('result'),'delete'); } }); } new_act='Like'; total=total-1; } $('.alike'+id).html(total) if(total){ $('.album_likebox'+id).find('.alikes_0').hide(); $('.album_likebox'+id).find('.alikes_stat').show(); }else{ $('.album_likebox'+id).find('.alikes_0').show(); $('.album_likebox'+id).find('.alikes_stat').hide(); } $(obj).find('span').html(new_act); $.post('/ajax/general.php',{mode:'albumlike',id:id},function(data){ //alert(data); }); $container.masonry('reload'); } function next_works(){ $('#slide4works').show("slide", { direction: "left" }, 1000); } function send_2friend(obj){ var err=0; var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; $('#sendtofriend').find('input[type="text"]').css('background','url("/images/bg_input_box_fade.png") repeat-x scroll center top #FFFFFF'); if(obj.name.value==''){ $('#sendtofriend').find('input[name="name"]').css('background','#ffeeee'); err=1; } if(obj.email.value=='' || !emailReg.test(obj.email.value)){ $('#sendtofriend').find('input[name="email"]').css('background','#ffeeee'); err=1; } if(obj.friendname.value==''){ $('#sendtofriend').find('input[name="friendname"]').css('background','#ffeeee'); err=1; } if(obj.friendemail.value=='' || !emailReg.test(obj.friendemail.value)){ $('#sendtofriend').find('input[name="friendemail"]').css('background','#ffeeee'); err=1; } /* if(obj.code && obj.code.value==''){ $('#captcha').addClass('validation-error'); err=1; } */ if(!err){ $.post('/ajax/general.php',$('#friendform').serialize(),function(data){ //if(data=='1') $('#captcha').addClass('validation-error'); //else{ $('#friendform').hide(); $('#send_result').html('
Your message has been sent
'); setTimeout(function(){ $('#friendform').show(); $('#send_result').html(''); close_popup(); },4000); //} }); } return false; } function get_about(id){ $.post('/ajax/general.php',{mode:'about',id:id},function(data){ $('#about-cont').hide(); $('#about-cont').html(data); $('#about-cont').slideDown('slow',function(){ $container.masonry('reload'); }); }); } var follow=0; var allow_follow=1; var temp_following = -1 var locked_following=false; function get_following_users(user_id){ if(!locked_following){ follow=0; $('#vallf div.vallfcont').html('Loading...'); $.post('/ajax/',{mode:'get_following',id:user_id,reset:1},function(data){ $('#vallf div.vallfcont').html(data); $('#following_container').scroll(function () { var scrollHeight=$('#following_container').scrollTop(); if (scrollHeight>=($('#following_container').height()/2) && scrollHeight-temp_following>200){ if(!locked_following){ $('#vallf div.sloadproc').show(); $.post('/ajax/',{mode:'get_following',id:user_id},function(data){ if(data=='noMoreUsers') locked_following=true; else $('#vallf div.vallfcont').append(data); $('#vallf div.sloadproc').hide(); }); } temp_following = scrollHeight; } }); }); } } var temp_followers=-1; var locked_followers=false; function get_followers_users(user_id){ if(!locked_followers){ follow=0; $('#vallf1 div#users_res').html('Loading...'); $.post('/ajax/',{mode:'get_followers',id:user_id,reset:1},function(data){ $('#vallf1 div#users_res').html(data); $containter=$('#followers_container div#users_res'); $containter.scroll(function(){ var scrollHeight=$containter.scrollTop(); if (scrollHeight>=($containter.height()/2) && scrollHeight-temp_followers>200){ if(!locked_followers){ $('#vallf1 div.sloadproc').show(); $.post('/ajax/',{mode:'get_followers',id:user_id},function(data){ if(data=='noMoreUsers') locked_followers=true; else $('#vallf1 div#users_res').append(data); $('#vallf1 div.sloadproc').hide(); }); } temp_followers = scrollHeight; } }); }); } } var temp_likes=-1; var l_work_id=0; var l_album_id=0; function get_likes(work_id,album_id,cnt){ $('#addpop strong').html('{people} people like this'.replace('{people}',cnt)); $('#laddpop').click(); temp_likes=-1; l_work_id=work_id; l_album_id=album_id; $('#addpop div#users_res').html('Loading...'); $.post('/ajax/',{mode:'get_likes',id:work_id,album_id:album_id,reset:1},function(data){ $('#addpop div#users_res').html(data); $containter=$('#addpop div.vallfcont'); $containter.scrollTop(0); $containter.scroll(function(){ scrollHeight=$containter.scrollTop(); if (scrollHeight>=($containter.height()/2) && scrollHeight-temp_likes>200){ $('#addpop div.sloadproc').show(); $.post('/ajax/',{mode:'get_likes',id:l_work_id,album_id:l_album_id},function(data){ if(data!='noMoreUsers') $('#addpop div#users_res').append(data); $('#addpop div.sloadproc').hide(); }); temp_likes = scrollHeight; } }); }); } function set_settings(obj,redir){ val=obj.checked ? 1 : 0; $.ajax({ url: "/ajax/", type: "POST", data: "mode=settings&val="+val+"&var="+obj.name, success: function(data){ if(redir) window.location.reload(); } }); } function open_work(obj){ if(!stopLoadWork){ stopLoadWork=1; if(!$.browser.msie){ history.replaceState(null,obj.title,obj.href); }else{ window.location.href=obj.href; return false; } $('body').css('overflow','hidden'); $(obj).after('
Loading...
'); $('div').click(function(e){ if($(this).attr('id')=='zoomScroll'){ close_popup(); $('#zoomScroll').remove(); } e.stopPropagation(); }); $('#zoom').html('Loading...'); $.post($(obj).attr('href'),function(data){ $('#zoom').html(data); stopLoadWork=0; }); } return false; } function objectLength(obj) { var L=0; $.each(obj, function(i, elem) { L++; }); return L; } function set_gallery(obj,profile){ if(obj.value==2 || obj.value==6){ if(obj.value==2){ $('#galname span').html('Gallery Name'); $('#galname input').attr('placeholder','Gallery Name'); if($.browser.msie) $('#galname input').val('Gallery Name'); }else{ $('#galname span').html('Auction House Name'); $('#galname input').attr('placeholder','Auction House Name'); if($.browser.msie) $('#galname input').val('Auction House Name'); } $('#galname').show(); }else{ $('#galname').hide(); if(!profile) $('#gallery_name').val(''); } } var current_count_works=0; function check_new_works(dt){ setInterval(function(){ $.ajax({ url: '/ajax/count_new_works.php', data: {datetime:dt}, success: function(data){ //alert(data); count_works=parseInt(data); if(current_count_works!=count_works){ current_count_works=count_works; $('#new_posts a>span').html(data); text=''+count_works+' new post{s}. Click here to refresh the page'; new_text=count_works>1 ? text.replace('{s}','s') : text.replace('{s}',''); $('#new_posts a').html(new_text); $('#new_posts a').show().effect("highlight",{},2000); } } }); },10000); } function share_work(id){ $('#sharepop>span').html('Loading...'); $.post('/ajax/',{mode:'share_work',id:id},function(data){ $('#sharepop>span').html(data); }); $('#sharepop_btn').click(); } function UrlExists(url){ var http = new XMLHttpRequest(); http.open('HEAD', url, false); http.send(); return http.status!=404; } function init_fb_friends(){ FB.getLoginStatus(function(response){ if(response.status==='connected') { facebook_friends(); }else{ $('#fb_btn_friends').show(); } }); } function facebook_friends(){ FB.getLoginStatus(function(response){ if(response.status==='connected') { $('#my_friens').html('Loading...'); FB.api('/me/friends', function(response) { if(response.data) { var users=[]; $.each(response.data,function(index,friend){ users.push(friend.id); }); if(!users.length){ $('#my_friens').html('Friends not found'); }else{ $.ajax({ type: 'POST', url: '/ajax/', data: {mode:'fb_already_exists',data:users.join(',')}, dataType: 'json', success: function(data){ var pictify_users=[]; $('#my_friens').html(''); var already_following=[]; if(data.length) $('#friends_on_pictify').html('

Friends on Pictify


'); $.each(data,function(key,user){ pictify_users.push(user.facebook_id); if(!user.is_follow) $('#friends_on_pictify').append('
'+user.name+'
Follow

'); else already_following.push(user); }); if(already_following.length){ already_foll="Already following {COUNT} friends".replace('{COUNT}',already_following.length); $('#already_on_pictify').html(''+already_foll+''); for(var i=0;i '+already_following[i].name+'
Unfollow

'); } } $.each(response.data,function(index,friend){ if($.inArray(friend.id,pictify_users)==-1) $('#my_friens').append('
'+friend.name+'
Invite

'); }); } }); } }else { alert("Error!"); } }); }else{ FB.login(function(response) { if (response.authResponse) { accessToken = response.authResponse.accessToken; location.href=location.href; } else { alert('User cancelled login or did not fully authorize.'); } },{scope:'email,user_checkins,user_photos,publish_stream,user_likes,offline_access,publish_actions,user_activities'}); } }); } function fb_send_invite(id){ FB.ui( { method: 'send', name: 'Join Pictify, the Virtual Gallery', link: 'http://pictify.saatchigallery.com', to: [id], description:'If you love art and want to share it with millions of other people all over the world get started now on Pictify.', picture: 'http://pictify.com/images/spacer.gif' }, function(response) { $('#fb_'+id).remove(); } ); } function invite(obj,g){ $(obj).find('input[type="submit"]').attr('disabled','disabled'); $.ajax({ type: 'POST', url: '/ajax/', data: $(obj).serialize(), dataType:'json', success: function(data){ if(g){ $('#fb_'+data.gnum).remove(); close_popup(); }else{ $.each(data,function(key,val) { $('#email'+(key+1)).html(val); if(val!='' && val!='Invalid email address'){ $('#em'+(key+1)).attr('readonly','readonly'); $('#em'+(key+1)).css('color','#cccccc'); } }); } $(obj).find('input[type="submit"]').removeAttr('disabled'); } }); return false; } function fbEnsureInit(){ if(!window.fbApiInit){ setTimeout(function(){fbEnsureInit();},50); }else{ init_fb_friends(); } } function YQLQuery(query, callback) { this.query = query; this.callback = callback || function(){}; this.fetch = function() { if (!this.query || !this.callback) { throw new Error('YQLQuery.fetch(): Parameters may be undefined'); } var scriptEl = document.createElement('script'), uid = 'yql' + +new Date(), encodedQuery = encodeURIComponent(this.query.toLowerCase()), instance = this; YQLQuery[uid] = function(json) { instance.callback(json); delete YQLQuery[uid]; document.body.removeChild(scriptEl); }; scriptEl.src = 'http://query.yahooapis.com/v1/public/yql?q=' + encodedQuery + '&format=json&callback=YQLQuery.' + uid; document.body.appendChild(scriptEl); }; } var temp_friend_wh=-1; var locked_friends_wh=false; var heppen_user_id=0; var lock_heppen_first=false; var l_action; var l_dt; function get_friends_wh(id,action,dt,title){ if(action){ $('#addpop strong').html(title); $('#addpop div#users_res').html('Loading...'); $('#laddpop').click(); $containter=$('#addpop div.vallfcont'); }else{ $('#allwh').html('
Loading...
'); $('#more_action').click(); $containter=$('#allwh'); } temp_friend_wh=-1; var action=action ? action : ''; var dt=dt ? dt : ''; l_action=action; l_dt=dt; user_id=id ? id : 0; heppen_user_id=user_id; $.post('/ajax/',{mode:'get_friends_heppen',id:user_id,action:action,dt:dt,reset:1},function(data){ if(!action){ $containter.html(data); }else{ $('#addpop div#users_res').html(data); } $containter.scrollTop(0); $containter.scroll(function(){ scrollHeight=$containter.scrollTop(); if(scrollHeight>=($containter.height()/2) && scrollHeight-temp_friend_wh>400){ $containter.find('div.sloadproc').show(); $.post('/ajax/',{mode:'get_friends_heppen',id:heppen_user_id,action:l_action,dt:l_dt},function(data){ if(data!='noMoreActions') $containter.append(data); $containter.find('div.sloadproc').hide(); }); temp_friend_wh = scrollHeight; } }); }); } function jlanguage(lang_id,lang_char,lang_file){ $.cookie('lang_id',lang_id,{expires:365,path: '/'}); $.cookie('lang_char',lang_char,{expires:365,path: '/'}); $.cookie('lang_file',lang_file,{expires:365,path: '/'}); $.post('/ajax/',{mode:'language',id:lang_id},function(){ window.location.reload(); }); } function open_comments(obj){ var album_id=$(obj).attr('data-id'); var album_title=$('#albumtitle'+album_id).html(); $('#album_comments h2').html(album_title); $('#album_comments div').html('Loading...'); $('#albcom').click(); $.post('/ajax/',{mode:'get_comments',id:album_id},function(data){ $('#album_comments div').html(data); }); } function read_more_comment(obj,id){ $(obj).html('loading...'); $.post('/ajax/',{mode:'get_comment',id:id},function(data){ $(obj).closest('span').html(data); $container.masonry('reload'); }); } function report_spam(obj,id){ $(obj).replaceWith('Thank you !'); setTimeout(function(){ $('#sp_'+id).remove(); },2000); $.post('/ajax/',{mode:'spam',id:id}); }