
function showSwbVideo(bankerId,titleOfBanker, options){
	var defalutOptions = {domain:"http://video.switzerbank.com/",
			   closeImageSrc: 'http://video.switzerbank.com/Services/icons/close.gif',
			   font:"bold 12px Arial, Helvetica, sans-serif",
			   bgColor:"#dddbcd",
			   fgColor:"#000000",
			   positionTop:"50",
			   positionLeft:"50"};
	options = options || defalutOptions;
    var domain = options.domain ||defalutOptions.domain;
    var font =options.font||defalutOptions.font;
    var bgColor = options.bgColor||defalutOptions.bgColor;
    var fgColor = options.fgColor||defalutOptions.fgColor;
    var closeImageSrc = options.closeImageSrc||defalutOptions.closeImageSrc;
    var positionTop = (options.positionTop||defalutOptions.positionTop) + "px";
    var positionLeft= (options.positionLeft ||defalutOptions.positionLeft) + "px";
    titleOfBanker = (titleOfBanker)?titleOfBanker:"Video"
    if (!bankerId) {
        alert('correct banker Id has to be provided to access video page')
    }
    

    var aIframeDiv = HTML.DIV();
    aIframeDiv.innerHTML =  '<iframe src="' + domain +'Services/video.aspx?bankerId='+ bankerId 
                        + '" id="VideoFrame" scrolling=no height="460px" noresize=noresize width="910px"' 
                        + 'style="background-color:'+bgColor
                        +'; border:0px;" name="testiframe"></iframe>';
 	var aparent = window.document.body;
	var div1Style = "border:2px solid " + bgColor +"; width:910px; height:480px;top:" + positionTop + "; left:"+positionLeft+"; position:absolute;"
	var div2Style = "height:20px; width:910px; background-color:" + bgColor +";";
	var div3Style = "float:left;padding-left:10px; height:20px; width:860px; color:" + fgColor+ ";font:" + font + ";";
	var videoDiv = HTML.DIV({'style':div1Style, id:'PopUpVideoContainer'}, 
	                   HTML.DIV({'style':div2Style},
	                       HTML.DIV({'style':div3Style}, titleOfBanker),
	                       HTML.DIV({'style':"float:right;padding-right:10px; height:20px; width:10px"}, 
	                           HTML.A({'href':'#', 'onclick':'closePopupVideo();return false;'}, 
	                               HTML.IMG({'src':closeImageSrc, 'style':'border:0px'})
	                           )
	                       )
	                   ),
	                 aIframeDiv
	                );
	                
    aparent.appendChild(videoDiv);
}

function closePopupVideo(){
    var popupElement = document.getElementById('PopUpVideoContainer');
    popupElement.parentNode.removeChild(popupElement);
    return false;
}


/*
Copyright (c) 2006 Dan Webb

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial 
portions of the Software.
*/
DomBuilder = {
  IE_TRANSLATIONS : {
    'class' : 'className',
    'for' : 'htmlFor'
  },
  ieAttrSet : function(a, i, el) {
    var trans;
    if (trans = this.IE_TRANSLATIONS[i]) el[trans] = a[i];
    else if (i == 'style') el.style.cssText = a[i];
    else if (i.match(/^on/)) el[i] = new Function(a[i]);
    else el.setAttribute(i, a[i]);
  },
	apply : function(o) { 
	  o = o || {};
		var els = ("p|div|span|strong|em|img|table|tr|td|th|thead|tbody|tfoot|pre|code|" + 
					   "h1|h2|h3|h4|h5|h6|ul|ol|li|form|input|textarea|legend|fieldset|" + 
					   "select|option|blockquote|cite|br|hr|dd|dl|dt|address|a|button|abbr|acronym|" +
					   "script|link|style|bdo|ins|del|object|param|col|colgroup|optgroup|caption|" + 
					   "label|dfn|kbd|samp|var").split("|");
    var el, i=0;
		while (el = els[i++]) o[el.toUpperCase()] = DomBuilder.tagFunc(el);
		return o;
	},
	tagFunc : function(tag) {
	  return function() {
	    var a = arguments, at, ch; a.slice = [].slice; if (a.length>0) { 
	    if (a[0].nodeName || typeof a[0] == "string") ch = a; 
	    else { at = a[0]; ch = a.slice(1); } }
	    return DomBuilder.elem(tag, at, ch);
	  }
  },
	elem : function(e, a, c) {
		a = a || {}; c = c || [];
		var isIE = navigator.userAgent.match(/MSIE/)
		var el = document.createElement((isIE && a.name)?"<" + e + " name=" + a.name + ">":e);
		for (var i in a) {
		  if (typeof a[i] != 'function') {
		    if (isIE) this.ieAttrSet(a, i, el);
		    else el.setAttribute(i, a[i]);
		  }
	  }
		for (var i=0; i<c.length; i++) {
			if (typeof c[i] == 'string') c[i] = document.createTextNode(c[i]);
			el.appendChild(c[i]);
		} 
		return el;
	}
}
var HTML = DomBuilder.apply(); 

