function showResult(answerId, lang) {
	var resultText = "";
	var errorText = "";
	
	if (lang && lang=='en') {
		errorText = "Please choose an answer.";
		if(document.quiz.answer[answerId].checked) {
			resultText = "Answer "+(answerId+1)+" is correct.";
		} else {
			resultText = "A near miss. Answer "+(answerId+1)+" is correct.";
		}
	} else {
		errorText = unescape("Bitte w%E4hlen Sie eine Antwort.");
		if(document.quiz.answer[answerId].checked) {
			resultText = "Stimmt, Antwort "+(answerId+1)+".";
		} else {
			resultText = "Knapp daneben, Antwort "+(answerId+1)+" ist richtig.";
		}
	}

	if (checkRadioButtons()){
		document.getElementById('result').innerHTML = resultText;
	} else {
		document.getElementById('error').style.display = "block";
		document.getElementById('error').innerHTML = errorText;
	}	
}

function checkRadioButtons() {
	var isChecked = false;
	
	for (var i=0; i < document.quiz.answer.length; i++){
		if (document.quiz.answer[i].checked == true) {
			isChecked = true;
		}
	}
    return isChecked;
}


function getWinHeight(win)
{
    if(!win) win = window;
    var s = new Object();
    if(typeof win.innerHeight != 'undefined')
    {
        s.height = win.innerHeight;
    }
    else
    {
         var obj = getBody(win);
         s.height = parseInt(obj.clientHeight);
    }
    return s.height;
}

////////////////////////////////////////////////////////////
// Der IE hat 2 verschiedene Objekte f�r den strict und quirks Mode.
function getBody(w)
{
    return (w.document.compatMode && w.document.compatMode == "CSS1Compat") ? w.document.documentElement : w.document.body || null;
}  

var flashContent = false;
var magicMoments = false;
//var bottom_text_img = '/de/img/general/bottom-text.gif';
//var bottom_text_link = 'www.schott.com/hometech/german/products/robax/index.html';
	
function checkAndResize(lang){
	var winHeight = getWinHeight();
	var contentHeight = 0;
	
	if(magicMoments) {
		document.getElementById('contentOuterDiv').style.height = winHeight-123+"px";
		document.getElementById('contentOuterDiv').style.overflow = 'hidden';
	} else {
		if(flashContent) {
			contentHeight = document.getElementById('contentOuterDiv').offsetTop + 284;
		} else {
			contentHeight = document.getElementById('contentOuterDiv').offsetTop + document.getElementById('footerSpacer').offsetTop-178;
		}
	}
	
	if(document.getElementById('backgroundImg')) {
		if(winHeight > contentHeight+224 ){
			document.getElementById('backgroundImg').style.height = winHeight-152+30+"px";
			document.getElementById('backgroundImg').style.overflow = 'hidden';
		}else{
			document.getElementById('backgroundImg').style.height = contentHeight+350+"px";
			document.getElementById('backgroundImg').style.overflow = 'hidden';
		}
	}
	
	
	
/*	if (lang=='en') {
		bottom_text_img = '/en/img/general/bottom-text.gif';
	  bottom_text_link = 'www.schott.com/hometech/english/products/robax/index.html';
	} else
	if (lang=='dk') {
		bottom_text_img = '/dk/img/general/bottom-text.gif';
	  bottom_text_link = 'www.schott.com/hometech/english/products/robax/index.html';
	} else
	if (lang=='es') {
		bottom_text_img = '/es/img/general/bottom-text.gif';
	  bottom_text_link = 'www.schott.com/hometech/english/products/robax/index.html';
	} else
	if (lang=='fr') {
		bottom_text_img = '/fr/img/general/bottom-text.gif';
	  bottom_text_link = 'www.schott.com/hometech/english/products/robax/index.html';
	} else
	if (lang=='it') {
		bottom_text_img = '/it/img/general/bottom-text.gif';
	  bottom_text_link = 'www.schott.com/italian/index.html';
	}
	
	if ($('#backgroundImg').children().length==1) {
		$('#backgroundImg').append('<div style="position: absolute; bottom: 9px; left: 8px; width: 160px; height: 12px; z-index: 100; color: #fff;"><a href="http://'+bottom_text_link+'" title="'+bottom_text_link+'" target="_blank"><img src="'+bottom_text_img+'" alt="" title="" width="160" height="12" /></a></div>');
	}*/
	
}

