/* 
---------------------------------------------------------------------------------------------------
GLOBAL VARIABLE DECLARATION
---------------------------------------------------------------------------------------------------
*/

var HostAddress="";
var CurrentSection="";
var Assetspath;


/* 
---------------------------------------------------------------------------------------------------
FUNCTION EXECUTEHANDLERS  - USED TO EXECUTE THE FUNCTIONS AT PAGE RENDER
---------------------------------------------------------------------------------------------------
*/

function ExecuteHandlers()
 {
  Preloader("");
  $("img[@src$=png]").pngfix();
  BindHanders("Navigation0");
  BindHanders("Footer");
  HoverThumb();
  ChangeLang();
  AssignRollOvers(".Navigation0");
  
  $("h1 a").css({cursor:"pointer"});
  $("h1 a")
  .bind("click",function(){
  	setHash($(this).attr("href").replace(HostAddress,".."));
  	return false;
  	});

/* IE background flickering */

	if(jQuery.browser.msie && jQuery.browser.version==6.0) 
	 {
	 document.execCommand("BackgroundImageCache",false,true);
   }

	if(jQuery.browser.msie) 
	 {
    positionPage();
    $(window).resize(function(){
     positionPage();
    });
   }
   
   HostAddress=location.href.split("/")[0]+"//"+location.href.split("/")[2];

VisitParent();

 }
 

/* 
---------------------------------------------------------------------------------------------------
FUNCTION PRELOADER - EXECUTES AT AJAX CALLS AND PAGE LOAD
---------------------------------------------------------------------------------------------------
*/

function Preloader(targetURL)
 {
  if(targetURL=="")
   {
   	PageAnimate();
   }
  else
   {  
    $("#Preloader").fadeIn("slow",function(){LoadPage(targetURL);});
   }
 }
 
 
/* 
---------------------------------------------------------------------------------------------------
FUNCTION POSTLOADER - EXECUTES AT AJAX CALLS AND PAGE LOAD END
---------------------------------------------------------------------------------------------------
*/

function Postloader()
 {
  $("#Preloader").fadeOut("slow");
 }


/* 
---------------------------------------------------------------------------------------------------
FUNCTION BindHanders - BINDS CLICK HANDLERS TO CLICKABLE ITEMS
---------------------------------------------------------------------------------------------------
*/

function BindHanders(NavClass)
 {
  $("."+NavClass+" a")
  .bind("click",function()
   {
   	var targetURL;
    targetURL=$(this).attr("href"); 
    if($(this).attr("rel")!=undefined)
     CurrentSection=$(this).attr("rel");
     setHash($(this).attr("href").replace(HostAddress,".."));
     
    return false;
   }); 
  
/* Binding Animation Effect with Navigation0 Collapse and Expand Buttons */

  $(".NavExpand a").unbind().
  bind("click",function(){
   ToggleNavigation0("Open");
   return false;
   });
  $(".NavCollapse a").unbind().
  bind("click",function(){
   ToggleNavigation0("Close");
   return false;
   });
 }


/* 
---------------------------------------------------------------------------------------------------
TOGGLE NAVIGATION0 EXPAND AND CLOSE
---------------------------------------------------------------------------------------------------
*/

function ToggleNavigation0(Direction)
 {
 	if(Direction=="Close")
   {
    $(".Navigation0").animate({right:-470},{duration:600,easing:"easeOutQuad",complete:function(){
     $(".NavExpand").fadeIn({duration:600,easing:"easeOutQuad"});
    }});
    $(".NavCollapse").animate({right:-10},{duration:600,easing:"easeOutQuad"});
   }
  else
   {
    $(".NavExpand").fadeOut(1000,function(){    
    	$(".NavCollapse").animate({right:470},{duration:600,easing:"easeInQuad"});
    	$(".Navigation0").animate({right:-15},{duration:600,easing:"easeInQuad"});
    	});
  }  	
 } 


/* 
---------------------------------------------------------------------------------------------------
SWF ADDRESS SETHASH FUNCTION
---------------------------------------------------------------------------------------------------
*/

