//	createCookie('Main_menu','1');
//  createCookie('Sub_menu_1','1');
//  createCookie('Sub_menu_2','1');
window.addEvent('domready', function(){

///================================================================================================
// High Light Menu Items
            var anchors = document.getElementsByTagName("a");
            for (var i=0; i<anchors.length; i++) {
                var anchor = anchors[i];
                
                var _href ;
                _href =anchor.getAttribute("href").toLowerCase()
                
                var _wind_loc ;
                _wind_loc =window.location.href.toLowerCase()
                
                  //||  (_href.indexOf('default.aspx')>-1 && _wind_loc.indexOf('.')=-1 )
                
                                    
                  // solve submenu of links 
                  
                       if ( _href.indexOf('financial.aspx')>-1  && 
                            ( _wind_loc.indexOf('corporatefinance')>-1  || _wind_loc.indexOf('valuationservices')>-1  
                             || _wind_loc.indexOf('acquisitiondiligence')>-1 || _wind_loc.indexOf('transactionservices')>-1 ) )
                        {
                                    anchor.style.color='green' 
                        }
                        
                        
                        else   if (_href.indexOf('enterpirse.aspx')>-1  && ( _wind_loc.indexOf('riskmanagement')>-1  || _wind_loc.indexOf('internalaudit')>-1  || _wind_loc.indexOf('internalcontrol')>-1 || _wind_loc.indexOf('corporategovernance')>-1 ))
                       {
                             anchor.style.color='green'  
                       }
                       
                       else  if (_href  &&  ((_wind_loc.indexOf("#")>-1 && _href.indexOf("#")>-1) || (_wind_loc.indexOf("#") == -1 && _href.indexOf("#") == -1))  && ( _href == _wind_loc  || _wind_loc.indexOf(_href) >-1    ||  (_href.indexOf('default.aspx')>-1 && _wind_loc.indexOf('.')== -1 )   )) 
                       {
                                /*   if(findParentNode('sub2',anchor)=='sub2')
                                       {
                                            createCookie('Main_menu','myOtherElementt');
                                       }else if ( findParentNode('sub1',anchor)=='sub1')
                                       {
                                            createCookie('Main_menu','myOtherElement');
                                       }
                                       else{
                                             createCookie('Main_menu','aaa');
                                            
                                       }
                                     */         
                         
                                

                          anchor.style.color='Green'
                           //anchor.setAttribute("style",'color:blue')

                  }  
                  
                  
                      if( _wind_loc.indexOf('aboutus.aspx')>-1 ||  _wind_loc.indexOf('vision.aspx')>-1 || _wind_loc.indexOf('global.aspx')>-1 )
                        {
                            createCookie('Main_menu','myOtherElementt');
                        }else if( _wind_loc.indexOf('engineering.aspx')>-1 ||  _wind_loc.indexOf('overview.aspx')>-1 )
                        {
                            createCookie('Main_menu','myOtherElement');
                            
                            createCookie('Sub_menu_1','Sub_menu1');
                            createCookie('Sub_menu_2','aaa');
                            
                        }else if ( _wind_loc.indexOf('financial.aspx')>-1  || _wind_loc.indexOf('enterpirse.aspx')>-1 || _wind_loc.indexOf('consultancy.aspx')>-1  
                            || _wind_loc.indexOf('corporatefinance')>-1  ||_wind_loc.indexOf('valuationservices')>-1  ||_wind_loc.indexOf('acquisitiondiligence')>-1  
                            || _wind_loc.indexOf('transactionservices')>-1   || _wind_loc.indexOf('riskmanagement')>-1  
                            || _wind_loc.indexOf('internalaudit')>-1  ||_wind_loc.indexOf('internalcontrol')>-1  || _wind_loc.indexOf('corporategovernance')>-1  
                        )
                        {
                                 
                             
                            createCookie('Main_menu','myOtherElement');
                            
                            createCookie('Sub_menu_1','aaa');
                            createCookie('Sub_menu_2','Sub_menu2');
                        }
                        else if (_wind_loc.indexOf('audit.aspx')>-1 ) {
                            createCookie('Main_menu','myOtherElement');
                            
                            createCookie('Sub_menu_1','aaa');
                            createCookie('Sub_menu_2','aaa');
                        }else{
                                createCookie('Main_menu','aaa');
                        }          
            }
///================================================================================================
	// js
	/*  function findParentNode(parentName, childObj) {
        var testObj = childObj.parentNode;
       
        while(testObj.id != parentName) {
            
            testObj = testObj.parentNode;
            
        }
        // now you have the object you are looking for - do something with it
      return   testObj.id
     
    }     
	*/   
///================================================================================================
	// Main Menu 
	
	if (__ReadCookie('Main_menu')=='myOtherElementt' ){
            $('myOtherElementt').set('tween', {
				    duration: 1000,
				    transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			    }).tween('height', '120px');
    		   
	}
	else{
	
	    $('myOtherElementt').addEvents({
		    'mouseenter': function(){
			    // Always sets the duration of the tween to 1000 ms and a bouncing transition
			    // And then tweens the height of the element
			    this.set('tween', {
				    duration: 1000,
				    transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			    }).tween('height', '120px');
    			
			    createCookie('Main_menu','myOtherElementt');
			    	
		    },
		    'mouseleave': function(){
			    // Resets the tween and changes the element back to its original size
			    this.set('tween', {}).tween('height', '30px');
			  createCookie('Main_menu','aaa');
		/*
			  createCookie('Sub_menu_1','aaa');
			  createCookie('Sub_menu_2','aaa');
			  */
		    }
	    });
	}
	
	
	
	if (__ReadCookie('Main_menu')=='myOtherElement' )
	{        
		     if (__ReadCookie('Sub_menu_1')=='Sub_menu1' ){
		       
		          $('myOtherElement').set('tween', {
				            duration: 1000,
				            transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			            }).tween('height', '200px');
    		 
		     }else if (__ReadCookie('Sub_menu_2')=='Sub_menu2' )
		     {
		       
		         $('myOtherElement').set('tween', {
				            duration: 1000,
				            transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			            }).tween('height', '260px');
		     }else{
		       
		         $('myOtherElement').set('tween', {
				            duration: 1000,
				            transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			            }).tween('height', '150px');
		     }
		 
			        
	}else{
	
	        $('myOtherElement').addEvents({
		        'mouseenter': function(){
		        
			        // Always sets the duration of the tween to 1000 ms and a bouncing transition
			        // And then tweens the height of the element
			       
			    /*   if (__ReadCookie('Sub_menu_1')=='Sub_menu1' ){
		                  this.set('tween', {
				                    duration: 1000,
				                    transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			                    }).tween('height', '200px');
            		 
		             }else if (__ReadCookie('Sub_menu_2')=='Sub_menu2' )
		             {
		                 this.set('tween', {
				                    duration: 1000,
				                    transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			                    }).tween('height', '260px');
		             }else{*/
		                 this.set('tween', {
				                    duration: 1000,
				                    transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			                    }).tween('height', '150px');
		            /* }*/
		             
		             
			       createCookie('Main_menu','myOtherElement');
		        },
		        'mouseleave': function(){
		        
			        // Resets the tween and changes the element back to its original size
			        this.set('tween', {}).tween('height', '33px');
			         createCookie('Main_menu','aaa');
			       
		        }
	        });
	}
	
	
	
	///================================================================================================
	// sub menues

if (__ReadCookie('Sub_menu_1')=='Sub_menu1' ){
    createCookie('Sub_menu_','Sub_menu1');
}else if (__ReadCookie('Sub_menu_2')=='Sub_menu2' ){
    createCookie('Sub_menu_','Sub_menu2');
}else{
    createCookie('Sub_menu_','aaa');
}



	if (__ReadCookie('Sub_menu_1')=='Sub_menu1' ){
		
		      $('Sub_menu1').set('tween', {
				        duration: 1000,
				        transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			        }).tween('height', '90px');
			
    		   
	}
	else{
	
	
	    $('Sub_menu1').addEvents({
		    'mouseenter': function(){
		    
			    // Always sets the duration of the tween to 1000 ms and a bouncing transition
			    // And then tweens the height of the element
			    
			    if (__ReadCookie('Sub_menu_2')=='Sub_menu2' )
			    {
			            $('myOtherElement').set('tween', {
				            duration: 1000,
				            transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			            }).tween('height', '320px');
			    }else{
			            $('myOtherElement').set('tween', {
				            duration: 1000,
				            transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			            }).tween('height', '200px');
			    }
			    
			    this.set('tween', {
				    duration: 1000,
				    transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			    }).tween('height', '90px');
    			
			    createCookie('Sub_menu_1','Sub_menu1');
		      createCookie('Sub_menu_2','aaa');
			    	
		    },
		    'mouseleave': function(){
		     
			    // Resets the tween and changes the element back to its original size
			    this.set('tween', {}).tween('height', '33px');
			      if (__ReadCookie('Sub_menu_')=='Sub_menu2'){
			    createCookie('Sub_menu_2','Sub_menu2');
			   }
			  
			     if (__ReadCookie('Sub_menu_2')=='Sub_menu2' )
			        {
			                  $('myOtherElement').set('tween', {
				                    duration: 1000,
				                    transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			                    }).tween('height', '260px');
			               // $('myOtherElement').set('tween', {}).tween('height', '260px');
			        //   createCookie('Sub_menu_2','Sub_menu2');
			        }else{
			                $('myOtherElement').set('tween', {
				                    duration: 1000,
				                    transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			                    }).tween('height', '150px');
			              //  $('myOtherElement').set('tween', {}).tween('height', '33px');
			        
			          
			        }
			  createCookie('Sub_menu_1','aaa');
			 
		    }
	    });
	}
	
	
	
	if (__ReadCookie('Sub_menu_2')=='Sub_menu2' )
	{        
		 $('Sub_menu2').set('tween', {
				        duration: 1000,
				        transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			        }).tween('height', '150px');  
			  
	}else{
	
	
	
	        $('Sub_menu2').addEvents({
		        'mouseenter': function(){
			        // Always sets the duration of the tween to 1000 ms and a bouncing transition
			        // And then tweens the height of the element
			        if (__ReadCookie('Sub_menu_1')=='Sub_menu1' )
			        {
			                $('myOtherElement').set('tween', {
				                duration: 1000,
				                transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			                }).tween('height', '320px');
			        }else{
			                $('myOtherElement').set('tween', {
				                duration: 1000,
				                transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			                }).tween('height', '260px');
			        }
			       
			       
			        this.set('tween', {
				        duration: 1000,
				        transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			        }).tween('height', '150px');
        		
			        createCookie('Sub_menu_2','Sub_menu2');
			    createCookie('Sub_menu_1','aaa');
		        },
		        'mouseleave': function(){
		        
			        // Resets the tween and changes the element back to its original size
			        this.set('tween', {}).tween('height', '30px');
			         if (__ReadCookie('Sub_menu_')=='Sub_menu1'){
			        createCookie('Sub_menu_1','Sub_menu1');
			       }
			       
			        if (__ReadCookie('Sub_menu_1')=='Sub_menu1' )
			        {
			                 $('myOtherElement').set('tween', {
				                    duration: 1000,
				                    transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			                    }).tween('height', '200px');
			                    
			                //$('myOtherElement').set('tween', {}).tween('height', '150px');
			              //  createCookie('Sub_menu_1','Sub_menu1');
			        }
			        
			        else{
			             $('myOtherElement').set('tween', {
				                    duration: 1000,
				                    transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			                    }).tween('height', '150px');
			               // $('myOtherElement').set('tween', {}).tween('height', '33px');
			        }
			        
			        
                     createCookie('Sub_menu_2','aaa');
                  
		        }
	        });
	}
	
});







