/* ---------------------------
* _abc 
* JSON object contains all 
* code used across the abc
--------------------------- */

var _abc = {
	
	/* ---------------------------
	* globals 
	* every page load
	--------------------------- */
	
	global : {
		
		init : function() {
			this.logo_link();
			this.dropdown();
			this.sub_nav_div();
			this.breadcrumbs();
		},
		
		dropdown : function() {
			$('ul#main_nav').nmcDropDown();
			$('ul#main_nav ul').hover(function() {
				$(this).parent('li').find('a:first').addClass('current');
			}, function() {
				$(this).parent('li').find('a:first').removeClass('current');
			});
		},
		
		sub_nav_div : function() {
			$('#section_nav li').each(function(i) {
				if ($(this).is(':last-child')) {
					$(this).addClass('current');
				}
				else {
					$(this).after('<li>&bull;</li>');
				}
			});			
		},
		
		breadcrumbs : function() {
			$('#breadcrumbs li').each(function(i) {
				if ($(this).is(':last-child')) {
					$(this).addClass('current');
				}
				else {
					$(this).after('<li>&raquo;</li>');
				}
			});
		},
		
		logo_link : function() {
			$('div#logo').css('cursor','pointer').bind('click', function() {
				window.location = '/';
			});
		}
		
	}, // global
	
	home : function() {
		$('#slideshow').cycle({
			slideExpr: 'img',
			pager: '#slideshow_nav',
			fit: 1,
			timeout: 6000
		});
        // Array of filename of images and href to the brand
        var callJewel = [                                
                            {    'image':'homepage_callout_ECourtney.jpg',
'href':'/index.jsp?comp=877&content=abcLite&menu=43&section=430&title=null&articleId=4995&refferer=main&ref=Designers#'


                            },
                            {    'image':'homepage_callout_HonFire2.jpg',
'href':'/index.jsp?comp=877&content=abcLite&menu=43&section=430&title=null&articleId=4996&refferer=main&ref=Designers#'


                            },
                            {    'image':'homepage_callout_kwiat.jpg',
'href':'/index.jsp?comp=877&content=abcIframe&menu=43&section=430&title=null&articleId=4997&refferer=main&ref=Designers#'


                            },
                            {    'image':'Mikimoto_jewelry_callout.jpg',
'href':'/index.jsp?comp=877&content=abcIframe&menu=43&section=430&title=null&articleId=4998&refferer=main&ref=Designers#'


                            },

                            {    'image':'homepage_callout_Rcoin.jpg',
'href':'/index.jsp?comp=877&content=abcIframe&menu=43&section=430&title=null&articleId=4999&refferer=main&ref=Designers#'


                            },
                            {    'image':'homepage_callout_Rosato.jpg',
'href':'/index.jsp?comp=877&content=abcLite&menu=43&section=430&title=null&articleId=5000&refferer=main&ref=Designers#'


                            },
                            {    'image':'homepage_callout_SBlaine.jpg',
'href':'/index.jsp?comp=877&content=abcLite&menu=43&section=430&title=null&articleId=5001&refferer=main&ref=Designers#'


                            },
                            {    'image':'homepage_callout_Suwa.jpg',
'href':'/index.jsp?comp=877&content=abcLite&menu=43&section=430&title=null&articleId=5111&refferer=main&ref=Designers#'


                            }
                        ];
                        
                        
        var callWatch = [    {    'image':'homepage_callout_Chanel.jpg',
                                'href':'/index.jsp?comp=877&content=abcLite&menu=43&section=429&title=null&articleId=4986&refferer=main&ref=Watches#'
                            },
                            {    'image':'homepage_callout_Hermes.jpg',
                                'href':'/index.jsp?comp=877&content=abcLite&menu=43&section=429&title=null&articleId=4988&refferer=main&ref=Watches#'
                            },
                            {    'image':'homepage_callout_MontBlanc.jpg',
                                'href':'/index.jsp?comp=877&content=abcLite&menu=43&section=429&title=null&articleId=4989&refferer=main&ref=Watches#'
                            },
                            {    'image':'homepage_callout_Panerai.jpg',
                                'href':'/index.jsp?comp=877&content=abcLite&menu=43&section=429&title=null&articleId=4990&refferer=main&ref=Watches#'
                            },
                            {    'image':'homepage_callout_TagH.jpg',
                                'href':'/index.jsp?comp=877&content=abcLite&menu=43&section=429&title=null&articleId=4992&refferer=main&ref=Watches#'
                            }

                        ];
        
        randomImage(callJewel,'#callout1');
        randomImage(callWatch,'#callout2');
        
        //randomImage function takes Parameters array and the div that is to be targeted.the div or class should be passed with # or .
        function randomImage(arr,id){
                
            var i = arr.length;
            var j = Math.floor(Math.random() * i);
            var newSrc='images/'+ arr[j]['image'];
            $(id).attr('src',newSrc);
            $(id).parent('a').attr('href',arr[j]['href']);
        
        }
	},
	
	about : {
		
		history : function() {
			//History Cylcle
			$('#slideshow').cycle({
				slideExpr: '.slides',
				pager: '#timeline',
				fx:'fade',
				fit: 1,
				timeout:  7000,
				before:function(){
					$('#timeline li a.activeSlide').parent('li').removeClass('active');
				},
				after:function(){
					$('#timeline li a.activeSlide').parent('li').addClass('active');
				},
				pagerAnchorBuilder: function(idx, slide) {
					return '#timeline li:eq(' + idx + ') a';
				}

			});
			//History Colorbox
			$.getScript('/js/jquery.colorbox.min.js', function() {
				$("a[rel='lightbox']").colorbox({
					onOpen:function(){$('#inner_wrapper #slideshow').cycle('pause');},
					onClosed:function(){$('#inner_wrapper #slideshow').cycle('resume',true);}
				});
				
			});
		},
		
		services_tooltip : function() {
			
			var text = null;
			
			$("a.tooltip").hover(function() { 
					text = $(this).attr('title');
					$('<div class="tooltip_wrapper"></div>').appendTo('body').html(text); 
					$(this).attr('title', '');
				}, function() { 
					$('div.tooltip_wrapper').remove();
					$(this).attr('title', text);
			});
			
			$("a.tooltip").mousemove(function(e) {
				
				var mousex = e.pageX + 10;
				var mousey = e.pageY + 5;
				
				$('div.tooltip_wrapper').css({ 
					top: mousey, 
					left: mousex 
				});
				
			});
		},
		
		services_modal : function() {
			$.getScript('/js/jquery.qtip.min.js', function() {	
				$('a[rel="modal"]').each(function() {
					$(this).qtip({
						content: {
							title: { 
								text: $(this).parent('li').find('span:first').text(),
								button: 'close'
							},
							text: $(this).parent('li').find('div:first').html()
						},
						position: {
							target: $(document.body), // Position it via the document body...
							corner: 'center' // ...at the center of the viewport
						},
						show: {
							when: 'click',
							solo: true // And hide all other tooltips
						},
						hide: false,
						style: {
							width: { max: 800 },
							padding: '14px',
							border: {
								width: 0
							},
							name: 'light',
							title: {
								'background-color':'#439BCB',
								'color':'#fff'
							}
						},
						api: {
							beforeShow: function() {
								$('#qtip-blanket').fadeIn(this.options.show.effect.length);
							},
							beforeHide: function() {
								$('#qtip-blanket').fadeOut(this.options.hide.effect.length);
							}
						}
					});
				});
				$('<div id="qtip-blanket">').css({
					position: 'absolute',
					top: $(document).scrollTop(),
					left: 0,
					height: $(document).height(),
					width: '100%',
					opacity: 0.7,
					backgroundColor: 'black',
					zIndex: 5000
				}).appendTo(document.body).hide().click(function() {
					$('a[rel="modal"]').qtip('hide');
					$('#qtip-blanket').fadeOut();
				});
			});
		}
	},
	
	catalog : function() {
		$('#slideshow').cycle({
			slideExpr: 'img',
			pager: '#slideshow_nav',
			fit: 1
		});
	},
	
	ads : {
		
		init : function() {
			this.cycle();
			this.enlarge();
		},
		
		cycle : function() {
			$('#carousel_container').cycle({
				fx: 'scrollHorz',
				next: '#btn_next',
				prev: '#btn_prev',
				timeout: 0
			});
		},
		
		enlarge : function() {
			$.getScript('/js/jquery.colorbox.min.js', function() {
				$("a[rel*='lightbox']").colorbox();
			});
		}	
		
	},
	
	video : function() {
		$('#carousel_container').cycle({
			fx: 'scrollHorz',
			next: '#carousel_container #btn_next',
			prev: '#carousel_container #btn_prev',
			timeout: 0
		});
	},
	
	locations_contact : function() {
		$.getScript('/js/jquery.colorbox.min.js', function() {
			$("a[rel*='store']").colorbox();
		});
	},
	
	catalogs : function() {
		$.getScript('/js/jquery.colorbox.min.js', function() {
			$("a[rel='lightbox']").colorbox({
				width:"95%", 
				height:"95%", 
				iframe:true
			});
		});
	}
	
};