function setHash(targetURL)
 {
   var hashVal=targetURL;
   hashVal=hashVal.replace(HostAddress,"");

    if(location.href.indexOf(CurrentSection)>=0 && CurrentSection!="")
    {
     if(location.href.indexOf(targetURL.replace("..",""))<0)
     $(".Cell2x2 .TextContent").animate({opacity:.2},500);
     $(".Master #Preloader").clone().appendTo($(".Cell2x2").eq(0));
     $(".Cell2x2").eq(0).find("#Preloader").css({marginTop:-23});
    }

   
   SWFAddress.setValue(hashVal.replace("../",""));
   
 }


/* 
---------------------------------------------------------------------------------------------------
SWF ADDRESS CHANGEHANDLER FUNCTION
---------------------------------------------------------------------------------------------------
*/

function changeHandler(Event)
 {

  if(Event.value=="/" || Event.value.indexOf("TermsConditions")>=0) return;

  var hashLength = Event.value.split("/").length;
  
  if(hashLength<3)
  Handlepath=Event.value.split("/")[1];

  else if(hashLength>3)
  Handlepath=Event.value.split("/")[1]+"/"+Event.value.split("/")[2]+"/"+Event.value.split("/")[3];  

  else
  Handlepath=Event.value.split("/")[1]+"/"+Event.value.split("/")[2];
  
  Assetspath=Handlepath;   
  Animateout();
 }	


/* 
---------------------------------------------------------------------------------------------------
SWF ADDRESS LISTENER CALL
---------------------------------------------------------------------------------------------------
*/

SWFAddress.addEventListener(SWFAddressEvent.CHANGE, changeHandler);


/* 
---------------------------------------------------------------------------------------------------
LOADPAGE FUNCTION TO LOAD AJAX CALLBACK CONTENTS
---------------------------------------------------------------------------------------------------
*/

