acdcCalc = {}
    
function initAcdcCalculator() {
    v = acdcCalc.v;
    
    for(i in v) {
        jQuery("#dc-1sec").append("<option value="+v[i][0]+">"+v[i][0]+"</option>");
        jQuery("#dc-1min").append("<option value="+v[i][1]+">"+v[i][1]+"</option>");
        jQuery("#cont").append("<option value="+v[i][2]+">"+v[i][2]+"</option>");
        jQuery("#ac-1sec").append("<option value="+v[i][3]+">"+v[i][3]+"</option>");
        jQuery("#ac-1min").append("<option value="+v[i][4]+">"+v[i][4]+"</option>");
    }
    
    return v;
}

jQuery(document).ready(function() {
	jQuery("#showEurope").click(function() {
		$(".country_flag").hide();
		$(".area_Europe").show();
		$(".area_Germany").show();
		$(".area_UnitedKingdom").show();
	});
	
	jQuery("#showUSA").click(function() {
		$(".country_flag").hide();
		$(".area_USA").show();
	});
	
	jQuery("#showAsia").click(function() {
		$(".country_flag").hide();
		$(".area_Asia").show();
	});
	
	jQuery("#showAll").click(function() {
		$(".country_flag").show();
	});
    
    jQuery('#footerlogos #ledlightforyou').click(function() {
        jQuery("object[classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000']").css({"visibility":"hidden"});
        if (jQuery(".dialog-modal").length<1) { jQuery("#main").append('<div class="dialog-modal" style="display:none;z-index:10000;"><img src="/typo3conf/ext/user_recom/res/ledlightforyou.jpg" /><div>'); }
        jQuery(".dialog-modal").dialog({
            width: 480,
            height: 735,
            title: 'LED Light for you Certified Partner',
            buttons: {
                "Close": function() { jQuery(this).dialog("close"); jQuery("object[classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000']").css({"visibility":"visible"}); },
                "Go to LED - Light for you website": function() {
                    window.open("http://www.ledlightforyou.com","_blank");
                    jQuery(this).dialog("close");
                    jQuery("object[classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000']").css({"visibility":"visible"}); 
                }
            },
            modal: true
        });
        if (navigator.userAgent.search("MSIE 8.0")<0) {
         jQuery(window).scrollTop(200);
        }
        return false;
    });
    
     /**
    *
    * ACDC Calculator
    *
    */
    if (jQuery("#acdc-calculator").length) {
	
		var idGeneralPurpose = 1540,
			idMedical = 1541,
			idIgbt = 1542,
			idHighVoltage = 1543;

		if (jQuery("#idRecomAsiaCom").length==1) {
			idGeneralPurpose = 1582;
			idMedical = 1581;
			idIgbt = 1580;
			idHighVoltage = 1579;
		}			
		if (jQuery("#idRecomAsiaCn").length==1) {
			idGeneralPurpose = 1561;
			idMedical = 1560;
			idIgbt = 1559;
			idHighVoltage = 1558;
		}
		if (jQuery("#idRecomAsiaJp").length==1) {
			idGeneralPurpose = 1568;
			idMedical = 1567;
			idIgbt = 1566;
			idHighVoltage = 1565;
		}
		if (jQuery("#idRecomAsiaKr").length==1) {
			idGeneralPurpose = 1575;
			idMedical = 1574;
			idIgbt = 1573;
			idHighVoltage = 1572;
		}
		if (jQuery("#idRecomPower").length==1) {
			idGeneralPurpose = 1554;
			idMedical = 1553;
			idIgbt = 1552;
			idHighVoltage = 1551;
		}
				
		acdcCalc.v = [
			[1000,800,130,700,500,{'site':idGeneralPurpose,'alsosites':idMedical+','+idIgbt+','+idHighVoltage}],
			[1400,1130,195,1000,700,{'site':idGeneralPurpose,'alsosites':idMedical+','+idIgbt+','+idHighVoltage}],
			[1500,1200,230,1080,750,{'site':idGeneralPurpose,'alsosites':idMedical+','+idIgbt+','+idHighVoltage}],
			[2000,1600,550,1400,1000,{'site':idGeneralPurpose,'alsosites':idMedical+','+idIgbt+','+idHighVoltage}],
			[2100,1695,620,1500,1050,{'site':idGeneralPurpose,'alsosites':idMedical+','+idIgbt+','+idHighVoltage}],
			[2500,2000,800,1750,1250,{'site':idGeneralPurpose,'alsosites':idMedical+','+idIgbt+','+idHighVoltage}],
			[2800,2260,950,2000,1400,{'site':idGeneralPurpose,'alsosites':idMedical+','+idIgbt+','+idHighVoltage}],
			[3000,2400,1100,2100,1500,{'site':idMedical,'alsosites':idIgbt+','+idHighVoltage}],
			[3500,2825,1400,2500,1750,{'site':idMedical,'alsosites':idIgbt+','+idHighVoltage}],
			[4000,3200,1800,2800,2000,{'site':idIgbt,'alsosites':String(idHighVoltage)}],
			[4230,3390,1950,3000,2100,{'site':idIgbt,'alsosites':String(idHighVoltage)}],
			[5000,4000,2450,3550,2500,{'site':idHighVoltage,'alsosites':''}],
			[5650,4520,2800,4000,2800,{'site':idHighVoltage,'alsosites':''}],
			[6000,4800,3050,4250,3050,{'site':idHighVoltage,'alsosites':''}],
			[6450,5200,3200,4600,3200,{'site':idHighVoltage,'alsosites':''}],
			[8000,6400,3950,5600,3950,{'site':idHighVoltage,'alsosites':''}],
			[8450,6780,4200,6000,4200,{'site':idHighVoltage,'alsosites':''}],
			[10000,8000,4950,7050,4950,{'site':idHighVoltage,'alsosites':''}]
		];
        initAcdcCalculator();
        
        // First select all corresponding voltages
        // Second load the result html
        jQuery("#acdc-calculator").delegate("select","change",function(event) {
            event.stopPropagation();

            //var selInd = jQuery(this).attr("selectedIndex");
		    var selInd = jQuery(this).find("option:selected").first().index();
			
            jQuery("#dc-1sec option:nth("+selInd+"), #dc-1min option:nth("+selInd+"),"+
                "#cont option:nth("+selInd+"),#ac-1sec option:nth("+selInd+"),"+
                "#ac-1min option:nth("+selInd+")").attr("selected","true");
            
            var d = new Date();
            jQuery("#result .result-header").html("<h3>You are searching for:</h3>");
            jQuery("#result .result").html('').css({'background':'transparent url(/fileadmin/styles/06_layouts_0col/css/images/ajax-loader1.gif) no-repeat 50% 50%','min-height':'100px'});
            jQuery("#result .result").load('/index.php?id='+acdcCalc.v[selInd-1][5].site+'&ts='+d.getTime()+' .upper');
            var tAlsoSites = acdcCalc.v[selInd-1][5].alsosites.split(',');
            if (tAlsoSites[0]!='') {
                jQuery("#also-result").html('').append('<h3>You may also be interested in:</h3>');
                for (i=0;i<tAlsoSites.length;i++) {
                  jQuery("#also-result").append('<div class="alsocontent'+i+'"></div>');
                    jQuery('#also-result .alsocontent'+i).html('').css({'background':'transparent url(/fileadmin/styles/06_layouts_0col/css/images/ajax-loader1.gif) no-repeat 50% 50%','min-height':'100px'});
                    jQuery('#also-result .alsocontent'+i).load('/index.php?id='+tAlsoSites[i]+'&ts='+d.getTime()+' .upper');
              }
            } else {
                jQuery("#also-result").html("").css({'background':'transparent'});
            }
         
            return false;
        });
    }
    
});


