/**
*	@name			: global.js
*	@version		: 0.0.1
*	@author			: The initial developer of the original code is 
*					  Andreas A. Lorenz
*	@contributors	: -
*
*	@created		: 11.03.2005
*	@modified		: 23.03.2007 - 00:04:46 (Andreas A. Lorenz)
*
*	@copyright		: Copyright(c) 2007 dCTRL GmbH. All rights reserved.
*					  Redistribution and use in source and binary forms, 
*					  with or without modification, is forbidden!
*					  This source code is part of the dasLib Framework
*					  http://www.dctrl.com
*	----
* 	@description	: global.js ist eine JavaScript Sammlung fuer unterschiedliche
*					  Anwendungen.
*
*	@usage			: <code>
*						<script type="text/javascript" src="js/global.js"></script>
*					  </code>
*	
* 	@todo:			: -
*/

// ------------------- GET BROWSER URL ---------------------------------------------
function getLocation() {
	return window.location.toString();
}

// ------------------- IE BROWSER ? ---------------------------------------------
function thisMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

// ------------------- DIE AS FUNCTION "asFunc" AUS JS AUFRUFEN ----------------------------
function makeCall(str) {
	thisMovie("extint").asFunc(str);
}

// ------------------- RESIZE FLASH SWF ---------------------------------------------
function resizeSWF(nHeight) {
	nHeight += "px";
	document.getElementById("resizer").style.height = nHeight;
}

// ------------------- SCROLL BROWSER-SCROLLBAR TO TOP -----------------------------------
function scrollWindow(){
	scroll(0,0);
}

// ------------------- BOOKMARK PAGE FROM FLASH CONTEXTMENU --------------------------
function addToFavorites() {
	titleL = encodeURIComponent(document.title); 
	urlL = encodeURIComponent(document.location.href);
	if (window.sidebar) { 
		window.sidebar.addPanel(titleL, urlL,"");
	} else if( window.external ) { 
		window.external.AddFavorite( urlL, titleL); 
	} else if(window.opera && window.print) { 
		return true; 
	}
}

// ------------------- ADD TO DELICIOUS ---------------------------------------------
function addToDelicious() {
	Adresse = 'http://del.icio.us/post?v=2&url='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(document.title)+' ';
	MeinFenster = window.open(Adresse, "del.icio.us");
  	MeinFenster.focus();
}

// ------------------- POPUP WINDOW: DYN CONTENT ---------------------------------------------
function tag(s){ return "<"+s+">" }

function openwin_a(str){
	var win = window.open("")
	if (win!=null){ //Hat das …ffnen des Fensters geklappt?
		win.document.open() //…ffnen fŸr Schreibzugriff, notwendig!
		win.document.write(tag("HTML")+tag("BODY"))
		win.document.write(tag("H1") + str + tag("/H1"))
		win.document.write(tag("/BODY")+tag("/HTML"))
		win.document.close() //Schreibzugriff beenden, notwendig!
	}
}

// ------------------- POPUP WINDOW: FIXED SIZE, POS 0/0 ---------------------------------------------
function openwin_b(imgURL) {
	win = window.open ("http://www.christianscherrer.com/popup.html?"+imgURL,"win","location=0,status=1,resizable=1,scrollbars=1,status=0,toolbar=0,width=300,height=300");
	//win = window.open ("popup.html?"+imgURL, "Christian Scherrer | Download", "location=1, status=1, scrollbars=1");
	win.moveTo(0,0);
}

// ------------------- POPUP WINDOW: DYN IMAGE SIZE -----------------(ORG CHRIS)----------------------------
var focusflg = true;

function openwin_z(imgURL) {
	var win 			= null;
	var name			= 'Christian Scherrer | Download';
	var posX			= 0;
	var posY			= 0;
	var scrollbarstext 	= 'scrollbars = no,';
	var resizabletext 	= 'resizable = yes,';
	var statustext 		= 'status = no,';
	var locationtext 	= 'location = no,';
	var toolbartext 	= 'toolbar = no,';
	var features 		= '';
	features = scrollbarstext+resizabletext+statustext;
	features = features + locationtext+toolbartext;
	//	features = features + 'width = '+x+',height = '+y;
	features = features + ',top = ' + posY;
	features = features + ',left = ' + posX;
    win = window.open( "popup.html?"+imgURL, name,features);
    win.focus();
   }