function LoadPage(targetURL)
 {         
 	if(location.href.replace(HostAddress,"").split("/")[1].indexOf("Default")<0 && location.href.replace(HostAddress,"").split("/")[1].indexOf("Disclaimer")<0 && location.href.replace(HostAddress,"").split("/")[1].indexOf("Contactus")<0)
 	targetURL="../"+targetURL;
  
  $.get(targetURL+"?decache="+(Math.random()*999999),function(data)
   {
   	var Markup;

   	if(location.href.replace(HostAddress,"").split("/").length<5 && location.href.replace(HostAddress,"").split("/")[1].indexOf("Default")<0 && location.href.replace(HostAddress,"").split("/")[1].indexOf("Disclaimer")<0 && location.href.replace(HostAddress,"").split("/")[1].indexOf("Contactus")<0)
   	 Markup=data.replace(/Common\//g,"../Common/");

    else if(location.href.replace(HostAddress,"").split("/")[1].indexOf("Default")<0 && location.href.replace(HostAddress,"").split("/")[1].indexOf("Disclaimer")<0 && location.href.replace(HostAddress,"").split("/")[1].indexOf("Contactus")<0)
     Markup=data;
   	   	 
   	else
   	 Markup=data.replace(/\.\.\//g,"");

     
    if(location.href.indexOf(CurrentSection)>=0 && CurrentSection!="")
     {
      Markup=$(Markup).find(".Cell2x2").html();      
      $(".Cell2x2 TextContent").remove();
      $(".Cell2x2").html(Markup);
      if($('.scroll-pane').length>0)
      {
      $('.scroll-pane').jScrollPane({animateTo:true});
      AnchorScroll();
	 		  $(".jScrollPaneDrag").css({opacity:"1",zIndex:"700"}); 
	 		  $(".jScrollPaneTrack").css({opacity:"1",zIndex:"600"});
	 		  $(".jScrollArrowUp").css({opacity:"1",zIndex:"600"}); 
        $(".jScrollArrowDown").css({opacity:"1",zIndex:"600"});	
      }
      VisitParent();

      CurrentSection="";
      Postloader();
      $(".Cell2x2").animate({opacity:"1"},{duration:1000,easing:"easeInQuad"});
     }
    else
     {
      Markup=$(Markup).find(".ContentMaster").html();
      $(".ContentMaster div").remove();
      $(".ContentMaster").html(Markup);
      $(".ContentMaster").css("opacity","1");
      $("img[@src$=png]").pngfix(); 
      $("div.Cell").unbind();
      $(".Navigation1 li a").unbind();
      BindHanders("Navigation1");
      HoverThumb();
      Postloader();

      if($(".Navigation1").length)
      {
      $(".Cell").eq(0).css({width:"317px",overflow:"hidden"});	
      $(".Cell3,.Cell6,.Cell9").css({opacity:"0"});
      $(".Cell2x3,.Cell2x3 img,ul,p,h2").css({opacity:"1"});
      $(".Cell2x3").css({left:"-645px",opacity:"1"});
       Animatein("Inner");
      } 
      else
      {
       if($(".Cell4x4").length==0)
        {
         if(location.href.indexOf(CurrentSection)<=0 && CurrentSection!="")
         $(".Cell").css("opacity","0");
         Animatein("Home");
        }
       else
        {
      	$(".Cell4x4,.TextContent").css({opacity:"1",zIndex:"300"});
        Animatein("Home");
        }
      } 
     }
   }); 

 }


/* 
---------------------------------------------------------------------------------------------------
FUNCTION HOVERTHUMB - TO ANIMATE CELL THUMBNAILS WHEN ROLLOVER
---------------------------------------------------------------------------------------------------
*/

function HoverThumb()
 {

   $("div.Cell div.GridOverlay")
   .bind("mouseover", function(e)
    {
    	$(this).css("cursor","pointer");
    	$(this).parent().find("div.ImageOverlay").animate({opacity:"1"},{queue:false, duration:500});
    })
   .bind("mouseout", function(e)
    {
    	$(this).parent().find("div.ImageOverlay").animate({opacity:"0"},{queue:false, duration:500});
    })
   .bind("click", function(e)                                                 
    {                                                                         
    	if($(this).parent().find("div.ImageOverlay img").eq(0).attr("alt")=="Aboutus")
    	 $(".Navigation0 li a").eq(1).trigger('click');

    	if($(this).parent().find("div.ImageOverlay img").eq(0).attr("alt")=="Expertise")
    	 $(".Navigation0 li a").eq(2).trigger('click');

    	if($(this).parent().find("div.ImageOverlay img").eq(0).attr("alt")=="Media")
    	 $(".Navigation0 li a").eq(4).trigger('click');

    	if($(this).parent().find("div.ImageOverlay img").eq(0).attr("alt")=="Projects")
    	 $(".Navigation0 li a").eq(3).trigger('click');
    });  
    
   $(".More")
   .bind("click", function(e)                                                 
    {                                                                         
     setHash($(this).attr("href").replace(HostAddress,".."));
     return false;
    });      
 }


/* 
---------------------------------------------------------------------------------------------------
FUNCTION ANIMATEOUT TO DELEGATE PAGE SECTION UNLOAD ANIMATIONS
---------------------------------------------------------------------------------------------------
*/
 
function Animateout()
 {
 	if($(".Navigation1").length==0)
 	 {
 	  if($(".Cell4x4").length==0)
 	   {
 	    $(".Cell1").animate({opacity:".2"},200,function(){
 	    	$(".Cell2").animate({opacity:".2"},200,function(){
 	    		$(".Cell3").animate({opacity:".2"},200,function(){
 	    			$(".Cell4").animate({opacity:".2"},200,function(){
 	    				$(".Cell5").eq(1).animate({opacity:".2"},200,function(){
 	    					$(".Cell7").animate({opacity:".2"},200,function(){
 	    						$(".Cell9").animate({opacity:".2"},200,function(){
 	    							Preloader(Assetspath);
 	    							});
 	    						$(".Cell9").animate({opacity:"0"},400);
 	    						});
 	    					$(".Cell7").animate({opacity:"0"},400);
 	    					});
 	    				$(".Cell5").animate({opacity:"0"},400);
 	    				});
 	    			$(".Cell4").animate({opacity:"0"},400);
 	    			});
 	    		$(".Cell3").animate({opacity:"0"},400);
 	    		});
 	    	$(".Cell2").animate({opacity:"0"},400);
 	    	});
 	    $(".Cell1").animate({opacity:"0"},400);
 	   }
 	   else
 	     Preloader(Assetspath);
 	 }

   if($(".Navigation1").length!=0 && CurrentSection=="")
   {
    $(".Cell9").animate({opacity:".8"},200,function(){
    	$(".Cell6").animate({opacity:".8"},200,function(){
    		$(".Cell3").animate({opacity:".8"},200,function(){
	   		$(".Cell2x3").animate({left:"-645px"},600,function(){Preloader(Assetspath);});  
    			});
    		$(".Cell3").animate({opacity:"0"},{duration:700,easing:"easeOutQuad"});
    		});
    	$(".Cell6").animate({opacity:"0"},{duration:600,easing:"easeOutQuad"});
    	});
    $(".Cell9").animate({opacity:"0"},{duration:500,easing:"easeOutQuad"});
   }
  
  if(location.href.indexOf(CurrentSection)>=0 && CurrentSection!="")
   Preloader(Assetspath);
 
 }
 

/* 
---------------------------------------------------------------------------------------------------
FUNCTION ANIMATEIN TO DELEGATE PAGE SECTION LOAD ANIMATIONS
---------------------------------------------------------------------------------------------------
*/

function Animatein(AnimSection)
{
	
 if(AnimSection=="Inner")
 {
  $.blockUI();
 	$(".Cell3,.Cell6,.Cell9").css({opacity:"0"});
  $(".Cell3").animate({opacity:".2"},200,function(){
  	$(".Cell6").animate({opacity:".2"},200,function(){
  		$(".Cell9").animate({opacity:".2"},200,function(){
	 		$(".Cell2x3").animate({left:"1px"},{duration:1500,easing:"easeOutQuad"}); 
      $('.scroll-pane').jScrollPane();
     	 		$(".jScrollPaneDrag").css({opacity:"1",zIndex:"700"});  
	 		    $(".jScrollPaneTrack").css({opacity:"1",zIndex:"600"});
	 		    $(".jScrollArrowUp").css({opacity:"1",zIndex:"600"}); 
          $(".jScrollArrowDown").css({opacity:"1",zIndex:"600"});	  		
  			});
  		$(".Cell9").animate({opacity:"1"},700);
     $(".Cell9 .ImageOverlay").animate({opacity:"1"},600,function(){$(this).animate({opacity:"0"},{duration:600,easing:"easeOutQuad"});});
  		});
  	$(".Cell6").animate({opacity:"1"},500);
  	$(".Cell6 .ImageOverlay").animate({opacity:"1"},500,function(){$(this).animate({opacity:"0"},{duration:500,easing:"easeOutQuad"});});
  	});
  $(".Cell3").animate({opacity:"1"},400);
  $(".Cell3 .ImageOverlay").animate({opacity:"1"},400,function(){$(this).animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});});
  $.unblockUI();
 }
 
 if(AnimSection=="Home")
 {
  $.blockUI();
 	if($(".Cell4x4").length==0)
 	 {
 	  $(".Cell1,.Cell2,.Cell3,.Cell4,.Cell5,.Cell7,.Cell9").css("opacity","0");
 	  $(".Cell1").animate({opacity:".2"},200,function(){
 	  	$(".Cell2").animate({opacity:".2"},200,function(){
 	  		$(".Cell3").animate({opacity:".2"},200,function(){
 	  			$(".Cell4").animate({opacity:".2"},200,function(){
 	  				$(".Cell5").eq(1).animate({opacity:".2"},200,function(){
 	  					$(".Cell7").animate({opacity:".2"},200,function(){
 	  						$(".Cell9").animate({opacity:".2"},200,function(){
 	  							});
 	  						$(".Cell9").animate({opacity:"1"},400);
 	  						$.unblockUI();
 	  						});
 	  					$(".Cell7").animate({opacity:"1"},400);
 	  					});
 	  				$(".Cell5").eq(1).animate({opacity:"1"},400);
 	  				});
 	  			$(".Cell4").animate({opacity:"1"},400);
 	  			$(".Cell4 .ImageOverlay").animate({opacity:"1"},600,function(){$(this).animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});}); 
 	  			});
 	  		$(".Cell3").animate({opacity:"1"},400);
 	  		$(".Cell3 .ImageOverlay").animate({opacity:"1"},600,function(){$(this).animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});}); 
 	  		});
 	  	$(".Cell2").animate({opacity:"1"},400);
 	  	$(".Cell2 .ImageOverlay").animate({opacity:"1"},600,function(){$(this).animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});}); 
 	  	});
 	  $(".Cell1").animate({opacity:"1"},400); 
    $(".Cell1 .ImageOverlay").animate({opacity:"1"},600,function(){$(this).animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});}); 	   
   }
  else
   {
 	  $(".Cell1,.Cell2,.Cell3,.Cell4,.Cell5").css("opacity","0");   
 	  $(".Cell1").animate({opacity:".2"},200,function(){
 	  	$(".Cell2").animate({opacity:".2"},200,function(){
 	  		$(".Cell3").animate({opacity:".2"},200,function(){
 	  			$(".Cell4").animate({opacity:".2"},200,function(){
 	  				$(".Cell5").eq(1).animate({opacity:".2"},200,function(){
 	  				 $(".Cell5").eq(1).animate({opacity:"1"},400,function(){$(".Cell5").eq(0).animate({opacity:".3"},400,function(){
 	  				 	 
 	  				 	  $('.scroll-pane').jScrollPane({animateTo:true});
 	  				 	 });
 	  				 	});
 	  				  $.unblockUI();
 	  				 });
 	  			$(".Cell4").animate({opacity:"1"},400);
 	  			$(".Cell4 .ImageOverlay").animate({opacity:"1"},600,function(){$(this).animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});}); 
 	  			});
 	  		$(".Cell3").animate({opacity:"1"},400);
 	  		$(".Cell3 .ImageOverlay").animate({opacity:"1"},600,function(){$(this).animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});}); 
 	  		});
 	  	$(".Cell2").animate({opacity:"1"},400);
 	  	$(".Cell2 .ImageOverlay").animate({opacity:"1"},600,function(){$(this).animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});}); 
 	  	});
 	  $(".Cell1").animate({opacity:"1"},400); 
    $(".Cell1 .ImageOverlay").animate({opacity:"1"},600,function(){$(this).animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});}); 	   
    });
   } 
 }
 
}


