/*
 * Javascript basic
 * Basic javascript for TROX - elephant seven bielefeld, christian wemhoff - 17.10.07
 * $Id: basic.js 594 2010-10-11 08:39:55Z christianw $
 */

/* Browsererkennung */
if ($.browser.msie) { if($.browser.version == 6) {var isIe6 = true} else {isIe6 = false} }

$(document).ready(function() {

	// replace classes / toggle visibility
	$(".jHide").hide()
	$(".jShow").show()


	// init Mousover topnavi
	$('#topnavi a:not(.act)').hover(
		function() {
			navImg = $('img', this)
			navImgSrc = navImg.attr('src')
			navImgHiSrc = navImg.attr('longdesc')
			navImg.attr('src', navImgHiSrc)
			navImg.attr('longdesc', navImgSrc)
		},
		function() {
			navImg.attr('src', navImgSrc)
			navImg.attr('longdesc', navImgHiSrc)
		}
	)

	// init Quickclicks
	$(".dropdownlist").change( function () {
		var thisOption = this.options[this.selectedIndex]
		var thisClass = $(thisOption).attr('class')
		if (thisOption.title != '' && (thisClass != '_blank')) {
			window.location.href = thisOption.title
		} else if (thisClass == '_blank') {
			window.open(thisOption.title)
		}
	});

	// init searchfield
	$("#suche").focus( function () {
		if (this.value != "") {this.value = ""}
	});


	// init imageSwitch
	$(".swImage").hide()
	$(".imageSwitch .zoom a:first").removeClass("hidden")
	$("#swImage1").show()

	$(".moduleImgSwitcher li:not(.zoom)").click(function () {
		 $(".moduleImgSwitcher li").removeClass('act')
    	 $(this).addClass('act')
		 var illuNumber = $(this).attr('accesskey')
		 $(".swImage").hide()
		 $("#swImage"+illuNumber).show()
		 $(".imageSwitch .zoom a:not(.hidden)").addClass('hidden')
		 $(".imageSwitch .zoom a:nth-child("+($(this).index()+1)+")").removeClass("hidden")
		 return false
    });


	// set tab click false
	$('ul.moduleTabs a').click(function () {
		return false
	})

	if (checkFlash() == true || flash == true) {$('.hideIfFlash').hide()}
})

// function checkFlash
function checkFlash() {
	if (!$.browser.msie) {
		flash = false
		if ((navigator.mimeTypes) && (navigator.mimeTypes.length > 0))
		for (a = 0; a < navigator.mimeTypes.length; a++)
		if (navigator.mimeTypes[a].type.indexOf("application/x-shockwave-flash")>= 0) flash = true
		return true
	} else {
		return false
	}
}
// function setFlash
function setFlash(swfSrc, swfWidth, swfHeight, swfParameter, swfVersion) {
	if (!swfWidth) {
		if (isIe6) { swfWidth = '710' }
		else { swfWidth = '710' }


	}
	if (!swfHeight) swfHeight = '253'
	if (!swfVersion) swfVersion = '8'
	if (!swfParameter) swfParameter = ''

	/* IE6 Bugfix */
	if (isIe6 && swfWidth >= '794') {
		swfWidth = '794'
	}

	if (checkFlash() == true || flash == true) {
   	$('body.home #teasertext, .stage img').remove()
		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"')
		document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+swfVersion+',0,0,0" ')
		document.write(' WIDTH="'+swfWidth+'" HEIGHT="'+swfHeight+'">')
		document.write(' <PARAM NAME=movie VALUE="'+swfSrc+'?'+swfParameter+'"><PARAM NAME="quality" VALUE="high"> <PARAM NAME="menu" VALUE=False> <PARAM NAME="wmode" VALUE="transparent">')
		document.write(' <EMBED src="'+swfSrc+'?'+swfParameter+'" quality="high" ')
		document.write(' swLiveConnect=false WIDTH="'+swfWidth+'" HEIGHT="'+swfHeight+'" menu=false wmode="transparent"')
		document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">')
		document.write(' </EMBED>')
		document.write(' </OBJECT>')
	}
}

// function mailme
function mailme( host, name, subject ){
	if( subject ) {
	    self.location = "mail" + "to:" + name + "@" + host + "?subject=" + subject
	} else {
	    self.location = "mail" + "to:" + name + "@" + host
	}
    return false;
}