function checkFlashHeight() {
	document.write('');
	
	document.getElementById('contentOuterDiv').style.height = document.getElementById('windowHeight').offsetHeight - 123 + "px";
	document.getElementById('contentOuterDiv').style.overflow = "hidden";
}

function hideBgSizedImage() {
	document.getElementById('backgroundImg').style.display = 'none';
}
function openPage(url) {
	window.location.href=url;
}

var bookmarkingTitle = "";
var bookmarkingText = document.title;

function getBookmarkingTitle() {
	if(typeof(bookmarkingText) != 'undefined' && bookmarkingText != null && bookmarkingText != "") {
		bookmarkingTitle = bookmarkingText;
	} else if(typeof(attributeTitle) != 'undefined' && attributeTitle != null && attributeTitle != ""){
		bookmarkingTitle = attributeTitle;
	}
	return bookmarkingTitle;
}

shareUrl = self.location.href;
shareTitle = document.title;

if(shareUrl.indexOf('/d/')!=-1)document.write('<div style="margin:31px 0px 25px 0px;"><a href="javascript://" class="dialogButtonShare " style="*background-position:0px 4px;">Link teilen<img src="' + getWcmsPrefix() +'/images/triggericons.gif" width="57" height="16" alt="" border="0" style="position:relative;top:4px;left:10px;"></a></div>');
if(shareUrl.indexOf('/e/')!=-1)document.write('<div style="margin:31px 0px 25px 0px;"><a href="javascript://" class="dialogButtonShare " style="*background-position:0px 4px;">Share<img src="' + getWcmsPrefix() +'images/triggericons.gif" width="57" height="16" alt="" border="0" style="position:relative;top:4px;left:10px;"></a></div>');

			  
function shareThis(url,service) {
  url = url.replace("{#share_url}", escape(shareUrl));
  url = url.replace("{#share_title}", escape(shareTitle));
  window.open(url,"share");
  return false;
}

path=self.location.pathname;
function trackSharing(service){
	var lang=path.split('/')[1];
	trackAbsolute("/"+lang+'/social/'+service,service);
	
}

function getWcmsPrefix(){
  var prefix = "";
//  if (self.location.href.indexOf('/bmwgroup_edit/') != -1) {
//    prefix = "/bmwgroup_edit";
//  } else if (self.location.href.indexOf('/bmwgroupqa/') != -1) {
//    prefix = "/bmwgroup_qa";
//  } else if (self.location.href.indexOf('/bmwgroup_prod/') != -1) {
//    prefix = "/bmwgroup_prod";
//  } else {
//  	prefix = "";
//  }
  return prefix;
}

function divisible(number,divider) {
   var temp = 0;
   var result = false;
   temp = number % divider;
   if(temp == 0) {
     result = true;
   }
   return result;
}