/* 
---------------------------------------------------------------------------------------------------
FUNCTION PAGEANIMATE TO DELEGATE PAGE REFRESH ANIMATIONS
---------------------------------------------------------------------------------------------------
*/

function PageAnimate()
 {
  
  if($(".Navigation1").length==0 && location.href.indexOf("#")<0 && (location.href.indexOf("Contact")<0 && location.href.indexOf("Disclaimer")<0 && location.href.indexOf("Terms")<0))
   {

    $(".BodyBg,.SiteMaster,.Cell1,.Cell2,.Cell3,.Cell4,.Cell5,.Cell7,.Cell9,.Header h1,.NavMaster").css("opacity","0");    
    $.blockUI();                          
    $("#Preloader").show();
    PreloadImages();
    $(".BodyBg").animate({opacity:"1"},800,function(){
     $(".SiteMaster").animate({opacity:"1"},{duration:600,easing:"easeInQuad",complete:function(){
      $(".Header h1").animate({opacity:"1"},{duration:400,easing:"easeInQuad",complete:function(){
       $(".NavMaster").animate({opacity:"1"},{duration:400,easing:"easeInQuad",complete:function(){
          ToggleNavigation0("Open");
          $(".Cell1").animate({opacity:"1"},400,function(){
           $(".Cell2").animate({opacity:"1"},400,function(){
            $(".Cell3").animate({opacity:"1"},400,function(){
             $(".Cell4").animate({opacity:"1"},400,function(){
              $(".Cell5").eq(1).animate({opacity:"1"},400,function(){
               $(".Cell5").eq(0).animate({opacity:".3"},400,function(){
                $(".Cell7").animate({opacity:"1"},400,function(){
                 $(".Cell9").animate({opacity:"1"},400,function(){
                  $.unblockUI();
                  $(".Cell1 .ImageOverlay").animate({opacity:"1"},{duration:500,easing:"easeInQuad",complete:function(){
                   $(".Cell1 .ImageOverlay").animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});
                   $(".Cell2 .ImageOverlay").animate({opacity:"1"},{duration:500,easing:"easeInQuad",complete:function(){
                    $(".Cell2 .ImageOverlay").animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});
                    $(".Cell3 .ImageOverlay").animate({opacity:"1"},{duration:500,easing:"easeInQuad",complete:function(){
                     $(".Cell3 .ImageOverlay").animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});
                     $(".Cell4 .ImageOverlay").animate({opacity:"1"},{duration:500,easing:"easeInQuad",complete:function(){
                      $(".Cell4 .ImageOverlay").animate({opacity:"0"},{duration:400,easing:"easeOutQuad"});
                     }});
                    }});
                   }});
                  }});
                 });
                });
               });
              });
             });
            });
           });
          });
       }});
      }});
     }});
    }); 
   }

  if($(".Navigation1").length==0 && location.href.indexOf("#")<0 && (location.href.indexOf("Contact")>=0 || location.href.indexOf("Disclaimer")>=0 || location.href.indexOf("Terms")>=0))
   {
    $(".Cell4x4,.TextContent").css({opacity:"1",zIndex:"300"});
    $(".BodyBg,.SiteMaster,.Cell1,.Cell2,.Cell3,.Cell4,.Cell5").css("opacity","0"); 
   
    $(".ContentGrid").css("opacity",".9");
    $(".TextContent").css("zIndex","300");
    $.blockUI();                          
    $("#Preloader").show();
    PreloadImages();
    $(".BodyBg").animate({opacity:"1"},800,function(){
     $(".SiteMaster").animate({opacity:"1"},{duration:600,easing:"easeInQuad",complete:function(){
      $(".Cell1").animate({opacity:"1"},400,function(){
  	   $(".Cell2").animate({opacity:"1"},400,function(){
  	  	$(".Cell3").animate({opacity:"1"},400,function(){
  	  	 $(".Cell4").animate({opacity:"1"},400,function(){
  	  	  $(".Cell5").eq(1).animate({opacity:"1"},400,function(){
  	  	   $(".Cell5").eq(0).animate({opacity:".3"},400,function(){
            $.unblockUI();
            $(".Cell1 .ImageOverlay").animate({opacity:"1"},{duration:500,easing:"easeOutQuad",complete:function(){
             $(".Cell1 .ImageOverlay").animate({opacity:"0"},{duration:300,easing:"easeInQuad"});
             $(".Cell2 .ImageOverlay").animate({opacity:"1"},{duration:500,easing:"easeOutQuad",complete:function(){
              $(".Cell2 .ImageOverlay").animate({opacity:"0"},{duration:300,easing:"easeInQuad"});
              $(".Cell3 .ImageOverlay").animate({opacity:"1"},{duration:500,easing:"easeOutQuad",complete:function(){
               $(".Cell3 .ImageOverlay").animate({opacity:"0"},{duration:300,easing:"easeInQuad"});
               $(".Cell4 .ImageOverlay").animate({opacity:"1"},{duration:500,easing:"easeOutQuad",complete:function(){
                $(".Cell4 .ImageOverlay").animate({opacity:"0"},{duration:300,easing:"easeInQuad"});
               }});
              }});
             }});
            }});
  	  	   });
  	  	  });
  	     });
  	    });
       });
      });
     }});
    });
   }

  if($(".Navigation1").length>0 && location.href.indexOf("#")<0 && (location.href.indexOf("Contact")<0 && location.href.indexOf("Disclaimer")<0 && location.href.indexOf("Terms")<0))
   {
    $.blockUI();
    $(".BodyBg,.SiteMaster,.Cell3,.Cell6,.Cell9").css("opacity","0"); 
    $(".Cell").eq(0).css({width:"317px",overflow:"hidden"});	
    $(".Cell3,.Cell6,.Cell9").css({opacity:"0"});
    $(".Cell2x3,.Cell2x3 img,ul,p,h2").css({opacity:"1"});
    $(".Cell2x3").css({left:"-645px",opacity:"1"});                         
    $("#Preloader").show();
    PreloadImages();
    $(".BodyBg").animate({opacity:"1"},800,function(){
     $(".SiteMaster").animate({opacity:"1"},{duration:600,easing:"easeInQuad",complete:function(){
      $(".Cell3").animate({opacity:"1"},400,function(){
       $(".Cell6").animate({opacity:"1"},400,function(){
        $(".Cell9").animate({opacity:"1"},400,function(){
         $.unblockUI();
     	 		$(".jScrollPaneDrag").css({opacity:"1",zIndex:"700"});  
	 		    $(".jScrollPaneTrack").css({opacity:"1",zIndex:"600"});
	 		    $(".jScrollArrowUp").css({opacity:"1",zIndex:"600"}); 
          $(".jScrollArrowDown").css({opacity:"1",zIndex:"600"});	 
          $(".Cell2x3").animate({left:"1px"},{duration:800,easing:"easeOutQuart",complete:function(){
          $(".Cell3 .ImageOverlay").animate({opacity:"1"},{duration:500,easing:"easeOutQuad",complete:function(){
           $(".Cell3 .ImageOverlay").animate({opacity:"0"},{duration:300,easing:"easeInQuad"});
            $(".Cell6 .ImageOverlay").animate({opacity:"1"},{duration:500,easing:"easeOutQuad",complete:function(){
             $(".Cell6 .ImageOverlay").animate({opacity:"0"},{duration:300,easing:"easeInQuad"});
             $(".Cell9 .ImageOverlay").animate({opacity:"1"},{duration:500,easing:"easeOutQuad",complete:function(){
              $(".Cell9 .ImageOverlay").animate({opacity:"0"},{duration:300,easing:"easeInQuad"});
             }});
            }});
           }});         
         }}); 
        });
       });
      });
     }});
    });  
   } 
 ToggleNavigation0("Open");
}