/* Cookies
-----------------------------------------------------------------------------------------------
*/

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function __SetCookie(cname,cvalue,mins) 
                 {
	                if (mins) 
                      {
		                var date = new Date();
		                date.setTime(date.getTime()+(mins*60*1000));
		                var expires ="; expires="+date.toGMTString();
	                  }
	                  else var expires ='';
	                document.cookie = cname+"="+cvalue+expires+"; path=/";
                 }

function __ReadCookie(cname) 
                {
	                var nameEQ = cname +"=";
	                var ca = document.cookie.split(';');
	                for(var i=0;i < ca.length;i++) 
                    {
		                var c = ca[i];
		                while (c.charAt(0)==' ') c = c.substring(1,c.length);
		                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	                }
	                return null;
                }

 function __EraseCookie(cname) 
                {
	                __SetCookie(cname,'',-1);
                }
  function __ResetCookie_(cname) 
                {
	                createCookie(cname,'aaa');
                }               
                
                
             function __ResetCookie(type) 
                {
                    if (type == 'all')
                    {
                        __ResetCookie_('Main_menu');__ResetCookie_('Sub_menu_1');__ResetCookie_('Sub_menu_2');
                    }else if (type == 'main'){
                            __ResetCookie_('Main_menu');
                    
                    }else if (type == 'sub'){
                        __ResetCookie_('Sub_menu_1');__ResetCookie_('Sub_menu_2');
                    
                    }
                    
                }               
                
 
