function advOpen(openUrl, openWidth, openHeight, openSwitch) {
	var srw = screen ? (screen.width-50)    : 750;
    var srh = screen ? (screen.height-36)   : 564;
    var openScroll  	= "0";
	var documentWrite	= "";
	var	openParameters	= "";
    if ((openWidth>srw) || (openHeight>srh)) {
        openScroll  = "1";
        if (openHeight>srh) { openWidth  = openWidth+16; openHeight = srh-50; }
        if (openWidth>srw)  { openHeight = openHeight+16; openWidth = srw-50; }
    }

    srw     = (srw - openWidth)/2;
    srh     = (srh - openHeight)/5;

  	var UTCstring;
  	Today = new Date();
  	UTCstring = Today.getUTCHours()+Today.getUTCMinutes()+Today.getUTCSeconds()+Today.getTime();

	var openName;
	openName        = "openPopup"+UTCstring;

    openParameters  = "left="+srw+",top="+srh+",outerHeight=0,innerWidth,width="+openWidth+",innerHeight,height="+openHeight+",scrollbars="+openScroll+",titlebar=1,resizable=0";
    switch(openSwitch) {
        case "print":   openParameters  = "left="+srw+",top="+srh+",outerHeight=0,innerWidth,width="+openWidth+",innerHeight,height="+openHeight+",scrollbars=1,titlebar=1,resizable=0,menubar=1"; break;
        case "scroll":  openParameters  = "left="+srw+",top="+srh+",outerHeight=0,innerWidth,width="+openWidth+",innerHeight,height="+openHeight+",scrollbars=1,titlebar=1,resizable=0"; break;
    }
    var openPopup   = open(openUrl, openName, openParameters);
    return false;
}

function init() {
	if (window.initMap) { initMap(); }
	if (window.initForm) { initForm(); }
}

function doAction() {
//	theObject("ifDo").src = $src;
}

function setInnerHTML($html, $target) {
	$target.innerHTML	= $html;
	return false;
}

function findPosY(obj) {
	var curtop = 0;

	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}

function doSort($sort) {
	document.fList.sort.value = (document.fList.sort.value == $sort) ? $sort+"-" : $sort;
	document.fList.submit();
	return false;
}

function updateCoordinates($id, $crd) {
	var $url		= "/in_site/tools/ajax/coordinates.php?id="+$id+"&crd="+$crd;
	$.get($url, function($html) {
	});
	return false;
}

function trimString(str) {
	while (str.charAt(0) == ' ')  str = str.substring(1);
	while (str.charAt(str.length - 1) == ' ')  str = str.substring(0, str.length - 1);
	return str;
}

function formActivate($id) {
	$("#"+$id+" .text").bind("blur focus", function(e) {
		switch (e.type) {
			case "blur":
				$(this).toggleClass("act", 0);
				if (!this.value) { this.value = trimString(this.title); }
			break;
			case "focus":
				$(this).toggleClass("act", 1);
				if (trimString(this.value) == trimString(this.title)) {
					this.value = "";
				}
			break;
		}
		this.value	= trimString(this.value);
		return true;
	});
}

function go($url) {
	document.location.href = $url;
	return false;
}

/* linkedIn */
function withLink($id,$a,$f,$t,$c) {
	var $url		= "/in_site/tools/ajax/index.php";
	if ($a=="drop" || $a=="link") {
		if ($c && !confirm($linkDropConfirm)) { return false; }
	}
	$.get($url, { id:$id, action:$a, field:$f, table:$t, status:$c }, function($json) { applyJSON($json); }, "json");
	return false;
}

function applyJSON($json) {
//	alert($json.url);
	for (var $id in $json.remove) {
		$("#"+$id).remove();
	}
	for (var $id in $json.html) {
		$("#"+$id).html($json.html[$id]);
	}
}