var share_services_active = true;
//var share_services_headline = "Jetzt sharen mit:";
var share_services_headline = "";
var share_services = new Array();
share_services[0] = new Array('DELICIOUS','http://delicious.com/save?url={#share_url}&title={#share_title}','/_common/img/delicious.png');
share_services[1] = new Array('DIGG','http://digg.com/submit?phase=2&url={#share_url}&title={#share_title}','/_common/img/digg.png');
share_services[2] = new Array('FACEBOOK','http://www.facebook.com/sharer.php?u={#share_url}&t={#share_title}','/_common/img/facebook.png');
share_services[3] = new Array('GOOGLE','http://www.google.com/bookmarks/mark?op=edit&bkmk={#share_url}&title={#share_title}','/_common/img/google.png');
share_services[4] = new Array('MISTER WONG','http://www.mister-wong.com/index.php?action=addurl&bm_url={#share_url}&bm_description={#share_title}','/_common/img/mr_wong.png');
share_services[5] = new Array('STUMBLEUPON','http://www.stumbleupon.com/submit?url={#share_url}&title={#share_title}','/_common/img/stumble_upon.png');
share_services[6] = new Array('TWITTER','http://twitter.com/home/?status={#share_url}','/_common/img/twitter.png');
share_services[7] = new Array('YAHOO!BUZZ','http://buzz.yahoo.com/submit/?submitUrl={#share_url}&submitHeadline={#share_title}','/_common/img/yahoo_buzz.png');
/*
share_services[8] = new Array('Myspace','http://www.myspace.com/Modules/PostTo/Pages/?u={#share_url}&t={#share_title}','/common/images/myspace.gif');
share_services[9] = new Array('Reddit','http://www.reddit.com/submit?url={#share_url}&title={#share_title}','images/reddit.gif');
share_services[10] = new Array('Windows Live','https://favorites.live.com/quickadd.aspx?url={#share_url}&title={#share_title}','images/windowslive.gif');
share_services[11] = new Array('Yammer','https://www.yammer.com/home?status={#share_url}','images/yammer.gif');
*/
$(document).ready(function() {

  if(typeof(share_services_active) == "boolean" &&  share_services_active) {
    var sharelayerCode = '<div class="dialogbox" id="shareDialogLayer"><div id="close"><a href="javascript://"><img id="closeImg" src="/_common/img/close.gif"></a></div><div class="content"><div class="sharecontent"><strong>' + share_services_headline + '</strong><table cellspacing="0" cellpadding="0" border="0">'
  
	for(i=0; i < share_services.length; i++ ) {
      sharelayerCode += '<tr valign="top">';
      sharelayerCode += '<td width="22" valign="top"><img src="' + getWcmsPrefix() + share_services[i][2] + '" width="17" height="16"></td>';
      sharelayerCode += '<td width="83" valign="top"><a href="" onClick="javascript:shareThis(\'' + share_services[i][1] + '\',\'' + share_services[i][0] + '\');trackSharing(\''+share_services[i][0]+'\');return false;" class="noBg">' + share_services[i][0] + '</a></td>';
      sharelayerCode += '</tr>';
    }
    sharelayerCode += '</table></div></div></div>';
    $("body").append(sharelayerCode);
  }
  else {
    $("a.dialogButtonShare").hide();
  }

  $("a.dialogButtonShare").click(
    function (event) {

      //dialogBoxesSetDimensions();
      var layerName = "#shareDialogLayer";
      var topPos = $(this).offset().top - ($(layerName).height() - 189);
	 
      var leftPos = $(this).offset().left - 130;
      var layerWidth = $(layerName).width();
	 
      $(layerName).css("top", topPos ).css("left", leftPos);
      $(layerName).css("visibility","visible");
      $(layerName).css("display","block");
    
      return false;
    });
	
$("#closeImg").click(
    function (event) {
      if( $(event.relatedTarget).attr("class") != "bottomArrowImage" && $(event.relatedTarget).attr("class") != "bottomArrowImageRight" && $(event.relatedTarget).attr("class") != "bottomBorder" && $(event.relatedTarget).attr("class") != "dialogbox" ) {
        var layerName = "#shareDialogLayer";
        $(layerName).css("visibility","hidden");
        $(layerName).css("display","none");
        $(layerName).css("top","-500px");
        $(layerName).css("left","-500px");
        $("a.dialogButtonShare").removeClass("dialogButtonShareActive").removeClass("dialogButtonDownloadActive").removeClass("dialogButtonFavoriteActive").removeClass("dialogButtonDeleteActive");
      }
      return false;
    }
  );
// ******** PREPARE DIALOG BOXES END ******** //




});
//document.ready end


$(document).ready(function(){
			$('.thumbaisSingleImagecontainer img').mouseover(function(){
				$('.thumbaisOverlay').css('display','none');
				$('.thumbaisOverlayContent').css('display','none');
				$(this).next().css('display','block');
				$(this).next().next().css('display','block');
			})
			$('.thumbaisSingleImagecontainer .thumbaisOverlay').mouseout(function(){
				$(this).next().css('display','none');
				$(this).css('display','none');
			})
			$('#threeFloatingImages .thumbaisSingleImagecontainer .thumbaisOverlayContent').mouseover(function(){
				$(this).prev().css('display','block');
				jQuery(this).css('display','block');
			})
		});

	$(document).ready(function(){
			$('.largeSingleImagecontainer img').mouseover(function(){
				$('.largeOverlay').css('display','none');
				$('.largeOverlayContent').css('display','none');
				$(this).next().css('display','block');
				$(this).next().next().css('display','block');
			})
			$('.largeSingleImagecontainer .largeOverlay').mouseout(function(){
				$(this).next().css('display','none');
				$(this).css('display','none');
			})
			$('#threeFloatingImages .largeSingleImagecontainer .largeOverlayContent').mouseover(function(){
				$(this).prev().css('display','block');
				jQuery(this).css('display','block');
			})
		});