// ------------------- POPUP WINDOW: DYN IMAGE SIZE ---------------------------------------------
function openwin_c(imgurl) {
	var win 			= null;
	var name			= 'Christian Scherrer | Download';
	var posX			= 0;
	var posY			= 0;
	var scrollbarstext 	= 'scrollbars = no,';
	var resizabletext 	= 'resizable = yes,';
	var statustext 		= 'status = no,';
	var locationtext 	= 'location = no,';
	var toolbartext 	= 'toolbar = no,';
	var features 		= '';
	features = scrollbarstext+resizabletext+statustext;
	features = features + locationtext+toolbartext;
	//	features = features + 'width = '+x+',height = '+y;
	features = features + ',top = ' + posY;
	features = features + ',left = ' + posX;
	win = window.open(imgurl, name, features);
	win.focus();
}

// ------------------- POPUP WINDOW: FIXED SIZE ---------------------------------------------
function openwin_d(url) {
	var win 			= null;
	var x 				= 600;
	var y 				= 400;
	var centerwidth		= (screen.width/2)-(x/2);
	var centerheight	= (screen.height/2)-(y/2);
	var scrollbarstext 	= 'scrollbars = no,';
	var resizabletext 	= 'resizable = no,';
	var statustext 		= 'status = no,';
	var locationtext 	= 'location = no,';
	var toolbartext 	= 'toolbar = no,';
	var features 		= '';
	features = scrollbarstext+resizabletext+statustext;
	features = features + locationtext+toolbartext;
	features = features + 'width = '+x+',height = '+y;
	features = features + ',top = ' + centerheight;
	features = features + ',left = ' + centerwidth;
	win = window.open(url, name, features);
	win.focus();
	movefenster();
}



// ------------------- POPUP WINDOW: RESIZE FULLSCREEN ---------------------------------------------
function movefenster() {
	self.moveTo(0,0);
	resizeTo(screen.availWidth,screen.availHeight);
	if (document.layers||document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
	redirectparent();
}

// ------------------- POPUP WINDOW: LOAD BLANK IN PARENT WINDOW -----------------------------------
function redirectparent() {
	window.location="blank.htm";
}

// ------------------- POPUP WINDOW: LOAD OLD PAGE IN PARENT WINDOW AFTHER POPUP CLOSE -------------
function gopage() {
	//window.location="opener.htm";
	if(focusflg){
		location.replace("opener.htm");
	}
}
function setfocus(){
		onfocus = gopage;
		focusflg = true;
}
function offfocus(){
		focusflg = false;
}

// ------------------- FORM: NEWSLETTER ---------------------------------------------
function subscribeNews(myobject) {
    if (myobject.FromName.value == ""){
		alert("Bitte tragen Sie Ihren Namen ein!");
		(myobject.FromName).focus();
        return false;
    }
	if (myobject.FromEmail.value == ""){
		alert("Bitte tragen Sie Ihre Emailadresse ein!");
		(myobject.FromEmail).focus();
        return false;
    }
	if (myobject.FromEmail.value.indexOf('@') == -1){
		alert("Ihre Emailadresse ist unvollstaendig!");
		(myobject.FromEmail).focus();
        return false;
    }
	else {
        alert("Vielen Dank fuer Ihr Interesse am Newsletter!\nDieser wird Ihnen ab der naechsten Ausgabe zugeschickt!\n\n");
		myobject.abo.value = "Subscribe"
		myobject.FormDate.value = day + "." + month + "." + year + " - " + hour + ":" + minute;
        return true;
    }
}
function unsubscribeNews(myobject) {
    if (myobject.FromName.value == ""){
		alert("Bitte tragen Sie Ihren Namen ein!");
		(myobject.FromName).focus();
        return false;
    }
	if (myobject.FromEmail.value == ""){
		alert("Bitte tragen Sie Ihre Emailadresse ein!");
		(myobject.FromEmail).focus();
        return false;
    }
	if (myobject.FromEmail.value.indexOf('@') == -1){
		alert("Ihre Emailadresse ist unvollstaendig!");
		(myobject.FromEmail).focus();
        return false;
    }
	else {
        alert("Vielen Dank fuer Ihr Interesse am Newsletter!\nIhre Adresse wird aus dem Verteiler geloescht!\n\n");
		myobject.abo.value = "Unsubscribe"
		myobject.FormDate.value = day + "." + month + "." + year + " - " + hour + ":" + minute;
        return true;
    }
}

// ------------------- SET COOKIE ---------------------------------------------
function setCookie(name, value, days) {
	var expires = '';
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = '; expires='+date.toGMTString();
	}
	document.cookie = name+'='+value+expires+'; path=/';
}

function getCookie(name) {
	var nameEQ = name + '=';
	var ca = document.cookie.split(';');
	for(var i=0; i<ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	return null;
}

function deleteCookie(name) {
	createCookie(name, '', -1);
}