﻿/* 
 modified by Michael Stamm, PixelLion, 2011
*/

/*
	jQuery Coda-Slider v2.0 - http://www.ndoherty.biz/coda-slider
	Copyright (c) 2009 Niall Doherty
	This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.
*/

var sliderCount = 1;
var lastHref = "";
var save = "";
var start = false;
var clickedTeamLink = "";
var clickedStartSeiteLink = "";

var gMapDisplayTimer = 0;

version = jQuery.browser.version || "0";
splitVersion = version.split('.');

$.fn.codaSlider = function(settings) {

	settings = $.extend({
		autoHeight: true,
		autoHeightEaseDuration: 1000,
		autoHeightEaseFunction: "easeInOutExpo",
		autoSlide: false,
		autoSlideInterval: 7000,
		autoSlideStopWhenClicked: true,
		crossLinking: true,
		dynamicArrows: false,
		dynamicArrowLeftText: "&#171; left",
		dynamicArrowRightText: "right &#187;",
		dynamicTabs: false,
		dynamicTabsAlign: "center",
		dynamicTabsPosition: "top",
		externalTriggerSelector: "a.xtrig",
		firstPanelToLoad: 1,
		panelTitleSelector: "h3.title",
		slideEaseDuration: 1000,
		slideEaseFunction: "easeInOutExpo"
	}, settings);
	
	return this.each(function(){
	
	var hoverInfoBox = false;

HTTP_GET_VARS=new Array();
strGET=document.location.search.substr(1,document.location.search.length);
if(strGET!='')
    {
    gArr=strGET.split('&');
    for(i=0;i<gArr.length;++i)
        {
        v='';vArr=gArr[i].split('=');
        if(vArr.length>1){v=vArr[1];}
        HTTP_GET_VARS[unescape(vArr[0])]=unescape(v);
        }
    }
 
function GET(v)
{
if(!HTTP_GET_VARS[v]){return undefined;}
return HTTP_GET_VARS[v];
}

function infoGrid() {
	initTechnologyDemoSound();
	
	$("#page-wrap").find("dd a.more").each(function() {
	
		$el = $(this); 
		
		$el.fancybox({
        "type": "inline",
        "autoScale": false,
        "width": 640,
        "height": 385,
        "transitionIn": "fade",
        "transitionOut": "fade",
        "easingIn": "easeOutBack",
        "easingOut": "easeInBack"
       });
    });
    
    $("#page-wrap").find("a.youtube").each(function(event) {
      		$(this).fancybox({
        "width": 640,
        "height": 385,
        "transitionIn": "fade",
        "transitionOut": "fade",
        "easingIn": "easeOutBack",
        "easingOut": "easeInBack",
        'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type'      : 'swf',
            'swf'       : {'wmode':'transparent','allowfullscreen':'true'}

       });
    });
    
    $("#page-wrap").find("a.youtubeportal").each(function(event) {
      		$(this).fancybox({
        "width": 950,
        "height": 700,
        "transitionIn": "fade",
        "transitionOut": "fade",
        "easingIn": "easeOutBack",
        "easingOut": "easeInBack",
        'href' : this.href,
            'type'      : 'iframe'
            

       });
    });
    
    $("#page-wrap").find("a.externlink").each(function(event) {
    	var url = $(this).attr("href");
    	$(this).bind("click", function(event) {
  			event.preventDefault();
  			fenster = window.open(url, "neu", "width=600,height=400,status=yes,scrollbars=yes,resizable=yes");
   			fenster.focus();
  		});
    });
    
    $("#page-wrap").find("a.externlink2").each(function(event) {
    	var url = $(this).attr("href");
    	$(this).bind("click", function(event) {
  			event.preventDefault();
  			fenster = window.open(url, "neu", "width=1000,height=700,status=yes,scrollbars=yes,resizable=yes");
   			fenster.focus();
  		});
    });
    
    
	//stamm: google plus won't work with IE6
	//gapi.plusone.go();

    // Set up variables
    var $el, $parentWrap, $otherWrap, 
        $allTitles = $("dt").css({
            padding: 5, // setting the padding here prevents a weird situation, where it would start animating at 0 padding instead of 5
            "cursor": "pointer" // make it seem clickable
        }),
        $allCells = $("dd").css({
            position: "relative",
            top: -1,
            left: 0,
            display: "none" // info cells are just kicked off the page with CSS (for accessibility)
        });
    
    // clicking image of inactive column just opens column, doesn't go to link   
    $("#page-wrap").delegate("a.image","click", function(e) { 
        
        if ( !$(this).parent().hasClass("curCol") ) {         
            e.preventDefault(); 
            $(this).next().find('dt:first').click(); 
        } 
        
    });
    
	//alert($("#page-wrap").html());
	
    // clicking on titles does stuff
    $("#page-wrap").delegate("dt", "click", function() {
	//alert("test");
        //playSoundPart();
        // cache this, as always, is good form
        $el = $(this);
        
        // if this is already the active cell, don't do anything
        if (!$el.hasClass("current")) {
        
            $parentWrap = $el.parent().parent();
			$parentParentWrap = $el.parent().parent().parent();
			//alert(); // 
            $otherParentWraps = $(".info-col").not($parentParentWrap);
			$otherWraps = $(".info-col-bg").not($parentWrap);
			
			$parentIdent = $parentWrap.find("h2").html();

            // remove current cell from selection of all cells
            $allTitles = $("dt").not(this);
            
            // close all info cells
            $allCells.slideUp();
            
            // return all titles (except current one) to normal size
            $allTitles.animate({
                fontSize: "12px",
                paddingTop: 10,
                paddingRight: 5,
                paddingBottom: 10,
                paddingLeft: 30
            }).removeClass("activeTitle");
            
            // animate current title to larger size            
            $el.animate({
                "font-size": "16px",
                paddingTop: 20,
                paddingRight: 5,
                paddingBottom: 0,
                paddingLeft: 30
            }).addClass("activeTitle").next().slideDown();
			
            
            // make the current column the large size
            $parentWrap.animate({
                width: 275
            }, 500);
			
			$parentParentWrap.animate({
                width: 275
            }, 500, function() {$parentWrap.find('dd').css('overflow', 'visible');}).addClass("curCol");
            
            // make other columns the small size
            $otherWraps.animate({
                width: 140
            }).removeClass("curColBg").find('dd').css('overflow', 'hidden');
			
			$parentWrap.removeClass("curColBg");
			
			$otherParentWraps.animate({
                width: 140
            }).removeClass("curCol");
            
            // make sure the correct column is current
            $allTitles.removeClass("current");
            $el.addClass("current");
			
			// Make left with right-border
			for(var i = 0; i < $parentParentWrap.parent().children().size(); i++)
			{
				$($parentParentWrap.parent().children()[i]).find("h2").html();
				if($($parentParentWrap.parent().children()[i]).find("h2").html() == $parentIdent)
				 if(i != 0)
					$($parentParentWrap.parent().children()[i - 1]).find(".info-col-bg").addClass("curColBg");
			}
        
        }
        
    });
    
    
    var foundarticle = false;
    if(typeof(GET('article')) === "undefined")
    	$("#starter").trigger("click");
    else { $("#page-wrap").find("dt").each(function() {
    		//alert($(this).html().replace("é","").replace("á","").replace(":", "") + " " + clickedStartSeiteLink);
    		if($(this).html().replace("é","").replace("é","").replace("á","").replace(":", "").replace(" ", "").replace(" ", "").replace(" ", "").replace(" ", "") == GET('article')) {
    			$(this).trigger("click");
    			foundarticle = true;
    		}
    	});	
    	
    	if(!foundarticle) $("#starter").trigger("click");
    }
	
	$("#page-wrap").find(".dot").bind("mouseenter", function() {
		$el = $(this);
		
		// infodot
		
		$el.addClass("activeDot");
		if($.browser.mozilla){
		 //console.log();
	 }
	 $("#infoDot").remove();
	 $("body").append("<div id=\"infoDot\" style=\"z-index:10000; position:absolute; left:" + (parseInt($el.offset().left) - 129) + "px; top:" + (parseInt($el.offset().top) - 135) + "px;\"></div>");
		$("#infoDot").append(insertTeamPersons($el.attr("title"),$el.attr("rel")));
		setTeamLink($("#infoDot"));
		
		//$position = -76 + $el.offset().left - $el.parent().offset().left - 52;
		//alert($el.offset().left);
		//$el.after(insertTeamPersons($position,$el.attr("title"),$el.attr("rel")));
		//$el.after('<div class="detailBox" style="bottom: 23px; left: '+$position+'px"><div class="left"><img src="images/personen/lsyre.png" /></div><div class="right"><h3>Leon Syré</h3>Head of ECM<br /><br />Lorem ipsum dolor sit amet, consectetur adipisici elit, sed</div></div>');
		$(".detailBox").bind("mouseenter", function() {
			if(hoverInfoBox) {
				hoverInfoBox = false;
				//
			}
				
			$el = $(this);
			
			//$el.parent().prev().addClass("activeDot");
			hoverInfoBox = true;
		});
		
		$(".detailBox").bind("mouseleave", function() {
			$el = $(this);
			hoverInfoBox = false;
			
			//$el.remove();
			// stamm:
			$("#infoDot").remove();
			$(".dot").removeClass("activeDot");
		});
	}).css("cursor", "pointer");
	
	$("#page-wrap").find(".dot").bind("mouseout", function() {
		window.setTimeout(function() {
			if(!hoverInfoBox) {
				//$(".detailBox").remove();
				// stamm:
			 $("#infoDot").remove();
				$el = $(".dot");
				$el.removeClass("activeDot");
			}
		}, 10);
	});
	
 setTeamLink($("#page-wrap"));
    
}

function setTeamLink(obj){
	$(obj).delegate(".teamLink", "click", function() {
		$("#page-wrap").find(".dot").removeClass("activeDot");
		$("#infoDot").remove();
			$el = $(this);
			$title = $el.attr("title");
			//alert($title);
			var targetVector = getTargetVector("de/wer-sind-wir.html", -1);
			clickedTeamLink = $title;
			if($("div.panel:eq(" + (targetVector[0] - 1) + ")").find("div.loading_box").length > 0
					   && $("div.panel:eq(" + (targetVector[0] - 1) + ")").find("div.panel-wrapper").attr("url") != undefined
					   || targetVector[0] == 7){ // && targetVector[1] == -1
      					getPageContent(targetVector, "de/wer-sind-wir.html");
      					
					}
					else{
						sideScoller(targetVector);
     				}
		});
}

	
	function iComms() {
	  var flashvars = {};		
      var params = {};
      params.play = "true";
      params.menu = "false";
      params.scale = "showall";
      params.wmode = "transparent";
      params.allowfullscreen = "false";
      params.allowscriptaccess = "never";
      params.allownetworking = "all";
	  
	  if(jQuery.browser.flash)
      	swfobject.embedSWF('content/flash/icomms/icomms.swf', 'icommsVideoInner', '730', '290', '9', null, flashvars, params, null);
	  else $("#icommsVideoInner").html('<img src="images/icomms_nojs.png" />');
	}
	
	function startSeite() {
	  	if(!start) {
      		$(".slider_box").boxSlider({"windowWidth":900});
      		
      		$(".slider_box").find(".linkToOurServices a").each(function(event) {
      			
      			if($(this).attr("class") == "") {
      			$(this).bind("click", function(event) {
					//$("#teamTopSlider").css("display","none");
				event.preventDefault();
				
				$title = $(this).attr("href");
      			$title = $title.split("#");
      			$title = $title[1].replace(/_/g," ");
				
      			var targetVector = getTargetVector("de/was-leisten-wir.html", -1);
				clickedStartSeiteLink = $title;
				if($("div.panel:eq(" + (targetVector[0] - 1) + ")").find("div.loading_box").length > 0
					   && $("div.panel:eq(" + (targetVector[0] - 1) + ")").find("div.panel-wrapper").attr("url") != undefined
					   || targetVector[0] == 7){ // && targetVector[1] == -1
      					getPageContent(targetVector, "de/was-leisten-wir.html");
      					
					}
					else{
						sideScoller(targetVector);
     				}
     			});
     			}
      		});
      		
      		$(".slider_box").find("a.youtube").each(function(event) {
      		$(this).fancybox({
        "width": 640,
        "height": 385,
        "transitionIn": "fade",
        "transitionOut": "fade",
        "easingIn": "easeOutBack",
        "easingOut": "easeInBack",
        'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type'      : 'swf',
            'swf'       : {'wmode':'transparent','allowfullscreen':'true'}

       });
       });
       		
       		$(".slider_box").find("a.externlink").each(function(event) {
    	var url = $(this).attr("href");
    	$(this).bind("click", function(event) {
  			event.preventDefault();
  			fenster = window.open(url, "neu", "width=1000,height=700,status=yes,scrollbars=yes,resizable=yes");
   			fenster.focus();
  		});
    });
    
    		 $(".slider_box").find("a.youtubeportal").each(function(event) {
      		$(this).fancybox({
        "width": 1000,
        "height": 700,
        "transitionIn": "fade",
        "transitionOut": "fade",
        "easingIn": "easeOutBack",
        "easingOut": "easeInBack",
        "href": "http://www.youtube.com/user/KWPcommunications?blend=21&ob=5",
            'type'      : 'iframe'
            

       });
    });
      		
      		start = true;
      	}
	}
	
	function teamSlider() {
		$("#target").mopSlider({'w':890, 'h':260, 'sldW':620, 'btnW':72, 'indi':"", 'shuffle':'y', 'type':'paper', 'auto':'yn', 'move': 50000, 'interval': 1000});
		
		$("html").find("p.start_movie a:eq(0)").fancybox({
        "href": "http://www.kwp-marketing.de/tl_files/flash/kwp_impressionen_small.swf",
        "type": "swf",
        "swf": {
         "wmode": "transparent",
         "allowFullScreen": "true",
         "allowscriptaccess": "always"
        },
        "width": 640,
        "height": 385,
        "transitionIn": "fade",
        "transitionOut": "fade",
        "easingIn": "easeOutBack",
        "easingOut": "easeInBack"
       });
	}
	
	function googleMaps() {
	
		mapOpened = true;
      	var latlng = new google.maps.LatLng(50.154825, 8.683909);
    	var markerPosition = new google.maps.LatLng(50.047525, 8.683909);
    	var myOptions = {
      		zoom: 10,
      		center: latlng,
      		mapTypeId: google.maps.MapTypeId.ROADMAP
    	};
    	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    	
    	var contentString = '<table border="0" width="276" style="overflow:hidden;">    <tr>      <td><a target="_blank" href="http://maps.google.de/maps/place?cid=4485160359648831841&amp;q=KWP+Marketing+%7C+Agentur+f%C3%BCr+Unternehmenskommunikation,+Schleu%C3%9Fnerstra%C3%9Fe+54,+Neu-Isenburg&amp;hl=de&amp;cd=1&amp;cad=src:ppiwlink&amp;ei=leZzTb2tLNOJ_QbJwvCqAw"><b>KWP</b> GmbH &amp; Co. KG</a></td>    </tr>    <tr>      <td><table width="276" border="0" style="margin-bottom:20px;">        <tr>          <td width="170">Schleussnerstraße 54</td>          <td rowspan="4"><a target="_blank" href="http://maps.google.de/maps/place?cid=4485160359648831841&amp;q=KWP+Marketing+%7C+Agentur+f%C3%BCr+Unternehmenskommunikation,+Schleu%C3%9Fnerstra%C3%9Fe+54,+Neu-Isenburg&amp;hl=de&amp;cd=1&amp;cad=src:ppiwlink&amp;ei=leZzTb2tLNOJ_QbJwvCqAw&amp;dtab=5"><img border="0" alt="Foto" src="http://lh5.googleusercontent.com/public/yuWDJtH4tECjMbJIri3If7-wHVaSJv3JykzjIi2wSGmwvRMpzP0d7SEPFrhywWEL1JX40mwWfM0PMWEi7191J6a8kMB7KHdLCI6XYiHCyA" ></a></td>        </tr>        <tr>          <td>63263 Neu Isenburg</td>          </tr>        <tr>          <td>06102 3679980</td>          </tr>        <tr>          <td><a href="http://www.kwp-communications.com">kwp-communications.com</a></td>          </tr>      </table></td>    </tr>    <tr>      <td><a href="http://maps.google.de/maps?f=d&source=s_q&hl=de&geocode=&q=KWP+Marketing+|+Agentur+f%C3%BCr+Unternehmenskommunikation,+Schleu%C3%9Fnerstra%C3%9Fe+54,+Neu-Isenburg&aq=0&sll=50.148012,8.683912&sspn=0.000885,0.002411&ie=UTF8&hq=KWP+Marketing+|+Agentur+f%C3%BCr+Unternehmenskommunikation,&hnear=Schleu%C3%9Fnerstra%C3%9Fe+54,+Neu-Isenburg+63263+Neu-Isenburg,+Offenbach,+Hessen&cid=4485160359648831841&ll=50.054825,8.683909&spn=0.021217,0.05579&z=14&iwloc=A&daddr=Schleussnerstrasse+54,+63263+Neu+Isenburg+%28KWP+GmbH+%26+Co.+KG%29" target="_blank">Routenplaner</a></td>    </tr>  </table>';

		var infowindow = new google.maps.InfoWindow({
    		content: contentString
		});		
		
		var image = new google.maps.MarkerImage('images/kwp_pin.png',
  		new google.maps.Size(87,61),
  		new google.maps.Point(0,0),
  		new google.maps.Point(27,61));

  		
  		var shape = {
  				coord: [34,0,36,1,38,2,39,3,40,4,41,5,42,6,42,7,43,8,43,9,44,10,44,11,44,12,45,13,45,14,45,15,45,16,45,17,45,18,45,19,45,20,45,21,45,22,45,23,45,24,44,25,44,26,44,27,43,28,43,29,42,30,42,31,41,32,40,33,40,34,39,35,38,36,38,37,37,38,37,39,36,40,36,41,35,42,35,43,34,44,34,45,33,46,33,47,33,48,32,49,32,50,31,51,31,52,31,53,30,54,29,55,28,56,27,57,27,58,27,59,26,60,24,60,21,59,18,58,16,57,14,56,13,55,11,54,9,53,7,52,5,51,4,50,2,49,0,48,0,47,0,46,0,45,0,44,0,43,0,42,0,41,0,40,0,39,0,38,1,37,1,36,2,35,4,34,6,33,10,32,10,31,9,30,9,29,8,28,8,27,7,26,7,25,7,24,7,23,7,22,6,21,6,20,6,19,6,18,6,17,6,16,7,15,7,14,7,13,7,12,7,11,8,10,8,9,9,8,9,7,10,6,11,5,11,4,13,3,14,2,15,1,18,0,34,0],
  				type: 'poly'
		};


		var marker = new google.maps.Marker({
    						position: markerPosition,
    						icon: image,
  							shape: shape,
    						map: map,
    						title:"KWP GmbH"
		});
		
		google.maps.event.addListener(marker, 'click', function() {
  			infowindow.open(map,marker);
		});
		infowindow.open(map,marker);
	
	}
  
  function setLinksJobs(domTarget) {
  
  	$(domTarget).each(function(){
  		
  		$(this).bind("click", function(event) {
  			event.preventDefault();
  			if(lastHref != $(this).attr("href")) {
  			lastHref = $(this).attr("href");
  			//alert("hallo;");
  			if(!jQuery.browser.msie)
  				$("div.panel:eq(6) div.althera_column_233").fadeTo(500,0.01);
  			//$(".subcolumns").html("");
  			$(domTarget).css("font-weight","normal").css("color","#585858");
  			$(this).css("font-weight","bold").css("color","#8FA600");
  			
  			
  			// Stamm 25.03.2011
  			var jobFile = parseURL($(this).attr("href")).file;
  			var jobIndex = 0;
  			$(window.xmlStructure).find("content>menu:eq(0)>page:eq(6)>menu:eq(0)").children("page").each(function(){
  			 if($(this).attr("url") == jobFile){
  			  jobIndex = $(this).index() + 1;
  			 }
  		 });
  		 // Stamm 25.03.2011
  			
  			$.ajax({
  				type: "GET",
  				url: $(this).attr("href").replace(/.html$/, ".xml"),
  				dataType: "xml",
  				error: function(XMLHttpRequest, textStatus, errorThrown){
   					//$("a.img_box").fancybox({"showNavArrows":false});
  				},
  				success: function(xml){
  					if($(xml).find("content").length == 1){
    
    					newText = $(xml).find("content:eq(0)").text();
    					newHTML = $(newText).html(newText);
    					
    					if($(newHTML).find("div.althera_column_233:").length > 0) {
    						//alert();
    						$(newHTML).find("div.althera_column_233 img").each(function(){
    							$(this).attr("src", $(this).attr("src").replace("../../",""));
    						});
    						$("div.panel:eq(6) div.althera_column_233").html($(newHTML).find("div.althera_column_233:eq(0)").html());
    						refreshPanelHeight();
    						if(!jQuery.browser.msie)
    							$("div.panel:eq(6) div.althera_column_233").fadeTo(500, 1);

          // Stamm 25.03.2011
          setTitle([window.lastVector[0], jobIndex]);
          // Stamm 25.03.2011
          
    					}
    				}
  				}});
  				
  			}
  		});
  	});
  }
  
  function setLinksPresse(domTarget) {
  
  	$(domTarget).each(function(){
  		
  		$(this).bind("click", function(event) {
  			event.preventDefault();
  			if(lastHref != $(this).attr("href")) {
  			lastHref = $(this).attr("href");
  			//alert("hallo;");
  			if(!jQuery.browser.msie)
  				$("div.panel:eq(7) div.althera_column_233").fadeTo(500,0.01);
  			//$(".subcolumns").html("");
  			$(domTarget).css("font-weight","normal").css("color","#585858");
  			$(this).css("font-weight","bold").css("color","#8FA600");
  			
  			
  			// Stamm 25.03.2011
  			var presseFile = parseURL($(this).attr("href")).file;
  			var presseIndex = 0;
  			$(window.xmlStructure).find("content>menu:eq(0)>page:eq(7)>menu:eq(0)").children("page").each(function(){
  			 if($(this).attr("url") == presseFile){
  			  presseIndex = $(this).index() + 1;
  			 }
  		 });
  		 // Stamm 25.03.2011
  			
  			$.ajax({
  				type: "GET",
  				url: $(this).attr("href").replace(/.html$/, ".xml"),
  				dataType: "xml",
  				error: function(XMLHttpRequest, textStatus, errorThrown){
   					//$("a.img_box").fancybox({"showNavArrows":false});
   					alert("test");
  				},
  				success: function(xml){
  				
  					if($(xml).find("content").length == 1){
    
    					newText = $(xml).find("content:eq(0)").text();
    					newHTML = $(newText).html(newText);
    					
    					if($(newHTML).find("div.althera_column_233:").length > 0) {
    						//alert();
    						//alert(newText);
    						$(newHTML).find("div.althera_column_233 img").each(function(){
    							$(this).attr("src", $(this).attr("src").replace("../../",""));
    						});
    						$("div.panel:eq(7) div.althera_column_233").html($(newHTML).find("div.althera_column_233:eq(0)").html());
    						refreshPanelHeight();
    						if(!jQuery.browser.msie)
    							$("div.panel:eq(7) div.althera_column_233").fadeTo(500, 1);

          // Stamm 25.03.2011
          setTitle([window.lastVector[0], presseIndex]);
          // Stamm 25.03.2011
          
    					}
    				}
  				}});
  				
  			}
  		});
  	});
  }
  
  function setLinksTeam(domTarget) {
  	$(domTarget).each(function(){

  		$(this).bind("click", function(event) {
  			event.preventDefault();
  			if(lastHref != $(this).attr("href")) {
  			lastHref = $(this).attr("href");
  			if(!jQuery.browser.msie)
  				$(".subcolumns").fadeTo(500,0.01);
  			//$(".subcolumns").html("");
  			
	
	    // Stamm 25.03.2011
  			var teamFile = parseURL($(this).attr("href")).file;
  			var teamIndex = 0;
  			$(window.xmlStructure).find("content>menu:eq(0)>page:eq(1)>menu:eq(0)").children("page").each(function(){
  			 if($(this).attr("url") == teamFile){
  			  teamIndex = $(this).index() + 1;
  			 }
  		 });
  		 // Stamm 25.03.2011
  			
  			$.ajax({
  				type: "GET",
  				url: $(this).attr("href").replace(/.html$/, ".xml"),
  				dataType: "xml",
  				error: function(XMLHttpRequest, textStatus, errorThrown){
   					//$("a.img_box").fancybox({"showNavArrows":false});
   					alert("Error");
  				},
  				success: function(xml){
  					if($(xml).find("content").length == 1){
    					newText = $(xml).find("content:eq(0)").text();
    					newHTML = $(newText).html(newText);
    					
    					if($(newHTML).find("div.subcolumns:").length > 0) {
    						//alert();
    						$(newHTML).find("div.subcolumns img").each(function(){
    							$(this).attr("src", $(this).attr("src").replace("../../",""));
    							if($(this).attr("src").indexOf("/uploads/") != -1)
    							$(this).attr("src", $(this).attr("src").replace("http://office.kwp-marketing.de/kunden/","").replace("http://berlin/kunden/","").replace("http://www.kwp-marketing.de/",""));
    						});
    						$(".subcolumns").html($(newHTML).find("div.subcolumns:eq(0)").html());
    						refreshPanelHeight();
    						if(!jQuery.browser.msie){
    							$(".subcolumns").fadeTo(500, 1);
    						}
    						
    						// Stamm 25.03.2011
          setTitle([window.lastVector[0], teamIndex]);
          // Stamm 25.03.2011
    						
    						if(jQuery.browser.msie && splitVersion[0] == 6) {
    							$("#mopSlider1").css("margin","0");
    							$("#mopSlider").css("margin","0");
    						}
    					}
    					
    					
    				}
  				}});
  				
  			}
  		});
  	});
  }
  
function setLinks(domTarget){
		$(domTarget).each(function(){

   var targetVector = getTargetVector((getRelativePath(this, "href")).url, $(this).parents("div.panel:eq(0)").index());
   //alert((getRelativePath(this, "href")).url);
   //alert((getRelativePath(this, "href")).url + " " + $(this).parents("div.panel:eq(0)").index());
	

   if(targetVector[0] != -1){
    var targetURL = (getRelativePath(this, "href")).url;
    
    targetURL = parseURL(targetURL);
    
    
    
				$(this).bind("click", function(event) {
					//$("#teamTopSlider").css("display","none");
				 	event.preventDefault();
				 	//alert(targetVector);
				 	if(targetVector[0] != 2) lastHref = "";
				 	
				 	if(getPagePrehandle() == "de/") contentFile = "en/pagestructure.xml";
				 	else contentFile = "de/pagestructure.xml";
				 	
				 	setLanguageLink(contentFile,targetVector[0]);
				 	
					if($("div.panel:eq(" + (targetVector[0] - 1) + ")").find("div.loading_box").length > 0
					   && $("div.panel:eq(" + (targetVector[0] - 1) + ")").find("div.panel-wrapper").attr("url") != undefined
					   || targetVector[0] == 7){ // && targetVector[1] == -1
      					getPageContent(targetVector, getPagePrehandle()+targetURL.file);
      					
					}
					/*else if($("div.panel:eq(" + (targetVector[0] - 1) + ") div.col1_content:eq(" + (targetVector[1]) + ")").find("div.loading_box").length > 0
						&& $("div.panel:eq(" + (targetVector[0] - 1) + ") div.col1_content:eq(" + (targetVector[1]) + ")").attr("url") != undefined){
      					getPageContent(targetVector, getPagePrehandle()+targetURL.file);
					}*/
					else{
						sideScoller(targetVector);
     				}
     				  setTitle(targetVector);
				});
		 
		 
		 
		 
		 }
		 
		 
		 
		});
}

function setLanguageLink(contentFile,targetVector) {
	newUrl = $(window.otherXmlStructure).find("content>menu>page:eq(" + (targetVector - 1) + ")").attr("url");
  	$("div #footer li.lang a:eq(0)").attr("href", newUrl);
}


function getTargetVector(targetURL, basePanelIndex){
 var targetVector = [-1, -1];
 targetURL = parseURL(targetURL);
 
 
 //alert(window.baseDir + " " + targetURL.folders.length);
 // window.baseDir == "../" && 
 if(targetURL.type == 3){
  if(targetURL.folders.length == 1){
  
   // von Level0 nach Level0
   // ./index.html -> ./impressum.html
   $(window.xmlStructure).find("content>menu>page").each(function(){
    if($(this).attr("url") == getPagePrehandle()+targetURL.file){
     targetVector[0] = $(this).index() + 1;
     if($(this).children("menu").length > 0){
      targetVector[1] = 0;
     }
    }
   });
  }
  else if(targetURL.folders.length > 1){
   // von Level0 nach Level1
   // ./index.html -> ./rezepte/mittags.html
   $(window.xmlStructure).find("content>menu>page>menu").each(function(){
    if($(this).attr("url") == targetURL.folders[targetURL.folders.length - 1]){
     var tempIndex = $(this).parent().index();
     $(window.xmlStructure).find("content>menu>page:eq(" + tempIndex + ")>menu>page").each(function(){
      if($(this).attr("url") == getPagePrehandle()+targetURL.file){
       targetVector[0] = tempIndex + 1;
       targetVector[1] = $(this).index() + 1;
      }
     });
    }
   });
  }
  else if(window.baseDir != "../" && targetURL.folders.length == 1){
   // von Level1:eq(0) nach Level1:eq(0)
   // ./rezepte/mittags.html -> ./rezepte/nachmittags.html
   basePanelIndex = 2;
   $(window.xmlStructure).find("content>menu>page:eq(" + basePanelIndex + ")>menu>page").each(function(){
    //alert($(this).attr("url"));
    if($(this).attr("url") == getPagePrehandle()+targetURL.file){
     targetVector[0] = basePanelIndex + 1;
     targetVector[1] = $(this).index() + 1;
    }
   });
  }
  else if(window.baseDir != "../" && targetURL.folders.length > 1){
   // von Level1:eq(0) nach Level0
   // ./rezepte/mittags.html -> ./index.html
   if(targetURL.folders[targetURL.folders.length - 1] == ".."){
    $(window.xmlStructure).find("content>menu>page").each(function(){
     if($(this).attr("url") == getPagePrehandle()+targetURL.file){
      targetVector[0] = $(this).index() + 1;
      if($(this).children("menu").length > 0){
       targetVector[1] = 0;
      }
     }
    });
   }
   // von Level1:eq(0) nach Level1:eq(x)
   // ./rezepte/mittags.html -> ./kontakt/impressum.html
   else if(targetURL.folders[targetURL.folders.length - 1] == ".."){
    $(window.xmlStructure).find("content>menu>page>menu").each(function(){
     if($(this).attr("url") == targetURL.folders[targetURL.folders.length - 1]){
      var tempIndex = $(this).parent().index();
      $(window.xmlStructure).find("content>menu>page:eq(" + tempIndex + ")>menu>page").each(function(){
       if($(this).attr("url") == getPagePrehandle()+targetURL.file){
        targetVector[0] = tempIndex + 1;
        targetVector[1] = $(this).index() + 1;
       }
      });
     }
    });
   }
  }
 }
 return targetVector;
}


function getRelativePath(objectHandle, objectAttr){
 var pathStatus = 1;
 var pathHandle = $(objectHandle).attr(objectAttr);

 // Browser Bugfix (IE 6/7; liefern nicht den eigentlichen sondern den berechneten Wert -> absolute URL)
 if(pathHandle.indexOf("://") > -1 || pathHandle.substr("0,1") == "/"){
  if(objectAttr == "src"){
   var altAttr = "altsrc";
  }
  else if(objectAttr == "href"){
   var altAttr = "althref";
  }
  if($(objectHandle).attr(altAttr) != undefined){
   pathHandle = $(objectHandle).attr(altAttr);
  }
  else{
   // konnte nicht konvertiert werden
   pathStatus = 2;
  }
 }
 return {"status": pathStatus, "url": pathHandle};
}



function ajustPath(content, loadedPanelVector){
 //Basis Level 0 (root)
 if(window.baseDir == ""){
  //Content is Level 0
  if(loadedPanelVector[1] == 0 || loadedPanelVector[1] == -1){
   // Alles bestens.
   // Seiten sind entweder Solo (-1) oder Parent (0) und
   // haben damit alle die selbe relative Basis wie
   // die Seite in die sie geladen werden.
  }
  //Content is Level 1
  else if(loadedPanelVector[1] > 0){
   // Ändern!
   // Seiten liegen in Unterseiten und sind damit
   // eine Ebene relative zur Seite, in die sie geladen
   // werden sollen, zu hoch
   //
   // src:
   
   $(content).find("div.col1_content img").each(function(){
    var imagePath = getRelativePath(this, "src");
    // ../images/datei.jpg -> images/datei.jpg
    if(imagePath.status == 1){
     $(this).attr("src", imagePath.url.substr(3));
    }
   });

   // href:
   $(content).find("div.col1_content a.internal-link, div.col1_content div.img_zoom_box a").each(function(){
    var linkPath = getRelativePath(this, "href");
    if(linkPath.status == 1){
     var linkObject = parseURL(linkPath.url);
     // datei.html -> unterordner1/datei.html
     if(linkObject.folders.length == 0){
      $(this).attr("href", $(window.xmlStructure).find("content>menu>page:eq(" + (loadedPanelVector[0] - 1) + ")>menu:eq(0)").attr("url") + "/" + linkPath.url);
     }
     else if(linkObject.folders.length == 1 || linkObject.folders.length == 2){
      if(linkObject.folders[0] == ".."){
       // ../datei.html -> datei.html
       // ../unterordner2/datei.html -> unterordner2/datei.html 
       $(this).attr("href", linkPath.url.substr(3));
      }
     }
    }
   });
  }
 }
 //Basis Level 1 (Unterverzeichnis)
 else{
  //Content is Level 0
  if(loadedPanelVector[1] == 0 || loadedPanelVector[1] == -1){
   // Ändern!
   // Seiten liegen im Hauptverzeichnis und sind damit
   // eine Ebene relative zur Seite, in die sie geladen
   // werden sollen, zu tief.
   //
   // src:
   
   $(content).find("div.content_sub_page img").each(function(){
   
    var imagePath = getRelativePath(this, "src");
    // images/datei.jpg -> ../images/datei.jpg
    if(imagePath.status == 1){
     $(this).attr("src", imagePath.url.replace("../../",""));
    }
   });
   
   // href:
   $(content).find("div.content_sub_page a.internal-link, div.content_sub_page div.img_zoom_box a, div.content_sub_page p.link_button a").each(function(){
    var linkPath = getRelativePath(this, "href");
    if(linkPath.status == 1){
     // datei.html -> ../datei.html
     // unterordner/datei.html -> ../unterordner/datei.html
     $(this).attr("href", linkPath.url);
    }
   }); 
      
  }
  //Content is Level 1
  else{
   // Alles bestens.
   // Seiten liegen in der selben Unterseiten-Ebene und
   // sind damit relative zur Seite, in die sie geladen
   // werden sollen.
  }
 }
 return content;
}

function getPageContent(targetVector, pageURL){
 //alert(targetVector + " | " + pageURL);
 if(targetVector[1] == -1 || targetVector[1] == 0){
  //Datei aus Hauptverzeichnis holen
  var xmlDir = (window.baseDir == "") ? "" : "./";
 }
 else{
  //Datei aus Unterverzeichnis holen
  //
  if(window.baseDir == ""){
   var xmlDir = $(window.xmlStructure).find("content>menu>page:eq(" + (targetVector[0] - 1) + ")>menu:eq(0)").attr("url") + "/"
  }
  else{
   if(targetVector[0] == window.lastVector){
    var xmlDir =  "";
   }
   else{
    var xmlDir = "./" + $(window.xmlStructure).find("content>menu>page:eq(" + (targetVector[0] - 1) + ")>menu:eq(0)").attr("url") + "/" 
   }
  }
 }
 
 //alert(pageURL);
 //pageURL = getPagePrehandle()+pageURL;
 //alert(xmlDir + pageURL.replace(/.html$/, ".xml"));
 $.ajax({
  type: "GET",
  url: xmlDir + pageURL.replace(/.html$/, ".xml"),
  dataType: "xml",
  error: function(XMLHttpRequest, textStatus, errorThrown){
   //alert("fehler!");
   //window.location.href = xmlDir + pageURL;
  },
  success: function(xml){
  	
  
   if($(xml).find("content").length == 1){
    
    newText = $(xml).find("content:eq(0)").text();
   
    newHTML = $(newText).html(newText);
   
   
    if($(newHTML).find("div.content_sub_page:eq(0) div.col3 ul.sub_navigation").length == 0){
     //mainPage
     
     newHTML = ajustPath(newHTML, targetVector);
	

     var domTarget = "div.panel-wrapper:eq(" + (targetVector[0] - 1) + ")";
     
     //alert(targetVector[0]);
     //alert($(domTarget).attr("url"));
     
     //alert($(domTarget).attr("url") + " " + pageURL);
     
     if($(domTarget).attr("url") == pageURL){
      
      $(domTarget).find("div.content_sub_page").remove();
      //if($.browser.mozilla) console.log($($(newHTML).find("div.content_sub_page")[0]).html());
      $(domTarget).append($(newHTML).find("div.content_sub_page").eq(0));//$(newHTML).find("div.content_sub_page:eq(0)"));
      setLinks(domTarget + " a.internal-link");
      setLinksTeam(domTarget + " a.team");
      setLinksJobs(domTarget + " a.jobs");
      setLinksPresse(domTarget + " a.presse");
      
      
	     //$(domTarget).find("a.img_box").fancybox({"showNavArrows":false});
	     
	     // <Hack> für Startseitenvideo
	  if(targetVector[0] == 1){
       	startSeite();
      }
      
      if(targetVector[0] == 2){
       	teamSlider();
      	setLinksTeam("a.team");
      }
      
      
      if(targetVector[0] == 5){
      	$("#contact_form").attr("action",$("#contact_form").attr("action").replace(".xml",".html"));
      }
      
      if(targetVector[0] == 3) {
    	infoGrid();
      }
      
      
	     // </hack>
     }

    }
    else{
   
     //subPage
     newHTML = ajustPath(newHTML, targetVector);

     var domTarget = "div.panel-wrapper:eq(" + (targetVector[0] - 1) + ") div.col1 div.col1_content:eq(" + (targetVector[1]) + ")";
     
     
     if($(domTarget).attr("url") == pageURL){
      $(domTarget).after($(newHTML).find("div.col1_content:eq(0)"));
      $(domTarget).remove();
      
      //Hack für H2-Überschrift in Sidebar
      var tempHeader = $(newHTML).find("div.col3 h2:eq(0)").text();
      $("div.panel-wrapper:eq(" + (targetVector[0] - 1) + ") div.col3 h2:eq(0)").empty();
      $("div.panel-wrapper:eq(" + (targetVector[0] - 1) + ") div.col3 h2:eq(0)").append(tempHeader);
      
      //Hack für div.backlink
      if($("div.panel-wrapper:eq(" + (targetVector[0] - 1) + ") div.col3 div.backlink:eq(0) a:eq(0)").text() == ""){
       var tempBacklink = $(newHTML).find("div.col3 div.backlink:eq(0) a:eq(0)").html();
       $("div.panel-wrapper:eq(" + (targetVector[0] - 1) + ") div.col3 div.backlink:eq(0) a:eq(0)").empty();
       $("div.panel-wrapper:eq(" + (targetVector[0] - 1) + ") div.col3 div.backlink:eq(0) a:eq(0)").append(tempBacklink);
      }
      
      $(newHTML).find("div.col3 div.backlink:eq(0)").text();
      
      
      setLinks(domTarget + " a.internal-link");
	     //$(domTarget).find("a.img_box").fancybox({"showNavArrows":false});
     }
    }
    
    sideScoller(targetVector);
   }
  }
  
 });
}


  function switchSubpage(targetVector, setMode){
   var linkTarget = "div.panel-wrapper:eq(" + (targetVector[0] - 1) + ") div.col3 ul.sub_navigation a";
   var backTarget = "div.panel-wrapper:eq(" + (targetVector[0] - 1) + ") div.col3 div.backlink:eq(0)";
   var pageTarget = "div.panel-wrapper:eq(" + (targetVector[0] - 1) + ") div.content_sub_page";
   if(targetVector[1] == 0){
    $(linkTarget).addClass("current");
    $(backTarget).hide();
   }
   else{
    $(linkTarget).removeClass("current");
    $(linkTarget + ":eq(" + (targetVector[1] - 1) + ")").addClass("current");
    $(backTarget).show();
   }
   $(pageTarget).find("div.col1_content").hide();
   $(pageTarget).find("div.col1_content:eq(" + (targetVector[1]) + ")").show();
   if(setMode == 1){
			 refreshPanelHeight();
			 //if($.browser.webkit){
     window.setTimeout(refreshPanelHeight, 100);
    //}
    window.lastVector = [targetVector[0], targetVector[1]];
   }
   setTitle(targetVector);
  }

// sideScolling
 var mapOpened = false;
 
 
function sideScoller(targetVector){
if(clickedTeamLink != "") {
    	$("#teamAllContainer").find("img").each(function() {
    		if($(this).attr("alt") == clickedTeamLink)
    			$(this).parent().trigger("click");
    	});
    	
    	clickedTeamLink = "";
    }
    
    if(clickedStartSeiteLink != "") {
    	$("#page-wrap").find("dt").each(function() {
    		//alert($(this).html().replace("é","").replace("á","").replace(":", "") + " " + clickedStartSeiteLink);
    		if($(this).html().replace("é","").replace("á","").replace(":", "") == clickedStartSeiteLink)
    			$(this).trigger("click");
    	});
    }
 
 if(targetVector[0] != window.lastVector[0]){
 	
 	//set gmap display:none/block
 	if($.browser.webkit){
	 	if(targetVector[0] == 5 ){
	 		gMapDisplayTimer = window.setTimeout(function(){
	 		 $("#map_canvas").css({display:"block"});
	 		}, 800);
	 	}
	 	else{
	 		$("#map_canvas").css({display:"none"});
	 	}
  }

		$("#navimain ul li").removeClass("current");
		if($("#navimain ul li").length >= targetVector[0]){
		 $("#navimain ul li:eq(" + (targetVector[0] - 1) + ")").addClass("current");
	 }
		
		if(targetVector[1] != -1){
		 switchSubpage(targetVector, 2);
		}
		offset = - (panelWidth*(targetVector[0] - 1));
		alterPanelHeight(targetVector[0] - 1);
		currentPanel = targetVector[0];
		//
		// Slide
		
		
	if(targetVector[0] == 6) {
      iComms();
    }
		
		
		
  $('.panel-container', slider).animate({"marginLeft": offset}, {"duration": settings.slideEaseDuration, "easing": settings.slideEaseFunction, "complete": function(){
    
    if(targetVector[0] != 6) {
    	var father = $("#icommsVideoInner").parent();
    	$("#icommsVideoInner").remove();
    	$(father).append('<div id="icommsVideoInner"></div>');
    }
   
   
  	if(targetVector[0] == 5 && mapOpened == false) {
  		googleMaps();
      }
   
   //if($.browser.webkit){
    refreshPanelHeight();
    //alert(targetVector[0]);
    
   //}

  	

   
  }});
  window.lastVector = [targetVector[0], targetVector[1]];
 }
 else if(targetVector[0] == window.lastVector[0] && targetVector[1] != window.lastVector[1]){
  switchSubpage(targetVector, 1);
 }

 callTracking(targetVector);
}
		
		function alterPanelHeight(x) {
			if (settings.autoHeight) {
				panelHeight = $('.panel:eq(' + x + ')', slider).height();
				slider.animate({ height: panelHeight }, settings.autoHeightEaseDuration, settings.autoHeightEaseFunction);
			};
		};
		function refreshPanelHeight() {
			x = currentPanel-1;
			if (settings.autoHeight) {
				panelHeight = $('.panel:eq(' + x + ')', slider).height();
				slider.css({ height: panelHeight });
			};
		};
	
	 ///////////////////
	 // INIT Progress //
	
		var slider = $(this);
				
		var panelWidth = slider.find(".panel").width();
		var panelCount = slider.find(".panel").size();
		var panelContainerWidth = panelWidth*panelCount;
		var navClicks = 0; // Used if autoSlideStopWhenClicked = true
		
		// Surround the collection of panel divs with a container div (wide enough for all panels to be lined up end-to-end)
		$('.panel', slider).wrapAll('<div class="panel-container"></div>');
		// Specify the width of the container div (wide enough for all panels to be lined up end-to-end)
		$(".panel-container", slider).css({ width: panelContainerWidth });
		
		// Specify the current panel.
		// If the loaded URL has a hash (cross-linking), we're going to use that hash to give the slider a specific starting position...
		if (settings.firstPanelToLoad != 1 && settings.firstPanelToLoad <= panelCount) { 
		 $("#navimain ul li").removeClass("current");
		 
		 
		 
		 if($("#navimain ul li").siblings().length >= settings.firstPanelToLoad){
    $("#navimain ul li:eq(" + (settings.firstPanelToLoad - 1) + ")").addClass("current");
   }
			var currentPanel = settings.firstPanelToLoad;
			var offset = - (panelWidth*(currentPanel - 1));
			$('.panel-container', slider).css({ marginLeft: offset });
		// Otherwise, we'll just set the current panel to 1...
		} else { 
			var currentPanel = 1;
		};
		
		window.lastVector = [currentPanel, -1];
	 var startUpPanel = -1;	

		
  $("div.main_2col").each(function(index) {
    if($(this).find("ul.sub_navigation").length > 0){
     var parentPanelIndex = $(this).parentsUntil("div.panel-container").eq($(this).parentsUntil("div.panel-container").length -1).index();
     
     if(parentPanelIndex + 1 == settings.firstPanelToLoad){
      startUpPanel = settings.firstSubPanelToOpen;
     }

     window.lastVector[1] = startUpPanel;
     $(this).find("div.col1_content").hide();
     $(this).find("div.col1_content:eq(" + (startUpPanel) + ")").show();
     if(startUpPanel != 0){
      $(this).find("ul.sub_navigation a:eq(" + (startUpPanel - 1) + ")").addClass("current");
     }
     else{
      $(this).find("ul.sub_navigation a").addClass("current");
     }
     
     $(this).find("ul.sub_navigation a").click(function(event){
      event.preventDefault();
      
      var targetVector = [$(this).parentsUntil("div.panel").parent().index() + 1, $(this).parent().index() + 1];
      domHandle = $(this).parentsUntil("div.content_sub_page");
      if(domHandle.find("div.col1_content:eq(" + (targetVector[1]) + ")>div.loading_box").length > 0){
       getPageContent(targetVector, domHandle.find("div.col1_content:eq(" + (targetVector[1])+ ")").attr("url"));
      }
      else{
       sideScoller(targetVector);
      }
			   return false;
     });
     
     // div.backlink a
     $(this).find("div.backlink a").click(function(event){
      event.preventDefault();
      var targetVector = [$(this).parentsUntil("div.panel").parent().index() + 1, 0];
      domHandle = $(this).parentsUntil("div.content_sub_page");
      if(domHandle.find("div.col1_content:eq(0)>div.loading_box").length > 0){
       getPageContent(targetVector, domHandle.find("div.col1_content:eq(0)").attr("url"));
      }
      else{
       sideScoller(targetVector);
      }
			   return false;
     });
     

    }
  });


		// Set the height of the first panel
		if (settings.autoHeight) {
			panelHeight = $('.panel:eq(' + (currentPanel - 1) + ')', slider).height();
			slider.css({ height: panelHeight });
		};	

  setLinks("#navimain a");
  //setLinks("#content_frame a.internal-link:not(.sub_navigation a)");
  setLinks("#footer ul a.internal-link");
  
  pageURL = getPagePrehandle()+parseURL(window.location.href).file;
  pageURL = (pageURL == getPagePrehandle()) ? getPagePrehandle()+standardStartpage : pageURL;
  //alert(pageURL);
  //alert(window.lastVector);
  //getPageContent(window.lastVector, pageURL);
  setTitle(window.lastVector);
  
  if(window.lastVector[0] == 7) {
    setLinksJobs("a.jobs");
  }
  
  if(window.lastVector[0] == 8) {
    setLinksPresse("a.presse");
  }
  
  if(window.lastVector[0] == 6) {
  	iComms();    
  }
  
  if(window.lastVector[0] == 5) {
		mapOpened == true;
  		googleMaps();
  }
  
  if(window.lastVector[0] == 3) {
  		infoGrid();
  }
  
  if(window.lastVector[0] == 2){
       	teamSlider();
      	setLinksTeam("a.team");
      }
  
  if(window.lastVector[0] == 1){
  			startSeite();
  }
	
	 // INIT Progress //
	 ///////////////////
		
		
		
	});
};

