﻿// JScript File

// onLoad functions

$(document).ready(function() {
    var isOpen = false;     
    $("#langSelector").click(function() {
        if(isOpen)
        {
            $("#langOptions").slideUp();
            $("#langSelector").removeClass('arrUp');
            isOpen = false;
        }
        else
        {
           $("#langOptions").slideDown(); 
           $("#langSelector").addClass('arrUp');
           isOpen = true;
        }
    }); 

    $('#homeFlash').flash({
        src: 'flash/iflash.swf',
        width: 530,
        height: 316,
        wmode: 'transparent'
    });

    // about tabs
    $("#Company").click(function() {
        SetCurrentTab(1);
    });
    $("#Management").click(function() {
        SetCurrentTab(3);
    });    
    $("#WhatIs").click(function() {
        SetCurrentTab(4);
    }); 
        
    //faq tabs
    $("#Publishers").click(function() {
        SetCurrentTab(1);
    });
    $("#Advertisers").click(function() {
        SetCurrentTab(3);
    }); 
    $("#General").click(function() {
        SetCurrentTab(5);
    });          
        
    $("#pop1").fadeTo("fast", 0.70);
});

function SetCurrentTab(index)
{
    var tabsCount = $("#tabs_strip li").length + 1;
    
    for(i=0; i<tabsCount; i++)
    {
        //set all tabs to none-active tabs
        $("#tabs_strip li:nth-child("+i+") a").removeClass("tabActive"); 
        //hide all contents
        $("#tabs_contents div:nth-child("+i+")").css({"display" : "none"});
    }
    // mark selected tab as active
    $("#tabs_strip li:nth-child("+index+") a").addClass('tabActive');
    
    // case there is a seperator <li> between tabs
    if(index > 2)
        index -= tabsCount-(tabsCount-1);
    
    // show selected content
    $("#tabs_contents div:nth-child("+index+")").css({"display" : "block"});
		
    // show all elements in selected content
    $("#tabs_contents div:nth-child("+index+") div").css({"display" : "block"});
}
