﻿// Master.js

/* get images rotate */


/* Open popup window */

function openPopUpWnd(wndName)
{
    var w=600,h=590;
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    var win2;
    switch(wndName) {
        case 'rules_en':
            win2 = window.open('Rules.htm','Rules','toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, width='+w+', height='+h+', top='+top+', left='+left);
            break;
         case 'terms_en':
            win2 = window.open('Terms.htm','Terms','toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, width='+w+', height='+h+', top='+top+', left='+left);
            break;
         case 'policy_en':
            win2 = window.open('Policy.htm','Policy','toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, width='+w+', height='+h+', top='+top+', left='+left);
            break;
         case 'rules_fr':
            win2 = window.open('Rules_fr.htm','Rules','toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, width='+w+', height='+h+', top='+top+', left='+left);
            break;
         case 'terms_fr':
            win2 = window.open('Terms_fr.htm','Terms','toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, width='+w+', height='+h+', top='+top+', left='+left);
            break;
         case 'policy_fr':
            win2 = window.open('Policy_fr.htm','Policy','toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, width='+w+', height='+h+', top='+top+', left='+left);
            break;
    }
    
    if(win2!=null)
        win2.focus();
        
    return false;
    
}

//changes the Text Header and the Image in order for Picture Gallery can display the image fully
function changeImageLightBox(tagImage,tagLightBoxTitle,strImage,strLightBoxTitle,tagTitleBar,strStyleName)
{
	//gets the properties of the tags
	tagImage = getDocID(tagImage);
	tagLightBoxTitle = getDocID(tagLightBoxTitle);
	tagTitleBar = getDocID(tagTitleBar);
	
	//checks if there is a LightBox Title to Change
	if(tagLightBoxTitle != null)
		tagLightBoxTitle.innerHTML = strLightBoxTitle;
		
	//checks if there is a tagTarget on the page
	if(tagImage != null)
	{
		//sets the style to be the new iamge
		if(strImage != "")
		{			
			tagImage.src = strImage;
						
			//checks if the width is bigger then height
			/*if(tagImage.width > tagImage.height)
				tagImage.width = 325;
			else
				tagImage.height = 325;*/	
		}//end of if
	}//end of if
	
	//checks if there is a TItle Bar to move in order for the Image to be as big as it wants to be
	if(tagTitleBar != null)
	{
		var intTitleBarStyle = 0;
		
		//checks if the form is IE or the other broswers this is to see if it is need to grow th size to
		//fit the boarder and removes the px at the end of the area
		if (tagTitleBar.currentStyle)
			//IE
			intTitleBarStyle = parseInt(tagTitleBar.currentStyle[strStyleName].substring(0,tagTitleBar.currentStyle[strStyleName].length - 2));
		else
			//other broswers
			intTitleBarStyle = parseInt(document.defaultView.getComputedStyle(tagTitleBar,null).getPropertyValue(strStyleName).substring(0,document.defaultView.getComputedStyle(tagTitleBar,null).getPropertyValue(strStyleName).length - 2));

		//checks if it is need size needs to grow
		if(tagImage.width > intTitleBarStyle)
			tagTitleBar.style.width = (tagImage.width) + "px";
		else
			//removes the style
			tagTitleBar.style.width = '';
	}//end of if
}//end of changeImageLightBox()

//gets the document properties in order to use them as there are many types of browers with different versions
function getDocID(tagLayer)
{
	var tagProp = "";//holds the proerties of tagLayer

	//gets the whichLayer Properties depending of the differnt bowers the user is using
	if (document.getElementById)//this is the way the standards work
		tagProp = document.getElementById(tagLayer);
	else if (document.all)//this is the way old msie versions work
		tagProp = document.all[tagLayer];
	else if (document.layers)//this is the way nn4 works
		tagProp = document.layers[tagLayer];
		
	return tagProp;
}//end of getDocID()

//shoes and hides a <div> using display:block/none from the CSS
function toggleLayer(tagLayer,tagGrayOut,tagMedia)
{
	var tagStyle = '';//holds the style of tagLayer

	//gets the tagLayer and tagGrayOut Properties
	tagStyle = getDocID(tagLayer);
	tagGrayOut = getDocID(tagGrayOut);
	tagMedia = getDocID(tagMedia);
		
	if (tagStyle != null)
	{tagStyle.style.display = tagStyle.style.display? "":"block";}
	
	if (tagGrayOut != null)
	{
		tagGrayOut.style.display = tagGrayOut.style.display? "":"block";

		//for IE
		if (navigator.userAgent.indexOf('MSIE') != -1)
		{
			tagGrayOut.attachEvent('onclick',function () {
				toggleLayer(tagStyle.id,tagGrayOut.id)
				
				//specal case pleace remove when REUSING THIS FUNCTION 
				//infoDetailLayer('divShareFriendsBody','divShareMessage','','');
				
				//checks if there is any Media to stop also pleace remove when REUSING THIS FUNCTION 
				if (tagMedia != null)
					tagMedia.Stop();
			});
		}//end of if
		//for the other browsers
		else
		{
			tagGrayOut.addEventListener('click',function () {
				toggleLayer(tagStyle.id,tagGrayOut.id);
				
				//specal case pleace remove when REUSING THIS FUNCTION 
				//infoDetailLayer('divShareFriendsBody','divShareMessage','','');
			},false);
		}//end of else
	}//end of if
}//end of toggleLayer()

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

