jQuery.noConflict();
jQuery(window).load(function() {
	try{
		jQuery('#mySlider').nivoSlider({ 
			effect:'fade',
			pauseTime:4000,
			directionNav:false,
			afterLoad: function(){
				jQuery('.nivo-control:not(:first-child):not(:last-child)').hide();
			},
			beforeChange: function(){
				jQuery('#initSlide').fadeOut();
			},
			afterChange: function(){
				if(jQuery('#smovImage').css('display')=='none')
					jQuery('#smovLink').hide();
				else
					jQuery('#smovLink').show();
			}
		});
	} catch(e) {}
	/*jQuery('#slider').nivoSlider({ 
		effect:'random', // Specify sets like: 'fold,fade,sliceDown'
		slices:15, // For slice animations
		boxCols: 8, // For box animations
		boxRows: 4, // For box animations
		animSpeed:500, // Slide transition speed
		pauseTime:3000, // How long each slide will show
		startSlide:0, // Set starting Slide (0 index)
		directionNav:true, // Next & Prev navigation
		directionNavHide:true, // Only show on hover
		controlNav:true, // 1,2,3... navigation
		controlNavThumbs:false, // Use thumbnails for Control Nav
		controlNavThumbsFromRel:false, // Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', // Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
		keyboardNav:true, // Use left & right arrows
		pauseOnHover:true, // Stop animation while hovering
		manualAdvance:false, // Force manual transitions
		captionOpacity:0.8, // Universal caption opacity
		prevText: 'Prev', // Prev directionNav text
		nextText: 'Next', // Next directionNav text
		beforeChange: function(){}, // Triggers before a slide transition
		afterChange: function(){}, // Triggers after a slide transition
		slideshowEnd: function(){}, // Triggers after all slides have been shown
		lastSlide: function(){}, // Triggers when last slide is shown
		afterLoad: function(){} // Triggers when slider has loaded
	});*/
	if(jQuery.browser.msie && jQuery.browser.version <= 8){
		jQuery('.theme-sanmar .nivo-controlNav a').each(function(index, element) {
			jQuery(this).css('background-position',''+index*-25+'px top');
		});
	}
});

jQuery(document).ready(function() {

	if(jQuery.browser.msie && jQuery.browser.version <= 8){
		jQuery('.loginbtn').each(function(){
			jQuery(this).css({'text-indent':'0'});
			jQuery(this).html('');		
		});
	}
	
	nickVideo = jQuery('#smoVideo').html();
	jQuery('#smovLink').click(function(){
		jQuery('#smoVideo').html(nickVideo).dialog('open');
	});
	
	jQuery('#smoVideo').dialog({
		autoOpen:false,
		width: 586,
		height: 363,
		modal: true,
		closeOnEscape:true,
		resizable:false,
		zIndex:10000,
  		beforeClose: function(event, ui) {
  			jQuery(this).html('');
  		}
	}); 
	
});

	    useBSNns = true;
	    		
	    var as_q_options = {
	        script: "/search/getAllLuceneKW7x.jsp?",
	        varname: "query",
	        json: false,
	        delay: 0,
	        timeout: 1800000,
	        maxresults: 25,
	        shownoresults: false,
	        callback: function(obj) {document.quicksrch.submit();}
	        };
	         
	    var as_q = null;
	    function start_bsn_q() {
	        as_q = new bsn.AutoSuggest('searchString', as_q_options);
	        
	    }
	  	    
	    function close_bsn_q() {
		if (as_q != null) {
	             as_q.clearSuggestions();
	        }
	    }
	
	
    function quickSearchHandler(){
       return true;
       /*
    	if ((document.quicksrch.searchString.value.length == 0) || (document.quicksrch.searchString.value.indexOf('style#/name') == 0)) {
        	alert('Search criterion is required.'); 
        	return false;
        } else {
            var isValidated = validateSpecialChar('query');
            if(isValidated == true){           
                return true;
            }else{
            	return false;
            }
        }
       */        
    }
	
	     
    function submitInvCheckFormG() {
        if ((document.ItemInventoryCheckFormG.productid.value.length == 0) || (document.ItemInventoryCheckFormG.productid.value == "enter style #")) {
            alert("style number is required");
            return false;
        }
    }
	

	  
    function validateSearchForm(){
    	
	     var searchString=document.forms["quicksrch"]["searchString"].value;
	     searchString=jQuery.trim(searchString);
	     if(searchString==""){
	        alert("Empty string is not allowed");
	        return false;
	     }	
	     
	     if(searchString=="Search Products and Inventory"){
		    alert("Empty string is not allowed");
		    return false;
		 }	
	     
	     if(searchString.length>100){
		        alert("Search string length exceeds maximum limit(100).\n Please enter a valid string.");
		        return false;
		     }
	     
	     if(containsSpecialChar(searchString)==true)
           return false;
	     
	}
    
   
    function containsSpecialChar(searchString){
     
	    var illegalChars="!@$^*()+=[]\\{}|\:<>?";
	    
	    for(var i=0;i<searchString.length;i++){
		  if(illegalChars.indexOf(searchString.charAt(i) )>-1){
			  alert("Your search has one of the following special characters:\n"+illegalChars+"\nThese are not allowed.\nPlease remove them and try again.");
			  return true;
		  }
		}
       return false;
    } 	  
	  
  function trim(s){
    var l=0; var r=s.length -1;
    while(l < s.length && s[l] == ' ')
    {     l++; }
    while(r > l && s[r] == ' ')
    {     r-=1;     }
    return s.substring(l, r+1);
  } 

  function showLoginModal(){
	     
      document.getElementById("dialog1").style.display="block";

  }

  setTimeout('initVideoGallery()',5000);
  jQuery(document).ready(function(){
  	initVideoGallery();
  });

  function initVideoGallery(){
  	_embedCodes = [];
  	jQuery('.video-popup').each(function(){
  		_i = parseInt(jQuery(this).attr('id').replace('videoPopup',''));
  		_embedCodes[_i] = jQuery(this).html();
  	});

	jQuery('#videosList a').hover(function(){
  		var _aIndex = jQuery(this).parents('li').index();
  		jQuery('#videosGallery img:not(:nth-child('+(_aIndex+1)+'))').hide();
  		jQuery('#videosGallery img:nth-child('+(_aIndex+1)+')').show();
  	});
  	
  	jQuery('#videosGallery img, #videosList li').click(function(){
  		var _aIndex = jQuery(this).index();
  		jQuery('#videoPopup'+(_aIndex+1)+'').html(_embedCodes[_aIndex+1]).dialog('open');
  	});
  	
  	jQuery('.video-popup').dialog({
  		autoOpen:false,
  		width: 400,
  		height: 264,
  		modal: true,
  		closeOnEscape:true,
  		resizable:false,
  		zIndex:10000,
  		beforeClose: function(event, ui) {
  			jQuery(this).html('');
  		}
  	});
  }
