function adClick(e) {
	if(typeof e.target != 'undefined') {
		var owner = findOwner(e);
		var url = 'http://margo.weddingpath.com/update/' + owner.attributes.getNamedItem("id").nodeValue.substring(2);
	}
	else {
		if (e.srcElement.id != '') {
			var id = e.srcElement.id;
		}
		else {
			var id = e.srcElement.parentNode.parentNode.id;
		}
		var url = 'http://margo.weddingpath.com/update/' + id.substring(2);
	}
	//alert(url);	
	var obj = new JSONscriptRequest(url);
	obj.buildScriptTag(); // Build the script tag
  	obj.addScriptTag(); // Execute (add) the script tag
}

function doClick(data) {
	if(data==null) {
    	//alert('error');
  	}
  	else {
  		//alert('ok');
  	}
}

function findOwner(e) {
    var node = e.target;
    while (node) {
        if (node.nodeType == Node.ELEMENT_NODE && node.nodeName == "DIV") {
        	return node;
        }
        node = node.parentNode;
    }
    return null;
}

/* JSONscriptRequest -- a simple class for accessing Web Services
 * using dynamically generated script tags and JSON
 *
 * Author: Jason Levitt
 * Date: December 7th, 2005
 */

// Constructor -- pass a REST request URL to the constructor
function JSONscriptRequest(fullUrl) {
    this.fullUrl = fullUrl; // REST request path
    this.noCacheIE = '/' + (new Date()).getTime();// Keep IE from caching requests
    this.headLoc = document.getElementsByTagName("head").item(0);// Get the DOM location to put the script tag
    this.scriptId = 'YJscriptId' + JSONscriptRequest.scriptCounter++;// Generate a unique script tag id
}

JSONscriptRequest.scriptCounter = 1; // Static script ID counter

// buildScriptTag method
JSONscriptRequest.prototype.buildScriptTag = function () {
    this.scriptObj = document.createElement("script");// Create the script tag
    // Add script object attributes
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
    this.scriptObj.setAttribute("id", this.scriptId);
}

// removeScriptTag method
JSONscriptRequest.prototype.removeScriptTag = function () {
    this.headLoc.removeChild(this.scriptObj);// Destroy the script tag
}

// addScriptTag method
JSONscriptRequest.prototype.addScriptTag = function () {
    this.headLoc.appendChild(this.scriptObj);// Create the script tag
}

function addLoadEvent(func) {
  	var oldonload = window.onload;
  	if (typeof window.onload != 'function') {
    	window.onload = func;
  	}
  	else {
    	window.onload = function() {
	      	oldonload();
	      	func();
    	}
  	}
}

function addEvent(obj, sType, fn){
    if (obj.addEventListener) {
        obj.addEventListener(sType, fn, false);
    } 
    else if (obj.attachEvent) {
        var r = obj.attachEvent("on"+sType, fn);
    } 
    else {
        //alert("Handler could not be attached");
    }
}