//starts up the page
function startUp()
{
	var oldonload=window.onload;//holds any prevs onload function from the js file

	//gets the onload window event checks if there is a function that is already in there
	window.onload=function(){
		if(typeof(oldonload)=='function')
			oldonload();
														
		  //finds which browser the user is using for Firefox it is the defult
		  //for IE 
		  if (navigator.userAgent.indexOf('MSIE') != -1)
		  {
			  if(navigator.appVersion.indexOf('MSIE 7') != -1)
			  {
			  }//end of if	  
		  }//end of if
		  //for Safari and Mac
		  else if (navigator.userAgent.indexOf('Safari') !=-1 || navigator.platform.indexOf("Mac") > -1)
		  {
			  //for Firefox for the Mac
			  if (navigator.userAgent.indexOf('Firefox') !=-1)
			  {
			  }//end of if else	
		  }//end of if else
		  //for Firefox
		  else if (navigator.userAgent.indexOf('Firefox') !=-1)
		  {
		  }//end of if else*/
		  
		  //for Opera
		  if (navigator.userAgent.indexOf('Opera') !=-1)
		  {
		  }//end of if else
		  
		  //for Chrome
		  if (navigator.userAgent.indexOf('Chrome') !=-1)
		  {
			  var tagMap = getDocID('divMap');//holds divtagMap
			  var tagTDMap = getDocID('tdMap');//holds tdMap
			  var tagTDFRMap = getDocID('tdMapFR');//holds tdMapFR

			  if(tagMap != null)
				 tagMap.style.height = '220px';
	
			  if(tagTDMap != null)
				 tagTDMap.style.height = '275px';
				  
 			  if(tagTDFRMap != null)
				 tagTDFRMap.style.height = '275px';
		  }//end of if else
	}//end of window.onload=function()
}//end of startUp()


/* JS Rotate Images */
    var num_imgs=0;
    var next_img = 1;
    var running=false;
    var timerID=0;
    var endTime;
 
 	var arrfade_img = new Array();
    var arr_img = new Array();
    var arr_img_alt = new Array();
 
    
    function getImagesXml(lang)
    {
    //alert(lang);
        if(!CreateWhXmlHttp()) {
            return;	
        }
        
        var reqUrl = '../ImagesHandler.ashx?lang=' + lang ;
   	
	    if(whXmlHttp)
	    {
		    whXmlHttp.onreadystatechange = handleWhResponse;
		    whXmlHttp.open("GET", reqUrl, true);
		    whXmlHttp.send(null);
	    }
    }
    
     function CreateWhXmlHttp()
    {
	    if(whXmlHttp) return false;
    	 
	    // IE	
	    try
	    {
		    whXmlHttp = new ActioveXObject("Msxml2.XMLHTTP");
	    }
	    catch(e)
	    {
		    try
		    {
			    whXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		    }
		    catch(os)
		    {
			    whXmlHttp = null;
		    }
	    }
	    // Mozilla and Safari	
	    if(!whXmlHttp && typeof XMLHttpRequest != "undefined")
	    {
		    whXmlHttp = new XMLHttpRequest();
	    }
    	
	    return true;
    }
    
    function handleWhResponse()
    {
	    if(whXmlHttp.readyState == 4)
	    {
		    if(whXmlHttp.status == 200)
		    {
			    LoadImageXml(whXmlHttp.responseXML);	
		    }
		    else
		    {
			    alert('error read data');
		    }
		    whXmlHttp = null;
	    }
    }
    
   
    function LoadImageXml(xDoc)
    { 
        try{
            if(xDoc != null) {
                //alert(xDoc);
            
                num_imgs = xDoc.documentElement.childNodes.length;
                var i;
                
                for(i = 0 ; i < num_imgs ; i++) {
                    arr_img[i] = xDoc.getElementsByTagName("ImageUrl")[i].childNodes[0].nodeValue;
					arrfade_img[i] = [xDoc.getElementsByTagName("ImageUrl")[i].childNodes[0].nodeValue,"","",trim(xDoc.getElementsByTagName("AlternateText")[i].childNodes[0].nodeValue)];
                    arr_img_alt[i] = trim(xDoc.getElementsByTagName("AlternateText")[i].childNodes[0].nodeValue).replace('<br />', '\n');
                }
				
				var mygallery=new fadeSlideShow({
					wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
					dimensions: [416, 317], //width/height of gallery in pixels. Should reflect dimensions of largest image
					imagearray: arrfade_img,
					displaymode: {type:'auto', pause:3500, cycles:0, wraparound:false},
					persist: false, //remember last viewed slide and recall within same session?
					fadeduration: 2000, //transition duration (milliseconds)
					descreveal: "none",
					togglerid: ""
				})
				
				//checks if it is IE and if so then turn on the image Rotate and turn off the fadeshow as there is 
				//some border around the image
				if(navigator.userAgent.indexOf('MSIE') != -1)
				{
					document.getElementById('imageRotate').style.display = "";
					document.getElementById('fadeshow1').style.display = "none";
                	document.getElementById('imageRotate').src = arr_img[0];
			    	document.getElementById('imageRotate').alt = arr_img_alt[0];
			    	document.getElementById('imageRotate').title = arr_img_alt[0];
			
			    	stopTimer();
				}//end of if
			}
        }
       catch(e){
            alert(e);
       }
    }
    
    function startTimer() {
		    running = true;
		    var now = new Date();
		    now = now.getTime();
		    // change last multiple for the number of seconds
		    endTime = now + (4000);
		    countDown();
	    }
	    
	    function countDown() {
		    var now = new Date();
		    now = now.getTime();
		    if (endTime - now <= 0) {
		        stopTimer();
		        rotateImage(next_img);
		    } else {
		        if (running) {
			    timerID = setTimeout("countDown()",2000);
		        }
		    }
	    }
	    
	    function stopTimer() {
		    clearTimeout(timerID);
		    running = false;
		    startTimer();
	    }

	    
	    function rotateImage(i_num){
	        if(num_imgs > 1){
		        document.getElementById('imageRotate').src = arr_img[i_num];
			    document.getElementById('imageRotate').alt = arr_img_alt[i_num];
			    document.getElementById('imageRotate').title = arr_img_alt[i_num];
			    
		        next_img = next_img + 1;
		        if(next_img >= num_imgs){
		            next_img = 0;
		        }
		    }
	    }
		
