// You can use like " BrowserDetect.browser == 'Explorer' " or " BrowserDetect.version == '7' "
//BROWSER CHECK

var BrowserDetect = {
    init: function(){
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent) ||
        this.searchVersion(navigator.appVersion) ||
        "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function(data){
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1) 
                    return data[i].identity;
            }
            else 
                if (dataProp) 
                    return data[i].identity;
        }
    },
    searchVersion: function(dataString){
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) 
            return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [{
        string: navigator.userAgent,
        subString: "Chrome",
        identity: "Chrome"
    }, {
        string: navigator.userAgent,
        subString: "OmniWeb",
        versionSearch: "OmniWeb/",
        identity: "OmniWeb"
    }, {
        string: navigator.vendor,
        subString: "Apple",
        identity: "Safari",
        versionSearch: "Version"
    }, {
        prop: window.opera,
        identity: "Opera"
    }, {
        string: navigator.vendor,
        subString: "iCab",
        identity: "iCab"
    }, {
        string: navigator.vendor,
        subString: "KDE",
        identity: "Konqueror"
    }, {
        string: navigator.userAgent,
        subString: "Firefox",
        identity: "Firefox"
    }, {
        string: navigator.vendor,
        subString: "Camino",
        identity: "Camino"
    }, { // for newer Netscapes (6+)
        string: navigator.userAgent,
        subString: "Netscape",
        identity: "Netscape"
    }, {
        string: navigator.userAgent,
        subString: "MSIE",
        identity: "Explorer",
        versionSearch: "MSIE"
    }, {
        string: navigator.userAgent,
        subString: "Gecko",
        identity: "Mozilla",
        versionSearch: "rv"
    }, { // for older Netscapes (4-)
        string: navigator.userAgent,
        subString: "Mozilla",
        identity: "Netscape",
        versionSearch: "Mozilla"
    }],
    dataOS: [{
        string: navigator.platform,
        subString: "Win",
        identity: "Windows"
    }, {
        string: navigator.platform,
        subString: "Mac",
        identity: "Mac"
    }, {
        string: navigator.userAgent,
        subString: "iPhone",
        identity: "iPhone/iPod"
    }, {
        string: navigator.platform,
        subString: "Linux",
        identity: "Linux"
    }]

};
BrowserDetect.init();

// BROWSER CHECK END