// init globals as soon the dom is ready
$(function() {
	_abc.global.init();
});

// includes below

/**
 * nmcDropDown plugin - v1.0.4
 * Author: Eli Van Zoeren
 * Copyright (c) 2009 New Media Campaigns
 * http://www.newmediacampaigns.com 
 **/
(function(a){a.fn.nmcDropDown=function(b){var c=a.extend({},a.fn.nmcDropDown.defaults,b);return this.each(function(){var menu=a(this);submenus=menu.children("li:has("+c.submenu_selector+")");if(c.fix_IE){menu.css("z-index",51).parents().each(function(d){if(a(this).css("position")=="relative"){a(this).css("z-index",(d+52))}});submenus.children(c.submenu_selector).css("z-index",50)}over=function(){a(this).addClass(c.active_class).children(c.submenu_selector).animate(c.show,c.show_speed);return false};out=function(){a(this).removeClass(c.active_class).children(c.submenu_selector).animate(c.hide,c.hide_speed);return false};if(c.trigger=="click"){submenus.toggle(over,out).children(c.submenu_selector).hide()}else{if(a().hoverIntent){submenus.hoverIntent({interval:c.show_delay,over:over,timeout:c.hide_delay,out:out}).children(c.submenu_selector).hide()}else{submenus.hover(over,out).children(c.submenu_selector).hide()}}})};a.fn.nmcDropDown.defaults={trigger:"hover",active_class:"open",submenu_selector:"ul",show:{opacity:"show"},show_speed:300,show_delay:50,hide:{opacity:"hide"},hide_speed:200,hide_delay:100,fix_IE:true}})(jQuery);