/*

	Ticker/Marquee

*/

/*
 * jScroller2 1.61 - Scroller Script
 *
 * Copyright (c) 2008 Markus Bordihn (markusbordihn.de)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2009-07-16 18:00:00 +0100 (Thu, 16 July 2009) $
 * $Rev: 1.61 $
 */
 
/*global window*/
/*jslint bitwise: true, browser: true, eqeqeq: true, immed: true, newcap: true, regexp: true, undef: true */

var ByRei_jScroller2 = {
 info: {
  Name: "ByRei jScroller2",
  Version: 1.61,
  Author: "Markus Bordihn (http://markusbordihn.de)",
  Description: "Next Generation Autoscroller"
 },

 config: {
  refreshtime: 150,
  regExp: {
   px: /([0-9,.\-]+)px/
  }
 },

 obj: [],
 /* 
   Object List Struction 
   ===============================================================================
   [0 / parent].height:[Number]        - Height of the Parent Container DIV
   [0 / parent].width:[Number]         - Width of the Parent Container DIV
   [1 / child].obj:[Object]            - Content DIV / Child DIV
   [1 / child].height:[Number]         - Height of Content DIV
   [1 / child].width:[Number]          - Width of Content DIV
   [2 / endless].obj:[Object]          - Second Content DIV for endless function
   [2 / endless].height:[Number]       - Height of second Content DIV
   [2 / endless].width:[Number]        - Width of second Content DIV
   [3 / option].direction:[Text]       - set the dirction (up,down,left,right)
   [3 / option].speed:[Number]         - set the speed of the scrolling
   [3 / option].pause:[Boolean]        - pause the scroller so it will not start
   [3 / option].delay:[Number]         - delay the startet of the scroller in sec.
   [3 / option].alternate:[Boolean]    - alternate scrolling
   [3 / option].dynamic:[Boolean]      - dynamic checking on every request
   ===============================================================================
  */

 cache: {
  active: false,
  prefix: 'jscroller2' + '_',
  delayer: 0,
  ileave: 0,
  ie: window.detachEvent ? true : false,
  last : {
   element : false
  }
 },

 get: {
  /* Check an Array for certain values and return the result */
  value: function (obj,value,ncs) {
   var
    i,
    result='',
    il = obj.length;
   if (obj && value) {
       for (i=0;i<il;i++) {
            if (ncs && obj[i].indexOf(value) >= 0) {
                result=obj[i].split(value)[1];
                break;
            } else if (obj[i] === value) {
                result=obj[i];
                break;
            }
       }
   }
   return result;
  },
  /* Get px value */
  px: function(obj) {
   var result = "";
   if (obj) {
       if (obj.match(ByRei_jScroller2.config.regExp.px)) {
           if (typeof obj.match(ByRei_jScroller2.config.regExp.px)[1] !== 'undefined') {
               result = obj.match(ByRei_jScroller2.config.regExp.px)[1];
           }
       }
   }
   return parseFloat(result);
  },
  /* Complexe Ckecking for Endless DIV return and set position */
  endless: function(mode, direction, value, obj, child, parent, endless, speed, alternate) {
   var result;

   switch (mode) {
    case 'down': case 'right':
     result = ByRei_jScroller2.get.px(obj.style[direction]) + speed;
     if (value > 0 && value <= parent) {
         ByRei_jScroller2.set[direction](obj, value - endless);
     }
     if (result + endless >= parent && result <= parent + speed) {
         ByRei_jScroller2.set[direction](obj, result);
         value = result + child * -1;
     }
    return value;
    case 'up': case 'left':
     result = ByRei_jScroller2.get.px(obj.style[direction]) - speed;
     if (value + child <= parent) {
         ByRei_jScroller2.set[direction](obj, value + child);
     }
     if (result + endless <= parent && result + endless + speed >= 0) {
         ByRei_jScroller2.set[direction](obj, result);
         value = result + endless;
     }
    return value;
   }
  }
 },

 /* 
  This include all on(action) Methodes 
 */
 on: {
  /* Set Event Handler when no action is required */
  blur: function() {
   if (ByRei_jScroller2.cache.last.element && ByRei_jScroller2.cache.last.element !== document.activeElement) {
       ByRei_jScroller2.cache.last.element = document.activeElement;
   } else {
       ByRei_jScroller2.stop();
   }
  },
  /* Set Event Handler when action is required */
  focus: function() {
   ByRei_jScroller2.start();
  },
  /* Set Event Handler for delayed starts */
  delay: function (delay) {
   if (delay > 0) {
       for (var i=0;i<ByRei_jScroller2.obj.length;i++) {
            if (delay === ByRei_jScroller2.obj[i][3].delay) {
                ByRei_jScroller2.obj[i][3].pause = ByRei_jScroller2.obj[i][3].delay = 0;
            }
       }
   }
  },
  /* Set Event Handler for Object Mouse Over */
  over: function(evt) {
   if (evt) {
       ByRei_jScroller2.start_stop(evt,1);
   }
  },
  /* Set Event Handler for Object Mouse Out */
  out: function(evt) {
   if (evt) {
       ByRei_jScroller2.start_stop(evt,0);
   }
  }  
 },

  /* 
  All set Functions
 */
 set: {
  /* Simple Warper to avoid to include "px" on every value */
  left: function(obj,value) {
   ByRei_jScroller2._style(obj,'left',value + "px");
  },
  top: function(obj,value) {
   ByRei_jScroller2._style(obj,'top',value + "px");
  },
  width: function(obj,value) {
   ByRei_jScroller2._style(obj,'width',value + "px");
  },
  height: function(obj,value) {
   ByRei_jScroller2._style(obj,'height',value + "px");
  }
 },

  /*
  This include all init functions 
 */
 init: {
  /* Init Events for all div with dynDiv_ as className */
  main: function() {
   var 
    div_list = document.getElementsByTagName('div'),
    il = div_list.length,
    i;

   /* Check if some Object have a direction */
   for (i=0;i<il;i++) {
    var 
     classNames = div_list[i].className.split(' '),
     direction = null;

    if (ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'down')) {direction = 'down';}
    else if (ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'up')) {direction = 'up';}
    else if (ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'left')) {direction = 'left';}
    else if (ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'right')) {direction = 'right';}

    if (direction) {
        ByRei_jScroller2.add(div_list[i],direction);
    }
   }
   if (!ByRei_jScroller2.active) {
       if (ByRei_jScroller2.obj.length > 0) {
           ByRei_jScroller2.start();
           if (ByRei_jScroller2.cache.delayer) {
               for (i=0;i<ByRei_jScroller2.obj.length;i++) {
                 if (ByRei_jScroller2.obj[i][3].delay > 0) {
                     window.setTimeout("ByRei_jScroller2.on.delay(" + ByRei_jScroller2.obj[i][3].delay + ",0)", ByRei_jScroller2.obj[i][3].delay);
                 }
               } 
           }
           if (ByRei_jScroller2.cache.ileave === 0) {
               if (ByRei_jScroller2.cache.ie) {
                   ByRei_jScroller2.cache.last.element = document.activeElement;
                   ByRei_jScroller2.set_eventListener(document, 'focusout',  ByRei_jScroller2.on.blur);
               } else {
                   ByRei_jScroller2.set_eventListener(window, 'blur',  ByRei_jScroller2.on.blur);
               }
               ByRei_jScroller2.set_eventListener(window, 'focus', ByRei_jScroller2.on.focus);
               ByRei_jScroller2.set_eventListener(window, 'resize', ByRei_jScroller2.on.focus);
               ByRei_jScroller2.set_eventListener(window, 'scroll', ByRei_jScroller2.on.focus);
           }
       }
   }
  }
 },

 /* Add needed DIVs to the obj List after some checks */
 add: function(obj, direction) {
  var
   i,
   il = ByRei_jScroller2.obj.length,
   error = false;

  /* Check for duplication, when Object is existing the direction will be replace nothing more to do... */
  if (obj && direction) {  
      if (il > 0) {
          for (i=0;i<il;i++) {
           if (ByRei_jScroller2.obj[i][1].obj === obj) {
               ByRei_jScroller2.obj[i][3].direction = direction;
               error=true;
           }
         }
      }
  } else {
    error=true;
  }
  if (!error) {
     var
      delay = 0, 
      speed = 1,
      pause = 0,
      alternate,
      dynamic,
      classNames = obj.className.split(' '),
      parent = obj.parentNode,
      endless = {
       obj : null,
       width : null,
       height : null
      };

     if (parent.className.indexOf('jscroller2') >= 0) {
         parent = parent.parentNode;
     }

     if (parent) {
         ByRei_jScroller2._style(parent,'position','relative');
         ByRei_jScroller2._style(parent,'overflow','hidden');

         var childs = parent.getElementsByTagName('div');
         for (i=0;i<childs.length;i++) {
              if (ByRei_jScroller2.get.value(childs[i].className.split(' '), ByRei_jScroller2.cache.prefix + direction +'_endless')) {
                  endless.obj = childs[i];
              }
         }

        if(obj) { 
           ByRei_jScroller2._style(obj,'position','absolute');
           ByRei_jScroller2.set.top(obj,0);
           ByRei_jScroller2.set.left(obj,0);

           switch(direction) {
            case "down":  
             ByRei_jScroller2.set.top(obj,(obj.clientHeight * -1) +  parent.clientHeight);
            break;  
            case "right":
             ByRei_jScroller2.set.left(obj,(obj.clientWidth * -1) +  parent.clientWidth);
            break;
           }

           switch(direction) {
            case "down":  case "up": 
             ByRei_jScroller2.set.width(obj, parent.clientWidth);
            break;
            case "right": case "left":
             ByRei_jScroller2.set.height(obj, parent.clientHeight);
            break;
           }

           if(endless.obj) {
              ByRei_jScroller2._style(endless.obj,'position','absolute');
              endless.width = endless.obj.clientWidth;
              endless.height = endless.obj.clientHeight;

              switch(direction) {
               case "down":
                ByRei_jScroller2.set.top(endless.obj, endless.height * -1);
               break;
               case "up": 
                ByRei_jScroller2.set.top(endless.obj, obj.clientHeight);
               break;
               case "left": 
                ByRei_jScroller2.set.left(endless.obj, obj.clientWidth);
               break;
               case "right":
                ByRei_jScroller2.set.left(endless.obj, obj.clientWidth* -1);
               break;
              }

              switch(direction) {
               case "down": case "up":
                ByRei_jScroller2.set.left(endless.obj, 0);
                ByRei_jScroller2.set.width(endless.obj, parent.clientWidth);
               break;
               case "left": case "right":
                ByRei_jScroller2.set.top(endless.obj, 0);
                ByRei_jScroller2.set.height(endless.obj, parent.clientHeight);
               break;
              }
           }
        }

        /* Speed Parameter */
        if (ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'speed-',1)) {
            speed = parseFloat(ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'speed-',1)||10)/10;
            if (ByRei_jScroller2.cache.ie && speed < 1) {speed = 1;}
        }

        /* Ignore Leave */
        ByRei_jScroller2.cache.ileave = (ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'ignoreleave') || ByRei_jScroller2.cache.ileave === 1) ? 1 : 0;

        /* Alternate */
        alternate = ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'alternate') ? 1 : 0;

        /* Dynamic */
        dynamic = ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'dynamic') ? 1 : 0;

        /* Scroller Delay Start */
        if (ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'delay-',1)) {
            ByRei_jScroller2.cache.delayer = pause = 1;
            delay = ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'delay-',1) * 1000;
        }

        /* Stop & Start on MouseOver */
        if (ByRei_jScroller2.get.value(classNames, ByRei_jScroller2.cache.prefix + 'mousemove')) {
            ByRei_jScroller2.set_eventListener(obj, 'mouseover', ByRei_jScroller2.on.over);
            ByRei_jScroller2.set_eventListener(obj, 'mouseout', ByRei_jScroller2.on.out);
            if (endless.obj) {
                ByRei_jScroller2.set_eventListener(endless.obj, 'mouseover', ByRei_jScroller2.on.over);
                ByRei_jScroller2.set_eventListener(endless.obj, 'mouseout', ByRei_jScroller2.on.out);
            }
        }
        ByRei_jScroller2.obj.push([
         {height: parent.clientHeight, width: parent.clientWidth},                                                // Parent  [0]
         {obj: obj, height: obj.clientHeight, width: obj.clientWidth},                                            // Child   [1]
         {obj: endless.obj, height: endless.height, width: endless.width},                                        // Endless [2]
         {direction: direction, speed: speed, pause: pause, delay: delay, alternate: alternate, dynamic: dynamic} // Options [3]
        ]);
     }
   }
 },

 /* Remove jScroller2 Object from the List complett */
 remove: function(obj) {
  if (obj) {
     for (var i=0;i<ByRei_jScroller2.obj.length;i++) {
         if (ByRei_jScroller2.obj[i][1].obj === obj) {
             ByRei_jScroller2.obj.splice(i, 1);
         }
     }
     if (ByRei_jScroller2.obj.length <= 0) {
         ByRei_jScroller2.stop();
     }
  }
 },

 /* Main Part - Scroller Events which will execute for a special Internval */
 scroller: function() {
  var
   i,
   il = ByRei_jScroller2.obj.length;

  for (i=0;i<il;i++) {
    var
     parent  = ByRei_jScroller2.obj[i][0],
     child   = ByRei_jScroller2.obj[i][1],
     endless = ByRei_jScroller2.obj[i][2],
     option  = ByRei_jScroller2.obj[i][3];

    if (!option.pause && !option.delay) {

      // check size and change the size, important for option.dynamic Objects...
       if (option.dynamic) {
           child.height = ByRei_jScroller2.obj[i][1].height = child.obj.clientHeight;
           child.width = ByRei_jScroller2.obj[i][1].width = child.obj.clientWidth;

           if (endless.obj) {
               endless.height = ByRei_jScroller2.obj[i][2].height = endless.obj.clientHeight;
               endless.width = ByRei_jScroller2.obj[i][2].width = endless.obj.clientWidth;
           }
       }

       switch(option.direction) {
             /* Calculations for option.direction "down" and "up" */
             case 'down': case 'up':
                var new_top = ByRei_jScroller2.get.px(child.obj.style.top);
                    new_top = (option.alternate === 2) ? ((option.direction === 'down') ? new_top - option.speed : new_top + option.speed) : ((option.direction === 'down') ? new_top + option.speed : new_top - option.speed);

                if(endless.obj && !option.alternate) {
                   new_top = ByRei_jScroller2.get.endless(option.direction, 'top', new_top, endless.obj, child.height, parent.height, endless.height, option.speed, option.alternate);
                }
                else {
                   if (option.alternate) {
                        if (option.alternate === ((option.direction === 'down') ? 1 : 2) && ((child.height > parent.height && new_top + option.speed > 0) || (child.height < parent.height && new_top + child.height + option.speed > parent.height))) {ByRei_jScroller2.obj[i][3].alternate = ((option.direction === 'down') ? 2 : 1);}
                        if (option.alternate === ((option.direction === 'down') ? 2 : 1) && ((child.height > parent.height && new_top + child.height < parent.height + option.speed) || (child.height < parent.height && new_top < 0))) {ByRei_jScroller2.obj[i][3].alternate = ((option.direction === 'down') ? 1 : 2);}
                   } else {
                       if (option.direction === 'down') {
                           if (new_top > parent.width) {new_top = (child.height) * -1;}
                       } else {
                           if (new_top < child.height * -1) {new_top = parent.height;}
                       }
                   }
                }
                ByRei_jScroller2.set.top(child.obj, new_top);
             break;
             /* Calculations for option.direction "left" and "right" */
             case 'left': case 'right':
              var new_left = ByRei_jScroller2.get.px(child.obj.style.left);
                  new_left = (option.alternate === 2) ? ((option.direction === 'left') ? new_left + option.speed : new_left - option.speed) : (option.direction === 'left') ? new_left - option.speed : new_left + option.speed;

              if(endless.obj && !option.alternate) {
                 new_left = ByRei_jScroller2.get.endless(option.direction, 'left', new_left, endless.obj, child.width, parent.width, endless.width, option.speed, option.alternate);
              } else {
                 if (option.alternate) {
                    if (option.alternate === ((option.direction === 'left') ? 2 : 1) && ((child.width > parent.width && new_left + option.speed > 0) || (child.width < parent.width && new_left + child.width + option.speed > parent.width))) {ByRei_jScroller2.obj[i][3].alternate = ((option.direction === 'left') ? 1 : 2);}
                    if (option.alternate === ((option.direction === 'left') ? 1 : 2) && ((child.width > parent.width && new_left + child.width < parent.width + option.speed) || (child.width < parent.width && new_left - option.speed < 0))) {ByRei_jScroller2.obj[i][3].alternate = ((option.direction === 'left') ? 2 : 1);}
                 } else {
                    if (option.direction === 'left') {
                        if (new_left < child.width * -1) {new_left = parent.width;}
                    } else {
                        if (new_left > parent.width) {new_left = (child.width) * -1;}
                    }
                 }
              }
              ByRei_jScroller2.set.left(child.obj, new_left);
             break;
       }
   }
  }
 },


 /* Start or Stop a specific Scroller */
 start_stop: function (evt,mode){
  if (evt.target || evt.srcElement) {
   var evt_src = evt.target ? evt.target : evt.srcElement;
   for (var i=0;i<5;i++) {
    if (evt_src.className.indexOf( ByRei_jScroller2.cache.prefix + 'mousemove') < 0 && evt_src.className.indexOf('_endless') < 0) {
        evt_src = evt_src.parentNode;
       } else {
        break;
       }
   }
   ByRei_jScroller2.pause(evt_src,mode);
  }
 },

 /* Start all Scrollers */
 start: function() {
  if (!ByRei_jScroller2.timer) {
      ByRei_jScroller2.active = ByRei_jScroller2.timer = window.setInterval(ByRei_jScroller2.scroller, ByRei_jScroller2.config.refreshtime);
  }
 },

 /* Stop all Scrollers */
 stop: function() {
  if (ByRei_jScroller2.timer) {
      window.clearInterval(ByRei_jScroller2.timer);
      ByRei_jScroller2.active = ByRei_jScroller2.timer = false;
  }
 },
 
 /* Pause a specific Scroller */
 pause: function (obj, value) {
  if (obj && value >= 0) {
      for (var i=0;i<ByRei_jScroller2.obj.length;i++) {
           if (obj === ByRei_jScroller2.obj[i][1].obj || obj === ByRei_jScroller2.obj[i][2].obj) {
               ByRei_jScroller2.obj[i][3].pause = value;
           }
      }
  }
 },

 /* Small alternative Style Selector to avoid JS Errors and make things easier */
 _style: function(obj,o_style,value) {
  if (obj && o_style) {
     if (obj.style) {
         if (typeof obj.style[o_style] !== 'undefined') {
            if (value) {
                try {return (obj.style[o_style] = value);} catch(e) {return false;}
            } else {
                return (obj.style[o_style] === '') ? ((obj.currentStyle) ? obj.currentStyle[o_style] : ((window.getComputedStyle) ? window.getComputedStyle(obj,'').getPropertyValue(o_style) : false)) : obj.style[o_style];
            }
         }
     }
  }
 },

 /* Set Standart Event Listener */
 set_eventListener: function(obj,evt,func) {
  if (obj && evt && func) {
   if (ByRei_jScroller2.cache.ie) {obj.attachEvent("on"+evt, func);} else {obj.addEventListener(evt, func, false);}
  }
 }

};

