
/* *******************************************************************************************
 *         INIT                                                                              *
 ******************************************************************************************* */

function init() {
	/*positionDocFoot() ;
	if (window.addEventListener) {
		window.addEventListener( "resize", positionDocFoot, false ) ;
	} else if (window.attachEvent) {
		window.attachEvent( "onresize", positionDocFoot ) ;
	}*/
}

/* *******************************************************************************************
 *         Popup                                                                             *
 ******************************************************************************************* */

function popWinOpen(winW,winH,sUrl,sName,iResize,iScroll,iStatus) {
	var winX, winY ;
	if (screen) {
		if (winW <= 0) {
			winW = screen.width - 20 ;
		}
		if (winH <= 0) {
			winH = screen.height - 80 ;
		}
		if ((screen.height - winH) < 150) {
			winX = (screen.width - winW) / 2;
			winY = 0;
		} else {
			winX = (screen.width - winW) / 2;
			winY = (screen.height - winH) / 2;
		}
		var popWindow = window.open(sUrl,sName,"resizable=" + iResize + ",menubar=0,scrollbars=" + iScroll + ",status=" + iStatus + ",width=" + winW + ",height=" + winH + ",top=" + winY + ",left=" + winX + "");
		if (popWindow) popWindow.focus();
	} else {
		window.open(sUrl,sName,"resizable=" + iResize + ",menubar=0,scrollbars=" + iScroll + ",status=" + iStatus + ",width=" + winW + ",height=" + winH);
	}
}

function openMail(sId, meta_id) {
	var url = "/jsp/mail_formular.jsp?id=" + sId;
	url += "&amp;" + "meta_id=" + meta_id;

	popWinOpen(500, 650, url , "mailWin", 1, 0, 1) ;
}

//<a href="/path/file.ext" onClick="popWinOpen(600,560,'/path/file.ext','myWin',0,0,0); return false">Linktext</a>

/* *******************************************************************************************
 *         Get absolute position of any element                                              *
 ******************************************************************************************* */

function getElementTop(el) {
	try {
		if (!el && this) {
			el = this ;
		}
		var posTop = el.offsetTop ;
		var elPar = el.offsetParent ;
		while (elPar != null) {
			posTop += elPar.offsetTop ;
			elPar = elPar.offsetParent ;
		}
		return posTop ;
	} catch (e) {
		return 0 ;
	}
}




/* *******************************************************************************************
 *         MISC                                                                              *
 ******************************************************************************************* */
function winStatus(str) {
	/*if (str != "") {
		str = "http://" + location.host + str ;
	}
	window.status = str ;*/
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}


/* *******************************************************************************************
 *         Comments - Article                                                                *
 ******************************************************************************************* */
jQuery.fn.outerHTML = function() {
    return $('<div>').append( this.eq(0).clone() ).html();
};

/* *******************************************************************************************
 *         Document Init                                                                     *
 ******************************************************************************************* */

$(document).ready(function() {
	if ($("#contactLink")) {
		$("#contactLink").click(function() {
			if ($("#contact_div").is(":hidden")) {
				$("#contact_div").show("slow", function() {
					$("body").scrollTo($("#article_bottom"), 500);
				});
			} else {
				$("#contact_div").hide("slow");
			}
		});
		$("#contactHideLink").click(function() {
			$("#contact_div").hide("slow");
		});
	}
	if ($("#rightContactLink1")) {
		$("#rightContactLink1").click(function() {
			if ($("#right_contact1_div").is(":hidden")) {
				$("#right_contact1_div").show("slow", function() {
					$("body").scrollTo($("#rightcol_contact1"), 500);
				});
			} else {
				$("#right_contact1_div").hide("slow");
			}
		});
		$("#rightContactHideLink1").click(function() {
			$("#right_contact1_div").hide("slow");
		});
	}
	if ($("#rightContactLink2")) {
		$("#rightContactLink2").click(function() {
			if ($("#right_contact2_div").is(":hidden")) {
				$("#right_contact2_div").show("slow", function() {
					$("body").scrollTo($("#rightcol_contact2"), 500);
				});
			} else {
				$("#right_contact2_div").hide("slow");
			}
		});
		$("#rightContactHideLink2").click(function() {
			$("#right_contact2_div").hide("slow");
		});
	}
	if ($("#rightContactLink3")) {
		$("#rightContactLink3").click(function() {
			if ($("#right_contact3_div").is(":hidden")) {
				$("#right_contact3_div").show("slow", function() {
					$("body").scrollTo($("#rightcol_contact3"), 500);
				});
			} else {
				$("#right_contact3_div").hide("slow");
			}
		});
		$("#rightContactHideLink3").click(function() {
			$("#right_contact3_div").hide("slow");
		});
	}
});