/* 
---------------------------------------------------------------------------------------------------
FUNCTION PRELOADIMAGES CHECKS IF ALL THE IMAGES OF A PAGE ARE LOADED
---------------------------------------------------------------------------------------------------
*/

var ImagesLoaded=0; 
function PreloadImages()
 {
   if(ImagesLoaded+1==$("img").length)
    {
     $("img").eq(ImagesLoaded).load(function(){$("#Preloader").fadeOut("slow");});
     return;
    }
   else
    {
  	 ImagesLoaded=ImagesLoaded+1;
  	 PreloadImages();
    }
 }

/* 
---------------------------------------------------------------------------------------------------
FUNCTION ASSIGNROLLOVERS
---------------------------------------------------------------------------------------------------
*/ 

function AssignRollOvers(NavClass)
 {
  $(NavClass+" li")
  .bind("mouseover", function(e)
  {
  $(this).find("ul").css("display","block");
  }
  )
  .bind("mouseout", function(e)
  {
  $(this).find("ul").css("display","none");
  }
  );
  
  $(NavClass+" li a")
  .bind("mouseover", function(e)
  {
  Active=$(this).find("img").attr("src");
  if(Active.indexOf("Active")<=-1)
  {
  Active=Active.replace("_en","Active_en");
  $(this).find("img").attr("src",Active);
  IsActive=1;
  }
  }
  );
  
  $(NavClass+" li a")
  .bind("mouseout", function(e)
  {
  Active=$(this).find("img").attr("src");
  if(IsActive==1)
  {
  Active=Active.replace("Active_en","_en");
  $(this).find("img").attr("src",Active);
  IsActive=0;
  }
  }
  );
  
  $(".Lang a")
  .bind("mouseover", function(e)
  {
   Active=$(this).find("img").attr("src");
   Active=Active.replace("_ar","Active_ar");
   $(this).find("img").attr("src",Active);
  });

  $(".Lang a")
  .bind("mouseout", function(e)
  {
   Active=$(this).find("img").attr("src");
   Active=Active.replace("Active_ar","_ar");
   $(this).find("img").attr("src",Active);
  });


 } 
 
 