/*--------------End of DOM builder----------*/


/*
 * Following code is used for the video teaser in SWB production site pre release phase
 * 
 * */

	var bankerInfos =  [{bankerId:1001,fullName:"Raoul Hinder - www.portfolio-consulting.com",lastName:"Hinder",firstName:"Raoul"},
	 			{bankerId:1002,fullName:"Remo Thalmann - www.thalmann-verling.com",lastName:"Thalmann",firstName:"Remo"},
	 			{bankerId:1003,fullName:"Tina Ormuz - www.thalmann-verling.com",lastName:"Ormuz",firstName:"Tina"},
	 			{bankerId:1004,fullName:"Beat Lehmann - www.thalmann-verling.com",lastName:"Lehmann",firstName:"Beat"},
	 			{bankerId:1005,fullName:"Guido A. Frigerio - frigerio@gafinv.ch",lastName:"Frigerio",firstName:"Guido A."},
	 			{bankerId:1006,fullName:"Paul Vogler - www.swiss-value.ch",lastName:"Vogler",firstName:"Paul"},
	 			{bankerId:1007,fullName:"Annemarie Verling - www.thalmann-verling.com",lastName:"Verling",firstName:"Annemarie"},
	 			{bankerId:1008,fullName:"Andrea Tschirky - www.thalmann-verling.com",lastName:"Tschirky",firstName:"Andrea"}];
var videoTeaser = {
	autoChangeImage:true,
	imgArray: [], 
	swbCurrentIndex:0,
	 buildTeaserImages: function(domainName){
	 	domainName = (domainName)?domainName:"test.switzerbank.com";
	 	var imageURLprefix = "http://" + domainName + "/Services/images/video_";
		for(var i =0; i<bankerInfos.length; i++){
				 	 videoTeaser.imgArray[i] =HTML.A({'class':bankerInfos[i].bankerId, 'title':'Video of ' + bankerInfos[i].fullName, 'onclick':'videoTeaser.loadVideo(this);return false;'},
				 						 HTML.IMG({
				 							'src': imageURLprefix +  bankerInfos[i].bankerId + ".jpg",
				 							'title':'Video of ' +  bankerInfos[i].fullName,
				 							'alt':'Video of ' +  bankerInfos[i].fullName,
				 							'style':'border:0px;'
				 						}));
		 }
	 },
	 
	 changeVideo:function(domainName){
	 		if(videoTeaser.swbCurrentIndex == 0) {
				videoTeaser.buildTeaserImages(domainName);
			}
	 	var teserDiv = document.getElementById('SWBVideoTeaser');
	 	teserDiv.innerHTML = '';
	 	teserDiv.appendChild(videoTeaser.imgArray[videoTeaser.swbCurrentIndex]);
	 	if (videoTeaser.autoChangeImage){
		 	videoTeaser.swbCurrentIndex++;	 	
		 	videoTeaser.swbCurrentIndex = videoTeaser.swbCurrentIndex % bankerInfos.length;
		 	videoTeaser.WaitAndChange();	 		
	 	}
	 },
	 WaitAndChange:function(){
		 window.setTimeout('videoTeaser.changeVideo()', 5000);
	 },
	 autoChange:function(domainName){
	 	videoTeaser.changeVideo(domainName);
	 },
	 loadVideo:function(thisObject){
	 	//Calls the function to load the video
	 	showSwbVideo('var.switzerbank.com', thisObject.className,thisObject.title);
	 }
	 
}


/*show and hide currency selection*/
function ChangeCurrency(e, thisVar) {
    var thisEle = $('Crncy');
    if (thisEle)
        Element.remove(thisEle);
    thisEle = null;
    var aHtmlStr = '<div id="Crncy" onmouseover="this.style.display=\'block\'" onmouseout="this.style.display=\'none\'" style="position:absolute;top:'+(Event.pointerY(e)-10)+'px;left:'+ (Event.pointerX(e) - 20 )+'px;")"><ul>';
    var CurrencyTable = getCurrencyTable();
    var proc = function (aCurrency){
                    aHtmlStr += '<li><a href="#" class="' + thisVar.className + '" onclick="ChangedCurrency(\'' + aCurrency.CurrencyCode + '\', this)">' + aCurrency.CurrencyCode + '</a></li>'
                }
    CurrencyTable.each(proc);
    aHtmlStr += '</ul></div>';
    new Insertion.Top('Body', aHtmlStr);					
}
