        
         //var rand_id;
         var gal;

	


		 
          
          function print_gallery(json_response)
          {
                
                var gallery= "";
                var i;
                var arr = json_response.img_array.split(";");
                var len = arr.length;
				var title_border = "border-bottom: dotted 3px orange;";
                //alert("roi");
                var rand_id = json_response.rand_id;
                
                if (json_response == null)
                 {
                      alert("There was a problem parsing search results.");
                      return;
                 }
                 
                  
                
                 
                gallery = "<div style='width: " + json_response.width + "px;'>";
				if( json_response.title == "")
					{title_border="";}
                var title = "<div style='width:100%;font-size: 18px; font-family: verdana;" + title_border  + "margin-bottom: 5px;'>" + json_response.title + "</div>";
              
                gallery = gallery + title;
                gallery = gallery + "<div style='list-style-type: none; display: inline-block;width: 100%;'>";
                
                 
                    for (i=0;i<=len-1;i++)
                    {
                        
                        gallery = gallery + "<img onmousedown = 'return false;' oncontextmenu='return false;' style='cursor:pointer; float: left;margin-right: 5px; margin-bottom: 5px;height: " + json_response.images[i].img_height + "px;width: " + json_response.images[i].img_width + "px;' onclick='javascript:window.open(\"http://www.blogher.com/photo-gallery?iid=" + json_response.images[i].id + "&term=*&tpid=" + json_response.img_array + "\")' title='" + json_response.images[i].title + " - " + json_response.images[i].description + " - Content &copy; 2009 " + json_response.images[i].cont_name + " All rights reserved' src='" + json_response.images[i].turl + "'>";
                    }
                    
                   gallery = gallery + ("</div>");
                   var footer = "<div style='font-size: 10px; font-family: verdana; width:100%; text-align: right; color: gray; '>Powered by <a target='_blank' style='color: orange;' href='http://www.picapp.com'>PicApp</a></div></div>";
                   gallery = gallery + footer ;
				   document.getElementById(rand_id).innerHTML = gallery;
				   /*
				   var newdiv = document.createElement('div');
				   
				   var divIdName = Math.floor(Math.random()*100000);
				   newdiv.setAttribute('id',divIdName);
				   
				   
				   document.getElementById(rand_id).appendChild(newdiv);
				   */
 
				   
					
					
          }
          
          
					
          function picapp_gallery(tag_id, gallery_array, title, rows, cols, gallery_type)
          {
                
					//var rand_id = tag_id;
					// Build the call
					var request = "http://zen.picapp.com/blogher/picapp_gallery_json.aspx?images=" + gallery_array + "&title=" + title + "&rows=" + rows + "&cols=" + cols + "&gal_typ=" + gallery_type + "&rand_id=" + tag_id;// + "&callback=print_gallery";
					// Create a new script object
					aObj = new JSONscriptRequest(request);
					// Build the script tag
					aObj.buildScriptTag();
					// Execute (add) the script tag
					aObj.addScriptTag();  
								  
           }
           
           
           
           
// Author: Jason Levitt
// Date: December 7th, 2005
//
// A SECURITY WARNING FROM DOUGLAS CROCKFORD:
// "The dynamic <script> tag hack suffers from a problem. It allows a page 
// to access data from any server in the web, which is really useful. 
// Unfortunately, the data is returned in the form of a script. That script 
// can deliver the data, but it runs with the same authority as scripts on 
// the base page, so it is able to steal cookies or misuse the authorization 
// of the user with the server. A rogue script can do destructive things to 
// the relationship between the user and the base server."
//
// So, be extremely cautious in your use of this script.
//

// Constructor -- pass a REST request URL to the constructor
//
function JSONscriptRequest(fullUrl) {
    // REST request path
    this.fullUrl = fullUrl; 
    // Keep IE from caching requests
    //this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
    // Get the DOM location to put the script tag
    this.headLoc = document.getElementsByTagName("head").item(0);
    // Generate a unique script tag id
    //this.scriptId = 'YJscriptId' + JSONscriptRequest.scriptCounter++;
}

// Static script ID counter
//JSONscriptRequest.scriptCounter = 1;

// buildScriptTag method
//
JSONscriptRequest.prototype.buildScriptTag = function () {

    // Create the script tag
    this.scriptObj = document.createElement("script");
    
    // Add script object attributes
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("src", this.fullUrl);
   // this.scriptObj.setAttribute("id", this.scriptId);
}
 
// removeScriptTag method
// 
JSONscriptRequest.prototype.removeScriptTag = function () {
    // Destroy the script tag
    this.headLoc.removeChild(this.scriptObj);  
}

// addScriptTag method
//
JSONscriptRequest.prototype.addScriptTag = function () {
    // Create the script tag
    this.headLoc.appendChild(this.scriptObj);
}