/* 
---------------------------------------------------------------------------------------------------
FUNCTION ASSIGNROLLOVERS
---------------------------------------------------------------------------------------------------
*/ 

 var positionPage=function(){
 var $currScene = $(".SiteMaster");
 var x = parseInt($currScene.css('left'));
 var y = parseInt($currScene.css('top'));
 var X = x-($(window).width() - $currScene.width())/2;
 var Y = y-($(window).height() - $currScene.height())/2;
 if($(window).width() < 1024 || $(window).height() < 600)
  {
  $(".Master").css({width:980,height:630});
  $currScene.css({marginTop:0,top:'0',marginLeft:0,left:'10'});
  }
 if($(window).width() >= 1024 || $(window).height() >= 600)
  {
  $(".Master").css({width:'100%',height:'100%'});  
  $currScene.css({marginTop:'-310px',top:'50%',marginLeft:'-480px',left:'50%'});
  }
 }
 
 
function ChangeLang()
{
 $(".Lang").eq(0).find("a")
 .bind("click",function(){

   if(location.href.indexOf("#")>=0)
    {
     Deeplink=location.href.split("#")[1].replace("en_gb","ar_ae");
     location.href=HostAddress+Deeplink;
    }
   else
   	 location.href=location.href.replace("en_gb","ar_ae");
 return false;	
  });
}
 
