﻿// THORNS FUNCTIONS

function changeBgPos(elementId,height){
    document.getElementById(elementId).style.backgroundPosition="0 "+height+"px";
}
function swapElement(hide,show){
    document.getElementById(hide).style.display="none";
    document.getElementById(show).style.display="block";
}

function getElementsByClassName(node, classname)
{
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function loadInSIFR(){

var Swiss721BlkCnBTcenter = {src: '/ewcommon/fonts/Swis721BlkCn_BT_center.swf',ratios: [6,1.32,7,1.28,8,1.31,9,1.27,10,1.25,11,1.24,12,1.23,13,1.22,14,1.21,15,1.2,16,1.22,17,1.2,18,1.2,19,1.19,20,1.19,21,1.18,22,1.18,23,1.19,24,1.19,25,1.18,26,1.18,27,1.18,28,1.17,29,1.17,30,1.16,31,1.18,32,1.17,33,1.17,34,1.16,35,1.17,36,1.16,37,1.16,38,1.16,39,1.17,40,1.16,41,1.16,42,1.16,43,1.16,44,1.16,45,1.15,46,1.16,47,1.16,48,1.16,49,1.16,50,1.16,51,1.15,52,1.15,53,1.15,54,1.16,55,1.15,56,1.15,57,1.15,58,1.15,59,1.15,60,1.15,61,1.15,62,1.15,63,1.15,64,1.15,65,1.15,66,1.15,67,1.15,68,1.15,69,1.15,70,1.15,71,1.15,72,1.15,73,1.15,74,1.15,76,1.14,77,1.15,78,1.15,80,1.15,81,1.15,82,1.14,83,1.14,84,1.14,85,1.15,86,1.15,87,1.14,88,1.15,89,1.14,90,1.14,91,1.14,92,1.15,93,1.14,94,1.14,95,1.14,96,1.14,97,1.14,98,1.14,99,1.14,100,1.14,101,1.14,102,1.14,103,1.14,104,1.14,105,1.14,106,1.14,107,1.14,108,1.14,109,1.14,110,1.14,111,1.14,112,1.14,113,1.14,114,1.14,115,1.14,116,1.14,117,1.14,118,1.14,119,1.14,120,1.14,121,1.14,122,1.14,123,1.14,124,1.14,1.14]};
var Swiss721CnBTcenter = {src: '/ewcommon/fonts/Swis721Cn_BT_center.swf',ratios: [6,1.32,7,1.28,8,1.31,9,1.27,10,1.25,11,1.24,12,1.23,13,1.22,14,1.21,15,1.2,16,1.22,17,1.2,18,1.2,19,1.19,20,1.19,21,1.18,22,1.18,23,1.19,24,1.19,25,1.18,26,1.18,27,1.18,28,1.17,29,1.17,30,1.16,31,1.18,32,1.17,33,1.17,34,1.16,35,1.17,36,1.16,37,1.16,38,1.16,39,1.17,40,1.16,41,1.16,42,1.16,43,1.16,44,1.16,45,1.15,46,1.16,47,1.16,48,1.16,49,1.16,50,1.16,51,1.15,52,1.15,53,1.15,54,1.16,55,1.15,56,1.15,57,1.15,58,1.15,59,1.15,60,1.15,61,1.15,62,1.15,63,1.15,64,1.15,65,1.15,66,1.15,67,1.15,68,1.15,69,1.15,70,1.15,71,1.15,72,1.15,73,1.15,74,1.15,76,1.14,77,1.15,78,1.15,80,1.15,81,1.15,82,1.14,83,1.14,84,1.14,85,1.15,86,1.15,87,1.14,88,1.15,89,1.14,90,1.14,91,1.14,92,1.15,93,1.14,94,1.14,95,1.14,96,1.14,97,1.14,98,1.14,99,1.14,100,1.14,101,1.14,102,1.14,103,1.14,104,1.14,105,1.14,106,1.14,107,1.14,108,1.14,109,1.14,110,1.14,111,1.14,112,1.14,113,1.14,114,1.14,115,1.14,116,1.14,117,1.14,118,1.14,119,1.14,120,1.14,121,1.14,122,1.14,123,1.14,124,1.14,1.14]};

  sIFR.debugMode = true;
  sIFR.delayCSS  = true;
  sIFR.activate(Swiss721BlkCnBTcenter);
  
  sIFR.replace(Swiss721BlkCnBTcenter, {selector: '#mainTopTitle.blue h1',wmode: 'transparent',css: ['.sIFR-root {color:#016cb1;text-align: left;font-size: 36px;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});
  sIFR.replace(Swiss721BlkCnBTcenter, {selector: '#mainTopTitle.red h1',wmode: 'transparent',css: ['.sIFR-root {color:#a9232c;text-align: left;font-size: 36px;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});
  sIFR.replace(Swiss721BlkCnBTcenter, {selector: '#mainTopTitle.green h1',wmode: 'transparent',css: ['.sIFR-root {color:#32a02f;text-align: left;font-size: 36px;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});
  sIFR.replace(Swiss721BlkCnBTcenter, {selector: '#mainTopTitle.yellow h1',wmode: 'transparent',css: ['.sIFR-root {color:#faa32f;text-align: left;font-size: 36px;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});
  sIFR.replace(Swiss721BlkCnBTcenter, {selector: '#mainTopTitle h1',wmode: 'transparent',css: ['.sIFR-root {color:#a3a3a3;text-align: left;font-size: 36px;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});
  sIFR.replace(Swiss721CnBTcenter, {selector: '#WelcomeText h1',wmode: 'transparent',css: ['.sIFR-root {color:#006DB2;text-align: left;font-size: 28px;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});  
  sIFR.replace(Swiss721BlkCnBTcenter, {selector: '.searchForm #searchInput label',wmode: 'transparent',css: ['.sIFR-root {color:#ffffff;text-align: left;font-size: 20px;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});
  /*sIFR.replace(FuturaBTMedCndcenter, {selector: '#quoteTitle .quoteTitle',wmode: 'transparent',css: ['.sIFR-root {color:#000000;text-align: right;font-size: 18px;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});
  sIFR.replace(FuturaBTMedCndcenter, {selector: '#mainMenuContainer a',wmode: 'transparent',css: ['.sIFR-root {color:#FFFFFF;text-align: rigth;font-size: 16px;padding: 0;margin-top:5px;margin-left:5px;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});

  sIFR.replace(FuturaBTMedCndcenter, {selector: 'h1',wmode: 'transparent',css: ['.sIFR-root {color:#006DB2;text-align: left;font-size: 36pt;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});
  sIFR.replace(FuturaBTMedCndcenter, {selector: 'h2',wmode: 'transparent',css: ['.sIFR-root {color:#006DB2;text-align: left;font-size: 32pt;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});
  sIFR.replace(FuturaBTMedCndcenter, {selector: 'h3',wmode: 'transparent',css: ['.sIFR-root {color:#006DB2;text-align: left;font-size: 26pt;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']}); 
  sIFR.replace(FuturaBTMedCndcenter, {selector: 'h4',wmode: 'transparent',css: ['.sIFR-root {color:#006DB2;text-align: left;font-size: 18pt;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});
  sIFR.replace(FuturaBTMedCndcenter, {selector: 'h5',wmode: 'transparent',css: ['.sIFR-root {color:#006DB2;text-align: left;font-size: 14pt;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});
  sIFR.replace(FuturaBTMedCndcenter, {selector: 'h6',wmode: 'transparent',css: ['.sIFR-root {color:#006DB2;text-align: left;font-size: 11pt;font-weight:bold;padding: 0;}','a { text-decoration: none; }','a:link { color: #414141; }','a:hover { color: #555555; }']});     */
}
function selectOptionSwitch(dropdownId){
    selects = document.getElementById(dropdownId)
    clickedId = selects.options[selects.selectedIndex].value;
    var newDisplay = 'dispImage_' + clickedId;
    if (document.getElementById(newDisplay)){
        optionSwitch(clickedId,dropdownId,true);
    }
}

function optionSwitch(clickedId,dropdownId,bChangeSelect){

    var newThumbnail = 'optImage_' + clickedId;
    var newDisplay = 'dispImage_' + clickedId;
    
    // Change class of selected thumbnail and display image back
    var opthumbs = getElementsByClassName(document, 'currentOptTN')
     for(var i = 0; i < opthumbs.length; i++)
     {
        opthumbs[i].className = 'optTN'
     }
	var elems2 = getElementsByClassName(document, 'displayShow')
     for(var i = 0; i < elems2.length; i++)
     {
        elems2[i].className = 'displayClosed'
     }
     
     // Make current thumbnailand display image
     document.getElementById(newThumbnail).className = 'currentOptTN';
	 document.getElementById(newDisplay).className = 'displayShow';
	 
	 // IF not changed by drop down, change the drop down
	 if (!bChangeSelect){
	 
	    var selects = document.getElementById(dropdownId);
	    
	    selects.options[selects.selectedIndex].selected = false;
	    
	    for (i=0; i<selects.length; i++){
	        if (selects[i].value==clickedId) {
	            selects[i].selected = true;
	        }  
	    }
	    
	 }
	 
}