/*
 *jQuery browser plugin detection 1.0.3
 * http://plugins.jquery.com/project/jqplugin
 * Checks for plugins / mimetypes supported in the browser extending the jQuery.browser object
 * Copyright (c) 2008 Leonardo Rossetti motw.leo@gmail.com
 * MIT License: http://www.opensource.org/licenses/mit-license.php
   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.
*/
(function ($) {
	//checks if browser object exists
	if (typeof $.browser === "undefined" || !$.browser) {
		var browser = {};
		$.extend(browser);
	}
	var pluginList = {
		flash: {
			activex: ["ShockwaveFlash.ShockwaveFlash", "ShockwaveFlash.ShockwaveFlash.3", "ShockwaveFlash.ShockwaveFlash.4", "ShockwaveFlash.ShockwaveFlash.5", "ShockwaveFlash.ShockwaveFlash.6", "ShockwaveFlash.ShockwaveFlash.7"],
			plugin: /flash/gim
		}
	};
	var isSupported = function (p) {
		if (window.ActiveXObject) {
			$.browser[p] = false;
			
			for (i = 0; i < pluginList[p].activex.length; i++) {
				try {
					new ActiveXObject(pluginList[p].activex[i]);
					$.browser[p] = true;
				} catch (e) {}	
			}
		} else {
			$.each(navigator.plugins, function () {
				if (this.name.match(pluginList[p].plugin)) {
					$.browser[p] = true;
					return false;
				} else {
					$.browser[p] = false;
				}
			});
		}
	};
	
	$.each(pluginList, function (i, n) {
		isSupported(i);
	});
})(jQuery);

