/*  
	last update 30.10.2007
	JavaScript libary by : M. Karr
	www: http://www.x11media.com
	version.0.3
	--> added by Sven M. -->
	www: http://www.sdesign.biz/
	2007-10-29 added Browser Detection; 
	see bottom - ned wirklich in Gebrauch aber vielleicht sinnvoll??
	To see what Browser version you are using, add the following lines to your html code
	<script type="text/javascript">
		document.write('<p class="accent">You\'re using ' + BrowserDetect.browser + ' ' + BrowserDetect.version + ' on ' + BrowserDetect.OS + '!</p>');
	</script>
	2007-10-30 added dunction: activateLightbox - ACTIVATE LIGHTBOX FROM FLASH
	2007-10-30 added function: toggleDisplay - FLASH BEI LIGHTBOX UNTER MAC VERSTECKEN
*/

var ImgBaseClass='popup-projekte-image';
var ImgActClass ='js-act';
var ImgPasClass='js';
var PreLoader = 'preloader';
var ImgRepcerid = 'replaceimg';

// ------------------------------------------------------------------
// for bluring links 
// ------------------------------------------------------------------
var browserName = navigator.appName;
var browserVer = parseInt(navigator.appVersion);
var version = "";
var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);

if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror" || browserName=="Opera") {version = "n3";} else {version = "n2";}
    // Blurring links:
    function blurLink(theObject)	{	//
	if (msie4)	{theObject.blur();}
}

// ------------------------------------------------------------------
// javacript to show and hide preloader ( <div id="preloader"><!-- --></div> ) 
// ------------------------------------------------------------------
  function showPreloader() 
  {
    // alert ('show');
    document.getElementById( 'preloader' ).style.display = 'block'; 
  }
  function hidePreloader( )
  { 
    // alert ('hide');
    document.getElementById( 'preloader' ).style.display = 'none'; 
  }
    
// ------------------------------------------------------------------
// javacript to change ccs style class 
// ------------------------------------------------------------------
// Works only on ellement with defined (id="somename") 
// Call like the element : 
// onMouseOut="change('this', 'def_class'); onMouseOver="change('this', 'over_class');

	function change( id, newClass )
	{
		identity=document.getElementById(id);
		identity.className=newClass;
	}

// ------------------------------------------------------------------
// function for image change in popups	
// ------------------------------------------------------------------

	function ChImg( file, id )
	{
    showPreloader( ); 
    ActClass = ImgBaseClass + ' ' + ImgActClass 
    PasClass = ImgBaseClass + ' ' + ImgPasClass 
		document.images[ImgRepcerid].src = file;
		var i = 1;
		while (document.getElementById( 'img' + i ) ) 
		{
		  change( 'img' + i, PasClass );
			i ++;
		}
  // alert ('ActClass: ' + ActClass + "\n" + 'PasClass: ' + PasClass );
	 change( id , ActClass );
	}
	
// ------------------------------------------------------------------
// function for popups 	
// ------------------------------------------------------------------
// Addon width/height, normaly should be 0 
// but if you want add some pixxels to all popups (IE and other Browsers)
	var Add_std_Width 	= 0;
	var Add_std_Height	= 0;
	
	var Add_ie_Width 	= 0;
	var Add_ie_Height		= 20;
// value if popup height greater than 598 px ( ie shit.... ,nobody nows why)
	var Add_ie_Height_gt_498	 = 0;	
// end config -----------------------------------	
// ---------------------------------------------------

// popup window name	
	var	DocName = 'smartypopup';
	var doc_win 		= 0;
	var Closeinfo 	= 1;

	function pop_up(doc,w,h)
	{
		if (doc_win.closed == true) {Closeinfo = 1;}
		if (navigator.appName == "Netscape")
		{
			w_sub = Add_std_Width; 
			h_sub = Add_std_Height;
		}
		else
		{
			w_sub = 	Add_std_Width 	+ Add_ie_Width;
			if ( h > 498 )
			{
				h_sub =  Add_std_Height + Add_ie_Height_gt_498;
			}	
			else
			{
				h_sub =  Add_std_Height + Add_ie_Height	;
			}
		}
		w = w + w_sub;
		h = h + h_sub;
  	doc_win = window.open(doc+'&nomv=1', DocName , 'location=no,menubar=no,toolbar=no,status=no,scrollbars=0,width='+ w +', height=' + h + ',resizable=0');

// test if URL param $nomv=1 is set
// if so, the popup is open, we navigate thru the popup-page and moving should stop now :-)	
// Closeinfo 0  means the popup is open and the user click onother popup in opener page 
// result is: move only if popup is a new popup window;
		var expr = /(nomv\=1)/g;
		if (!expr.test(document.URL) &&  Closeinfo == 1 )
		{

			MvValueFromLeft = screen.width / 2 - (w / 2) + w_sub;
			if (browserName != 'Opera' )
			{
				MvValueFromTop = screen.height / 2  - ( h / 2) + h_sub;		
				doc_win.moveTo( MvValueFromLeft , MvValueFromTop );		
				Closeinfo 	= 0;
			}
			else
			{
				MvValueFromTop = screen.height / 2  - ( h / 2) + h_sub;		
				MvValueFromTop = MvValueFromTop - 140;
				doc_win.moveTo( MvValueFromLeft , MvValueFromTop );
			  doc_win.focus;						
				Closeinfo 	= 0;
			}
		}
	doc_win.focus;
	}

// -------------------------------------------------------


// ------------------------------------------------------------------
// Browser Detection
// ------------------------------------------------------------------
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

// -------------------------------------------------------


/*  -------------------------------------------
BEGIN	 ACTIVATE LIGHTBOX FROM FLASH
 ---------------------------------------------- */
function activateLightbox(href) {  
	if (href) {
		var lightboxLink = document.createElement('a');
		lightboxLink.href = href;

 		var lb = new lightbox(lightboxLink);
		lb.activate();
	}
}

/*  -------------------------------------------
END		ACTIVATE LIGHTBOX FROM FLASH
 ---------------------------------------------- */
 
 
/*
// another function to activate lightbox from flash !!! not working on Apple/MAC Safari !!!
function executeLink(id)
{
	var l = document.getElementById(id);
	if(l.click) 	l.click();
	else if(document.createEvent) { // FF model
		var customClick = document.createEvent('MouseEvents');
		customClick.initMouseEvent('click',true,true,l.ownerDocument.defaultView,1,0,0,0,0,false,false,false,false,0,null);
		l.dispatchEvent(customClick);
	} else {
		// HMMZZZ.. Problem 
	}
}
*/


/*  -------------------------------------------
BEGIN	 FLASH BEI LIGHTBOX UNTER MAC VERSTECKEN
 ---------------------------------------------- */
function toggleDisplay() {
if (navigator.platform.indexOf('Mac') > -1)
	{
		if( document.getElementById("flashContent").style.display == "none" ) 
			{
			document.getElementById("flashContent").style.display = "block";
		  } else {
		    document.getElementById("flashContent").style.display = "none"; 
		}
	} 
}
/*  -------------------------------------------
END	 FLASH BEI LIGHTBOX UNTER MAC VERSTECKEN
 ---------------------------------------------- */
