function showhide() { //v9.0
  var i,p,v,obj,args=showhide.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	obj.visibility=v; 
	}
}


/*top navigation*/
jQuery(document).ready(function () {	
	
	jQuery('#top_nav li').hover(
		function () {
			//show its submenu
			jQuery('ul', this).slideDown(200);
			jQuery('.language_details').hide(50);
	 		jQuery('.cart_details').hide(50);

		}, 
		function () {
			//hide its submenu
			jQuery('ul', this).slideUp(100);			
		}
	);
	
});


/*navigation*/
jQuery(document).ready(function () {	
	
	jQuery('#nav li').hover(
		function () {
			//show its submenu
			jQuery('ul', this).slideDown(200);
		}, 
		function () {
			//hide its submenu
			jQuery('ul', this).slideUp(100);			
		}
	);
	
});


/*statistics*/
function review_stats() {  
  jQuery('.stats').hover(
    function () {
      jQuery('.stats_box', this).fadeIn(200);
    }, 
    function () {
      jQuery('.stats_box', this).fadeOut(100);
    }
  );
  
};


/*language and currency*/
jQuery(document).ready(function () {  
  
  
  jQuery('.language_currency_summary').click(
    function () {
      jQuery('.language_details').slideToggle(50);
	    jQuery('.cart_details').hide(50);
	    jQuery('.login_box').hide(50);
    }
  );
  
  jQuery('.language_currency_close').click(function () {
      jQuery('.language_details').slideToggle(50);
    }
  );  
   
   	//Cart Script begin
	cart_update();
	
	jQuery('.add_to_cart').click(function(){
		var pid = jQuery(this).attr('pid');
		cart_add(pid);	
	});
	
	jQuery('.remove_from_cart').click(function(){
		var pid = jQuery(this).attr('pid');
		cart_remove(pid)
	});	
	
	jQuery('#cart_img').click(function(){
		jQuery('.cart_details').slideToggle(50);
		jQuery('.language_details').hide(50);
		jQuery('.login_box').hide(50);
	});   
	//Cart Script End
  
});

//Cart Functions Begin
function cart_remove(pid){
	jQuery.post('/cart/remove',{pid:pid},function(data){
		if(data == 'OK'){
			var occ = jQuery('#cc').html().replace(/\(|\)/g, "");
			occ = parseInt(occ)-1;
			jQuery('#cc').html('('+occ+')');
		}else{
			alert('Error removing from cart');
		}
	});	
	cart_update();
}

function cart_add(pid){
	jQuery.post('/cart/add',{pid:pid},function(data){
		if(data == 'OK'){
			var occ = jQuery('#cc').html().replace(/\(|\)/g, "");
			occ = parseInt(occ)+1;
			jQuery('#cc').html('('+occ+')');
		}else{
			alert('Error adding to cart');
		}
	});
	cart_update();		
}

function cart_update(){
	jQuery.post('/cart/get',function(data){
		if(data){
			var result = eval('('+ data +')');
			
			jQuery('#cc').html('('+result[0]+')');
			jQuery('.cart_details').html(result[1]);
			jQuery('a.remove_from_cart').click(function(){
				var pid = jQuery(this).attr('pid');
				cart_remove(pid);	
			});
			
			if(result[0] > 0) jQuery('#cart').show();
			else jQuery('#cart').hide(); 			
		} 
	});		
}
//Cart Functions End


/*login*/
jQuery(document).ready(function () {  
  
  jQuery('.login_btn').click(
    function () {
      jQuery('.login_box').slideToggle(50);
      jQuery('.language_details').hide(50);
      jQuery('.cart_details').hide(50);
    }
  );
  
  jQuery('.login_close_btn').click(
    function () {
      jQuery('.login_box').slideToggle(50);
    }
  );  
  
});

/*review slickbox details*/

jQuery(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  jQuery('#review_body_more').hide();
 // shows the slickbox on clicking the noted link  
  jQuery('a#slick-show').click(function() {
    jQuery('#review_body_more').show('slow');
    return false;
  });
 // hides the slickbox on clicking the noted link  
  jQuery('a#slick-hide').click(function() {
    jQuery('#review_body_more').hide('slow');
    return false;
  });
 
 // toggles the slickbox on clicking the noted link  
  jQuery('a#slick-toggle').click(function() {
    jQuery('#review_body_more').toggle(50);
    return false;
  });
});


/*flights details*/

jQuery(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  jQuery('#slickbox').hide();
 // shows the slickbox on clicking the noted link  
  jQuery('a#slick-show').click(function() {
    jQuery('#slickbox').show('slow');
    return false;
  });
 // hides the slickbox on clicking the noted link  
  jQuery('a#slick-hide').click(function() {
    jQuery('#slickbox').hide('slow');
    return false;
  });
 
 // toggles the slickbox on clicking the noted link  
  jQuery('a#slick-toggle').click(function() {
    jQuery('#slickbox').fadeIn(800);
    return false;
  });

  jQuery('.result_flights').click(function() {
    jQuery('#slickbox').fadeIn(800);
    return false;
  });
});
