var divNum = 0; var imgids = [0]; var nameids = [0]; function dump(arr,level) { var dumped_text = ""; if(!level) level = 0; //The padding given at the beginning of the line. var level_padding = ""; for(var j=0; j \"" + value + "\"\n"; } } } else { //Stings/Chars/Numbers etc. dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; } return dumped_text; } function addFormField() { var id = document.getElementById('counter').value; $("#divTxt").append("
Add A Gift
"); $('#row' + id).highlightFade({ speed:1000 }); uploadify('#uploadify'+id,id); imgids.push(id); nameids.push(id); //alert(dump(imgids)); //alert(dump(nameids)); id = (id - 1) + 2; document.getElementById("counter").value = id; $.facebox.close(); } function removeFormField(id,id2){ id2 = String(id2); //alert(dump(imgids)); //alert(dump(nameids)); //alert(id2); //alert(nameids.indexOf(id2)); imgids.splice(imgids.indexOf(id2), 1); nameids.splice(nameids.indexOf(id2), 1); $(id).remove(); } google.load("search", "1", {"nocss" : true}); // function will bind event to all images function bind_event(){ $("a.gs-image").bind("click", function(e){ // $("#imageContainer").html('Loading Image...'); // $("a.gs-image img").removeClass(); // $("a.gs-image img").addClass("gs-image"); // $(this).find("img").removeClass(); // $(this).find("img").addClass("selectImage"); // if($(".gs-imageResult").length <= 0){ // $("#gsearchErr").css("display","block"); // }else{ // $("#gsearchErr").css("display","none"); // } $("#pic-"+divNum).html('Loading Image...'); document.getElementById("s-"+divNum).value = 1; $.facebox.close(); valimgsearch(escape($(this).attr('href'))); return false; }); //$("div.gsc-cursor").prepend("
"); //$(".gsc-trailing-more-results").css("display","none"); } // the se class encapsulates a left and right search control // both controls are driven by a shared search form function OnLoad() { // create a tabbed mode search control var tabbed = new google.search.SearchControl(); //restrict results: search only moderated //tabbed.setRestriction(google.search.RESTRICT_SAFESEARCH, google.search.SAFESEARCH_STRICT); // Set the Search Control to get the most number of results tabbed.setResultSetSize(google.search.Search.LARGE_RESULTSET); // create image searchers. tabbed.addSearcher(new google.search.ImageSearch()); // proprofscc: On search completeion tabbed.setSearchCompleteCallback(this, bind_event); // draw in tabbed layout mode var drawOptions = new google.search.DrawOptions(); drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED); // Draw the tabbed view in the content div tabbed.draw(document.getElementById("imgSearchControl"), drawOptions); // Search! tabbed.execute(""); } google.setOnLoadCallback(OnLoad); function displaySearch() { jQuery.facebox(function() { jQuery.facebox("#searchhid"); }) } function reLoadFacebox() { $('a[rel*=facebox]').facebox({ loading_image : 'loading.gif', close_image : 'closelabel.gif' }) } function valimgsearch(u) { var validationtext = $('#validationtext'); var imagevalidation = $('#imgvalidation'); validationtext.removeClass('error').html(' checking ...'); this.timer = setTimeout(function () { $.ajax({ url: 'validate.php', data: 'action=check_imgurl&url=' + u, dataType: 'json', type: 'post', success: function (j) { validationtext.html(j.msg); ok = j.ok; if ( ok == false ) { imagevalidation.html('false'); } } }); }, 200); } function uploadify(t, n) { //alert ( n ); var uniquefile = '4f452c5927d8f'; $(t).uploadify({ 'uploader' : 'uploadify/uploadify.swf', 'script' : 'uploadify/uploadify.php', 'cancelImg' : 'uploadify/cancel.png', 'folder' : 'giftimages', 'buttonImg' : 'browse_button.gif', 'width' : 43, 'height' : 16, 'auto' : true, 'fileDesc' : '*.jpg;*.jpeg;*.png;*.gif', 'fileExt' : '*.jpg;*.jpeg;*.png;*.gif', 'scriptData' : {'ts' : uniquefile}, 'multi' : false, 'onComplete' : function valimgupload(event, queueId, fileObj,response, data) { //alert ( fileObj.name ); $("#pic-"+n).html('Loading Image... '); document.getElementById("s-"+n).value = 1; valimgsearch("http://www.bookspy.info/bigtimegifts/giftimages/" + uniquefile + fileObj.name); } }); } function reloadval(t) { var validationtext = $('#validationtext'); $('#'+t).keyup(function () { var t = this; if (this.value != this.lastValue) { if (this.timer) clearTimeout(this.timer); validationtext.removeClass('error').html(' checking ...'); this.timer = setTimeout(function () { $.ajax({ url: 'validate.php', data: 'action=check_name&name=' + t.value, dataType: 'json', type: 'post', success: function (j) { validationtext.html(j.msg); } }); }, 200); this.lastValue = this.value; } }); } function reloadvalx(t) { var validationtext = $('#validationtext'); var namevalidation = $('#namevalidation'); var txt = document.getElementById(t).value; $.ajax({ url: 'validate.php', data: 'action=check_name&name=' + txt, dataType: 'json', type: 'post', success: function (j) { validationtext.html(j.msg); ok = j.ok; if ( ok == false ) { namevalidation.html('false'); } else { namevalidation.html(''); } } }); } function setDivNum(num) { divNum = num; } function finalCheck(form) { var imgTest = true; var nameTest = true; var imagevalidation = $('#imgvalidation'); var namevalidation = $('#namevalidation'); imagevalidation.html(''); namevalidation.html(''); //alert(dump(imgids)); for ( var i=imgids.length-1; i>=0; --i ) { var id = imgids[i]; //alert (id); var upic = 'upic-'+String(id); //alert (upic); if (document.getElementById(upic) ) { valimgsearch(document.getElementById(upic).value); } else { imagevalidation.html('false'); } //alert(id); // alert(document.getElementById('upic-'+id).value); } for ( var i=nameids.length-1; i>=0; --i ) { var id = nameids[i]; var gname = 'gname'+String(id); //alert(gname); //alert (upic); if (document.getElementById(gname).value) { reloadvalx(gname); } else { namevalidation.html('false'); } //alert(id); // alert(document.getElementById('upic-'+id).value); } var title = document.getElementById('title').value; var desc = document.getElementById('desc').value; if(title) { var re1='.*?'; // Non-greedy match on filler var re2='(facebook)'; // Word 1 var p = new RegExp(re1+re2,["i"]); var m = p.exec(title); if (m != null) { namevalidation.html('false'); } else { reloadvalx(gname); } } else { namevalidation.html('false'); } if(desc) { var re1='.*?'; // Non-greedy match on filler var re2='(facebook)'; // Word 1 var p = new RegExp(re1+re2,["i"]); var m = p.exec(desc); if (m != null) { namevalidation.html('false'); } else { reloadvalx(gname); } } else { namevalidation.html('false'); } t = imagevalidation.html(); x = namevalidation.html(); //alert (t); if (t == 'false' || x == 'false' ) { $.facebox("
There was a problem with with your gifts. Make sure you have provided a name and image to all gifts and try again!
"); } else { document.forms["myform"].submit(); } } $(document).bind('afterReveal.facebox', function() { var windowHeight = $(window).height(); var faceboxHeight = $('#facebox').height(); if(faceboxHeight < windowHeight) { $('#facebox').css('top', (Math.floor((windowHeight - faceboxHeight) / 2) + $(window).scrollTop()) ); } });