$(document).ready(function(){
	
	
	
	if(BrowserDetect.browser == 'Explorer' && BrowserDetect.version == '6'){
		//window.location = "http://www.ikongm.com/oldversion/default.asp"
		$('.Contains-2').css({
			"margin-left" : "30px",
			"margin-right" : "27px"
		});
		$('.WhatsNew ul li').css({
			"margin-bottom" : "1px"
		});
		$('.Menu ul li:eq(0)').find('a').css({
			"width" : "40px"
		});
		$('.Menu ul li:eq(1)').find('a').css({
			"width" : "60px"
		});
		$('.Menu ul li:eq(2)').find('a').css({
			"width" : "40px"
		});
		$('.Menu ul li:eq(8)').find('a').css({
			"width" : "40px"
		});
		$('.Menu ul li:eq(14)').find('a').css({
			"width" : "130px"
		});
		$('.Menu ul li:eq(15)').find('a').css({
			"width" : "40px"
		});
		$('.Menu ul li:eq(16)').find('a').css({
			"width" : "40px"
		});
		$('.Menu ul li:eq(17)').find('a').css({
			"width" : "70px"
		});

	}
	
	$("ul.subMenu").css({display: "none"}); // Opera Fix
	
	$('.subMenu').css({
		"background-color": "#00000F",
		"padding":"0px",
		"margin":"0px",
		"width": "175px",
		"position":"absolute",
		"z-index":"9999"
	});
	
	$('.subMenu li a').css({
		"background-color": "#2C3A53",
		"font-size": "12px",
		"height":"21px",
		"line-height": "18px",
		"width": "167px",
		"display":"block",
		"padding-right":"0px",
		"padding-left":"8px",
		"margin":"0px",
		"font-family": "Verdana, Geneva, sans-serif",
		"font-weight": "bold"
	});
	
	$('.subMenu li a').hover(function(){
		$(this).css({
			"background-color": "#006F9F"
		});
	},function(){
		$(this).css({
			"background-color": "#2C3A53"
		});
	});
	
	$("ul#navigationMenu li.topNavLink").hover(function(){

		$(this).find('ul.subMenu').show(400);
	},function(){
		//$('.Slider').css("visibility","visible");
		$(this).find('ul.subMenu').hide();
	});
	
	$(".SlideMenu ul li div").css({
		"cursor" : "pointer"
	});
	
	$(".SlideMenu ul li div span").css({
		"cursor" : "pointer"
	});
	
    // FONT REPLACEMENT	
    Cufon.replace('.Menu ul li');
	Cufon.replace('.DiffFonts');
	Cufon.replace('.AllButtonItems');
    // FONT REPLACEMENT	END
	
	$('.DiffFonts').css({
		"cursor" : "pointer"
	});

    
	// Slide Menu
    var SlideInterval = setInterval("slideAuto()", 11000);
    
    $(".SlideMenu ul li div").hover(function(){
		
		if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == '6') {
			
		} else {
			$(this).css({
				"background-position" : " 0px -72px"
			});
		}
		
        var SlideThis;
        clearInterval(SlideInterval);
        SlideThis = $(this).find('span').attr("id");
        SlideThis = SlideThis.substring(SlideThis.length - 1, SlideThis.length);
        slideHover(SlideThis);
    }, function(){
		
		if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == '6') {
			
		} else {
			$(this).css({
				"background-position" : " 0px 0px"
			});
		}
		
        SlideInterval = setInterval("slideAuto()", 11000);
    });
	// Slide Menu End
	
	$('.lstPlatforms').change(function(){
		switch($('.listPlatforms option:selected').val()) {
			case '0':
			    $('.PlatformNameJS').html('IKON PLATINUM DEMO REQUEST');
				$('#FormPlatforms').attr('action','http://localhost/platinum/');
				break;
			case '1':
			    $('.PlatformNameJS').html('META TRADER 4 DEMO REQUEST');
				$('#FormPlatforms').attr('action','http://localhost/metatrader/');
				break;
			case '2':
			    $('.PlatformNameJS').html('IKON FUTURES DEMO REQUEST');
				$('#FormPlatforms').attr('action','http://localhost/futures/');
				break;
			case '3':
			    $('.PlatformNameJS').html('CORE OPTIONS DEMO REQUEST');
				$('#FormPlatforms').attr('action','http://localhost/options/');
				break;
			case '4':
			    $('.PlatformNameJS').html('IKON VIKING DEMO REQUEST');
				$('#FormPlatforms').attr('action','http://localhost/viking/');
				break;
			default: 
				default_statement;
		}
	});
	
	$('#PlatinumItem').click(function(){
		$('.PlatformNameJS').html('IKON PLATINUM DEMO REQUEST');
		$('#FormPlatforms').attr('action','http://localhost/platinum/');
	});
	
	$('#MetaItem').click(function(){
		$('.PlatformNameJS').html('META TRADER 4 DEMO REQUEST');
		$('#FormPlatforms').attr('action','http://localhost/metatrader/');
	});
	
	$('#FuturesItem').click(function(){
		$('.PlatformNameJS').html('IKON FUTURES DEMO REQUEST');
		$('#FormPlatforms').attr('action','http://localhost/futures/');
	});
	
	$('#OptionsItem').click(function(){
		$('.PlatformNameJS').html('CORE OPTIONS DEMO REQUEST');
		$('#FormPlatforms').attr('action','http://localhost/options/');
	});
	
	$('#VikingItem').click(function(){
		$('.PlatformNameJS').html('IKON VIKING DEMO REQUEST');
		$('#FormPlatforms').attr('action','http://localhost/viking/');
	});
	
});

var $active;
var $next;


function slideAuto(){
    $active = $('.Slider a img.active');
    
    if ($active.length == 0) 
        $active = $('.Slider a img:last');
    
    $next = $active.parent().next().length ? $active.parent().next().find('img') : $('.Slider a img:first');
    
    $active.addClass('last-active');
    
    $next.css({
        opacity: 0.0
    }).addClass('active').stop().animate({
        opacity: 1.0
    }, 1000, function(){
        $active.removeClass('active last-active');
    });
}


function slideHover(SlideNmb){

    $active = $('.Slider a img.active');
    var $activeName = $active.attr("id");
    $activeName = $activeName.substring($activeName.length - 1, $activeName.length);
    
    $next = $(".Slider a:eq(" + SlideNmb + ")").find('img');
    var $nextName = $next.attr("id");
    $nextName = $nextName.substring($nextName.length - 1, $nextName.length);
	
    if ($activeName != $nextName) {
        $active.addClass('last-active');
        
        $next.css({
            opacity: 1.0
        }).addClass('active');
		
		$active.removeClass('active last-active');
    }
}





