
function confirm_delete(form_name,msg){
  if(msg == undefined){
    msg = 'Are you sure you want to delete this?';
  }
  if(confirm(msg)){$(form_name).submit();}
  return false;  
}

// generates a form and submits post
function post(linkObj){
  id='GDWK_POST';
  $(linkObj).after('<form id="'+id+'" method="post" action="'+linkObj.href+'"></form>');
  $('#'+id).submit();
  return false;
}

function del(linkObj,name){
  if(name == undefined){name = 'this';}
  msg = 'Are you sure you want to delete '+name+'?';
  if(confirm(msg)){post(linkObj);}
  return false;
}

function ajax_submit_w_update(fObj,updateE,statusE){ // onsubmit
  $.ajax({url:fObj.action,type:"POST",beforeSend:function(x){$(statusE).show();},success:function(x){$(updateE).html(x);},complete:function(x){$(statusE).hide();},data:$(fObj).serialize()});
  return false;
}

function findPosX(el){
	var curleft = 0;
	if (el.offsetParent){
		while (el.offsetParent){
			curleft += el.offsetLeft
			el = el.offsetParent;
		}
	}
	else if (el.x)
		curleft += el.x;
	return curleft;
}

function findPosY(el){
	var curtop = 0;
	if (el.offsetParent){
		while (el.offsetParent){
			curtop += el.offsetTop;
			el = el.offsetParent;
		}
	}
	else if (el.y)
		curtop += el.y;
	return curtop;
}

function protect_email(who, where, className, doLink){
	var addy = who + String.fromCharCode(64) + where;
	if (doLink){
		document.write("<a href=\"mai" + "lto:" + addy + "\"");
		if (className.length){document.write(" class=\"" + className + "\"");}
		document.write(">");
	}
	document.write(addy);
	if (doLink){document.write("</a>");}
}


function setCookie (name, value, expires, path, domain, secure) {document.cookie = name + "=" + escape(value)+((expires) ? "; expires=" + expires : "")+((path) ? "; path=" + path : "")+((domain) ? "; domain=" + domain : "")+((secure) ? "; secure" : "");}
function getCookie(name) {
	var cookie=" "+document.cookie;
	var search=" "+name+"=";
	var setStr=null;
	var offset=0;
	var end=0;
	if(cookie.length > 0){
		offset=cookie.indexOf(search);
		if(offset != -1){
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function deleteCookie(n){
  var cd = new Date();
  cd.setTime(cd.getTime()-1);
  setCookie(name,null,cd.toGMTString());
}