/* Init the hole jScroller2 after the Document was loaded complet */
ByRei_jScroller2.set_eventListener(window, 'load', ByRei_jScroller2.init.main);

/**
* author Remy Sharp
* url http://remysharp.com/tag/marquee
*/

(function ($) {
    $.fn.marquee = function (klass) {
        var newMarquee = [],
            last = this.length;

        // works out the left or right hand reset position, based on scroll
        // behavior, current direction and new direction
        function getReset(newDir, marqueeRedux, marqueeState) {
            var behavior = marqueeState.behavior, width = marqueeState.width, dir = marqueeState.dir;
            var r = 0;
            if (behavior == 'alternate') {
                r = newDir == 1 ? marqueeRedux[marqueeState.widthAxis] - (width*2) : width;
            } else if (behavior == 'slide') {
                if (newDir == -1) {
                    r = dir == -1 ? marqueeRedux[marqueeState.widthAxis] : width;
                } else {
                    r = dir == -1 ? marqueeRedux[marqueeState.widthAxis] - (width*2) : 0;
                }
            } else {
                r = newDir == -1 ? marqueeRedux[marqueeState.widthAxis] : 0;
            }
            return r;
        }

        // single "thread" animation
        function animateMarquee() {
            var i = newMarquee.length,
                marqueeRedux = null,
                $marqueeRedux = null,
                marqueeState = {},
                newMarqueeList = [],
                hitedge = false;
                
            while (i--) {
                marqueeRedux = newMarquee[i];
                $marqueeRedux = $(marqueeRedux);
                marqueeState = $marqueeRedux.data('marqueeState');
                
                if ($marqueeRedux.data('paused') !== true) {
                    // TODO read scrollamount, dir, behavior, loops and last from data
                    marqueeRedux[marqueeState.axis] += (marqueeState.scrollamount * marqueeState.dir);

                    // only true if it's hit the end
                    hitedge = marqueeState.dir == -1 ? marqueeRedux[marqueeState.axis] <= getReset(marqueeState.dir * -1, marqueeRedux, marqueeState) : marqueeRedux[marqueeState.axis] >= getReset(marqueeState.dir * -1, marqueeRedux, marqueeState);
                    
                    if ((marqueeState.behavior == 'scroll' && marqueeState.last == marqueeRedux[marqueeState.axis]) || (marqueeState.behavior == 'alternate' && hitedge && marqueeState.last != -1) || (marqueeState.behavior == 'slide' && hitedge && marqueeState.last != -1)) {                        
                        if (marqueeState.behavior == 'alternate') {
                            marqueeState.dir *= -1; // flip
                        }
                        marqueeState.last = -1;

                        $marqueeRedux.trigger('stop');

                        marqueeState.loops--;
                        if (marqueeState.loops === 0) {
                            if (marqueeState.behavior != 'slide') {
                                marqueeRedux[marqueeState.axis] = getReset(marqueeState.dir, marqueeRedux, marqueeState);
                            } else {
                                // corrects the position
                                marqueeRedux[marqueeState.axis] = getReset(marqueeState.dir * -1, marqueeRedux, marqueeState);
                            }

                            $marqueeRedux.trigger('end');
                        } else {
                            // keep this marquee going
                            newMarqueeList.push(marqueeRedux);
                            $marqueeRedux.trigger('start');
                            marqueeRedux[marqueeState.axis] = getReset(marqueeState.dir, marqueeRedux, marqueeState);
                        }
                    } else {
                        newMarqueeList.push(marqueeRedux);
                    }
                    marqueeState.last = marqueeRedux[marqueeState.axis];

                    // store updated state only if we ran an animation
                    $marqueeRedux.data('marqueeState', marqueeState);
                } else {
                    // even though it's paused, keep it in the list
                    newMarqueeList.push(marqueeRedux);                    
                }
            }

            newMarquee = newMarqueeList;
            
            if (newMarquee.length) {
                setTimeout(animateMarquee, 25);
            }            
        }
        
        // TODO consider whether using .html() in the wrapping process could lead to loosing predefined events...
        this.each(function (i) {
            var $marquee = $(this),
                width = $marquee.attr('width') || $marquee.width(),
                height = $marquee.attr('height') || $marquee.height(),
                $marqueeRedux = $marquee.after('<div ' + (klass ? 'class="' + klass + '" ' : '') + 'style="display: block-inline; width: ' + width + 'px; height: ' + height + 'px; overflow: hidden;"><div style="float: left; white-space: nowrap;">' + $marquee.html() + '</div></div>').next(),
                marqueeRedux = $marqueeRedux.get(0),
                hitedge = 0,
                direction = ($marquee.attr('direction') || 'left').toLowerCase(),
                marqueeState = {
                    dir : /down|right/.test(direction) ? -1 : 1,
                    axis : /left|right/.test(direction) ? 'scrollLeft' : 'scrollTop',
                    widthAxis : /left|right/.test(direction) ? 'scrollWidth' : 'scrollHeight',
                    last : -1,
                    loops : $marquee.attr('loop') || -1,
                    scrollamount : $marquee.attr('scrollamount') || this.scrollAmount || 2,
                    behavior : ($marquee.attr('behavior') || 'scroll').toLowerCase(),
                    width : /left|right/.test(direction) ? width : height
                };
            
            // corrects a bug in Firefox - the default loops for slide is -1
            if ($marquee.attr('loop') == -1 && marqueeState.behavior == 'slide') {
                marqueeState.loops = 1;
            }

            $marquee.remove();
            
            // add padding
            if (/left|right/.test(direction)) {
                $marqueeRedux.find('> div').css('padding', '0 ' + width + 'px');
            } else {
                $marqueeRedux.find('> div').css('padding', height + 'px 0');
            }
            
            // events
            $marqueeRedux.bind('stop', function () {
                $marqueeRedux.data('paused', true);
            }).bind('pause', function () {
                $marqueeRedux.data('paused', true);
            }).bind('start', function () {
                $marqueeRedux.data('paused', false);
            }).bind('unpause', function () {
                $marqueeRedux.data('paused', false);
            }).data('marqueeState', marqueeState); // finally: store the state
            
            // todo - rerender event allowing us to do an ajax hit and redraw the marquee

            newMarquee.push(marqueeRedux);

            marqueeRedux[marqueeState.axis] = getReset(marqueeState.dir, marqueeRedux, marqueeState);
            $marqueeRedux.trigger('start');
            
            // on the very last marquee, trigger the animation
            if (i+1 == last) {
                animateMarquee();
            }
        });            

        return $(newMarquee);
    };
}(jQuery));

