// Functions

function isset(varname) {
	if(typeof( window[ varname ] ) != "undefined") return true;
	else return false;
}

$.fn.centerForm = function (vert,horiz) {
	$(this).css("position","fixed");
	if (horiz == undefined) { horiz = true; }
	if (vert == undefined) { vert = true; }
	top = ($(window).height() - this.height() ) / 2;
	if ( top > 100 ) top -= 60;
	horiz = ( $(window).width() - this.width() ) / 2;
	if (vert) { this.css("top",  top + "px"); }
	if (horiz) { this.css("left", horiz + "px"); }
	return this;
}

$.fn.aPhone = function (number) {
	contents = '<a href="tel:' + number + '">' + $(this).html() + '</a>';
	$(this).html(contents);	
}

$.fn.sizeToParent = function () {
	var newWidth = $(this).parent().width();
	$(this).width(newWidth+20);
}

/* JSDDM code
------------------------------------------------------------------------- */

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

document.onclick = jsddm_close;