function AnchorScroll()
 {
 	$(".scroll-pane").eq(0).find("a").unbind();
 	
  $(".scroll-pane").eq(0).find("a").
  bind("click",function(){
  	
   if($(this).attr("rel")=="Top")
    $(".scroll-pane")[0].scrollTo(0);
   else
    {
     var YParent=parseInt($(".scroll-pane").eq(0).offset().top);
     var yElement=parseInt($(".scroll-pane").eq(0).find("a[name='"+$(this).attr("rel")+"']").offset().top);  
     $(".scroll-pane")[0].scrollBy(yElement-YParent);
    }
   return false;  	
  }); 
  

 }
 
 
function VisitParent()
 {
   $(".Cell1 .Content").css({cursor:"pointer"});
   $(".Cell1 .Content").unbind();
   $(".Cell1 .Content")
   .bind("click",function(){  	
  	 if($(".Preview img").eq(0).attr("alt")=="Aboutus")
  	 {
  	  CurrentSection="Aboutus";
  	  $(".Navigation0 li a").eq(1).trigger('click');
     }
     
     if($(".Preview img").eq(0).attr("alt")=="Expertise")
     {
      CurrentSection="Expertise";
      $(".Navigation0 li a").eq(2).trigger('click');
     }
     if($(".Preview img").eq(0).attr("alt")=="Media")
     {
      CurrentSection="Media";
      $(".Navigation0 li a").eq(4).trigger('click');
     }
     if($(".Preview img").eq(0).attr("alt")=="Projects")
     {
      CurrentSection="Projects";
      $(".Navigation0 li a").eq(3).trigger('click');
     }
    
   });   
 
 } 