$(document).ready(function(){
    $("#search").keypress(function(event){
        if(event.which=='13')
        {
            self.location='index.php?show=Talks&query='+$(this).val();
        }

    });
    $("#search").focus(function(){
        $("#search").val('');
    }).blur(function(){
        $("#search").val('Search...');
    });

    $(".piclinks").mouseover(function(){
        $(this).css('opacity', '0.7');
    }).mouseout(function(){$(this).css('opacity', '1');})
    ;

    $(".campaigns").mouseover(function(){
        $(this).css('opacity', '0.7');
    }).mouseout(function(){$(this).css('opacity', '1');})
    ;

    $(".campaigns").click(function(){
        e = new String($(this).attr('id'));
        e = e.substring(1);
        
       showcampaign(e);
       
    });

    $(".about").click(function(){
        thisid = $(this).attr('id');
        e = new String(thisid);
        e = e.substring(1);

       show(e);

    });

    $("#event").change(function(){
       showTalks('event', $(this).val());
    });

    $(".press_tabs").click(function(){

        $.each($(".press_tabs"), function(i, j){
            $(this).attr("src", $(this).attr("default_src") );
            $("#press"+$(this).attr("order")).hide();
        });
       $("#press"+$(this).attr("order")).show();
       $(this).attr("src", $(this).attr("hover_src") );
       
    });

    $(".newsletter").focus(function(){
        if($(this).val()=='Enter Email For Newsletter Signup...' )
        {
        $(this).val("");
        }

    }).blur(function(){
       if($(this).val()=='')
       {
       $(this).val("Enter Email For Newsletter Signup...");
       }
    });

    $("#newslettersubscribe").click(function(){
        if($(".newsletter").val()=='' || $(".newsletter").val()=='Enter Email For Newsletter Signup...')
        {
            $("#newsletter_msg span").text("Please enter a valid email");
            $("#newsletter_msg").show();
        }
        else
        {
            $("#newsletterform").submit();
        }
    });

    

}
)

function showcampaign(e)
{
    $.each($(".campaigncontent"), function(i,j){
           ic = i+1;
           $(this).css('display', "none");
           ic_src = new String($("#c"+ic).attr("src"));
           $("#c"+ic).attr('src',  ic_src.replace('_hover.png', '.png') );
       });

       $("#campaign"+e).css("display", '');
       e_src = new String($("#c"+e).attr("src"));
       $("#c"+e).attr('src',  e_src.replace('.png', '_hover.png') );
    
}

function show(o)
{
    $.each($(".aboutcontent"), function(i,j){
           ei=i+1;
           $(this).css('display', "none");
           $('#a'+ei).css("color", '#595959');
       });

       $("#about"+o).css("display", '');
       $("#a"+o).css("color", '#ff0000');

}
function showTalks(cond,id)
{
    $("#talks").html("");

    
    $("#loading").show();
    $("#talks").load("index.php?show=showTalks&"+cond+"="+id, function(){
    $("#loading").hide();
    
    });
    
}
function sponsors(s)
{
    $("#list_of_honor img").show();
    $("#list_of_honor img").css("margin-top", '34px');
    sponsorsarr = new Array();
    sponsorsarr[0] = "http://tedxcairo.com/ss1.png";
    sponsorsarr[1] = "http://tedxcairo.com/ss2.png";
    sponsorsarr[2] = "http://tedxcairo.com/ss2.png";
    sponsorsarr[3] = "http://www.tedxcairo.com/sponsors/s4.png";
    sponsorsarr[4] = "http://www.tedxcairo.com/sponsors/spla.jpg";
    sponsorsarr[5] = "http://www.tedxcairo.com/sponsors/s3.gif";
    
    
    sponsorsarr[6] = "http://tedxcairo.com/sp8.jpg";
    sponsorsarr[7] = "http://tedxcairo.com/sp66.jpg";
    sponsorsarr[8] = "http://tedxcairo.com/6.jpg";
    sponsorsarr[9] = "images/cocacola.png";
    

    $("#list_of_honor img").attr("src", sponsorsarr[s]);
    if(s<5)
    {
    $("#list_of_honor img").css("width", '198px');
    $("#list_of_honor img").css("height", '101px');
    }
    else if(s==5)
    {
    $("#list_of_honor img").css("width", '198px');
    $("#list_of_honor img").css("height", '');
    $("#list_of_honor img").css("margin-top", '70px');
    }
    else if(s==9)
    {
    $("#list_of_honor img").css("width", '105px');
    $("#list_of_honor img").css("margin-top", '30px');
    }
    else
    {
    $("#list_of_honor img").css("width", '');
    $("#list_of_honor img").css("height", '');
        if(s==6)
        {
            $("#list_of_honor img").css("margin-top", '70px');
        }
        else
        {
            $("#list_of_honor img").css("margin-top", '50px');
        }
    }

    nsponosr = s+1;
    
    if(nsponosr>9)
    {
        nsponosr=0;
    }
   setTimeout( "sponsors("+nsponosr+")" , 5000);
}

function arabic_quote()
{
    document.write("الهمونا بأمل يستحق النشر و الانتشار..شرفني ان اكون معكم ");
}
