﻿
var _gNavItemSelected = "home";
    
function aimateShowcase()
{
    $('.slideshow').cycle(
    {
	    fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	    timeout:       4000  // milliseconds between slide transitions (0 to disable auto advance) 
    });
}


var _gClientsHash = new Array();
    _gClientsHash[0] = "client_elgouna";
    _gClientsHash[1] = "client_hardrock";
    _gClientsHash[2] = "client_elsewedy";
    _gClientsHash[3] = "client_hsbc";
    _gClientsHash[4] = "client_orascom";
    

$("#client_elgouna, #client_hardrock, #client_elsewedy, #client_hsbc, #client_orascom").css("opacity","0");
function animateClients()
{
    var cn = _gClientsHash[ 0 ];

    /******* ELGOUNA ******/
    $("#"+cn).show().animate({"opacity": 1, left:"30px" }, 2000, "easeOutExpo");
    setTimeout(function()
    {
        $("#"+cn).animate({"opacity": 0, left:"375px"}, 2000, "easeInExpo");
        setTimeout(function()
        {
            $("#"+cn).css({ left:"-323px", display:"none" });
            
            /******* HARDROCK ******/
            cn = _gClientsHash[ 1 ]; 
            $("#"+cn).show().animate({"opacity": 1, left:"12px" }, 2000, "easeOutExpo");
            setTimeout(function()
            {
                $("#"+cn).animate({"opacity": 0, left:"375px" }, 2000, "easeInExpo");
                setTimeout(function()
                {
                    $("#"+cn).css({ left:"-346px", display:"none" });
                    
                    /******* ELSEWEDY ******/
                    cn = _gClientsHash[ 2 ];
                    $("#"+cn).show().animate({"opacity": 1, left:"30px" }, 2000, "easeOutExpo");
                    setTimeout(function()
                    {
                        $("#"+cn).animate({"opacity": 0, left:"375px" }, 2000, "easeInExpo");
                        setTimeout(function()
                        {
                            $("#"+cn).css({ left:"-312px" , display:"none"});
                            
                            /******* HSBC ******/
                            cn = _gClientsHash[ 3 ];
                            $("#"+cn).show().animate({"opacity": 1, left:"25px" }, 2000, "easeOutExpo");
                            setTimeout(function()
                            {
                                $("#"+cn).animate({"opacity": 0, left:"375px" }, 2000, "easeInExpo");
                                setTimeout(function()
                                {
                                    $("#"+cn).css({ left:"-323px", display:"none" });
                                    
                                    /******* ORASCOM ******/
                                    cn = _gClientsHash[ 4 ];
                                    $("#"+cn).show().animate({"opacity": 1, left:"15px" }, 2000, "easeOutExpo");
                                    setTimeout(function()
                                    {
                                        $("#"+cn).animate({"opacity": 0, left:"375px" }, 2000, "easeInExpo");
                                        setTimeout(function()
                                        {
                                            $("#"+cn).css({ left:"-345px", display:"none" });
                                            
                                            /******* RESTART METHOD ******/
                                            //_gAnimTimeOut = setTimeout("animateClients()", 16); 
                                            animateClients();
                                            
                                        }, 2100);
                            	        
                                    }, 2000);
                                    /***** END ORASCOM ****/
                                    
                                }, 2100);
                    	        
                            }, 2000);
                            /******* END HSBC ******/
                            
                        }, 2100);
            	        
                    }, 2000);
                    /******* END ELSEWEDY ******/
                    
                }, 2100);
    	        
            }, 2000);
            /******* END HARDROCK ******/
            
        }, 2100);
        
    }, 2000);
    /******* END ELGOUNA ******/
}

function GetPromotionsLink()
{
    $.ajax({
            type: "POST",
            url: "admin/getHomepageInfo.php",
            data: "{}",
            success: function(msg)
            {
				var result = eval('(' + msg + ')');
                
				var promolink = result.homeinfo.data.promolink;
				
				$('#promo_dummy').click(function()
                {
                    window.location = "products.htm?p="+promolink;
                });
			}
         });
}
    
    
$(document).ready(function() //$(function( $ )
{
    GetPromotionsLink();
    
    $('#bp_dummy').click(function()
    {
        window.location = "services.htm?v=tech";
    });
    
    
    $("#"+_gNavItemSelected+"_wrapper").removeClass("hidden");
    
    //$("#mainContainer").fadeIn("slow");
    
    /**/
    $("div.items div").click(function()
    {
        var id = $(this).attr("id").replace("_full_224x87", "");
        
        $("#showcase").css("opacity","0.4"); 
        
        switch(id)
        {
            case "construction":
            {
                window.location = "about.htm";
                break;
            }
            case "tech":
            {
                window.location = "services.htm?v=tech";
                break;
            }
            case "esplanada":
            {
                window.location = "services.htm?v=esplanada";
                break;
            }
            case "eladly":
            {
                window.location = "services.htm?v=eladly";
                break;
            }
        }
        
    });
    
    
    aimateShowcase();
    
    animateClients();


});
