jQuery.noConflict();
jQuery(document).ready(function(){
	jQuery(function(){

		// initialise plugins megamenu
        jQuery(".megamenu").megamenu({'justify':'right'});
			/*var SelfLocation = window.location.href.split('?');
       		switch (SelfLocation[1]) {
	         	case "justify_right":
	            jQuery(".megamenu").megamenu({ 'justify':'right' });
	            break;
	          	case "justify_left":
	          	default:
	            jQuery(".megamenu").megamenu();
	        	}*/

		// initialise plugins superfish
		jQuery('ul.sf-menu').superfish();
    
 		// initialise plugins superSlider
		//jQuery('.ifocus').superSlider();
		
		// initialise plugins cycle.all
		jQuery('.fotoshow').cycle({fx: 'fade'});

		// initialise plugins anythingSlider
		jQuery('#slider1').anythingSlider({
			// Appearance
  			width               : '360',      // Override the default CSS width
  			height              : '130',      // Override the default CSS height
  			theme      		  : 'metallic',
			themeDirectory      : 'css/anythingslider/theme-{themeName}.css', // Theme directory & filename {themeName} is replaced by the theme value above
   			//startPanel        : 0,
			toggleControls      : false,     // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times
			//tooltipClass      : 'tooltip', // Class added to navigation & start/stop button (text copied to title if it is hidden by a negative text indent)
			enableKeyboard      : false,      // if false, keyboard arrow keys will not work for the current panel.
			buildNavigation     : false,      // If true, builds a list of anchor links to link to each panel
			buildArrows         : true,      // If true, builds the forwards and backwards buttons
			resizeContents      : true,      // If true, solitary images/objects in the panel will expand to fit the viewport
			enablePlay          : true,      // if false, the play/stop button will still be visible, but not clickable.
			autoPlay            : true,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
			startStopped 	  : false,     // If autoPlay is on, this can force it to start stopped
			startText		: ' ', // Start button text
			stopText		: ' ', // Stop button text 
			navigationFormatter : function(index, panel){
			return " Panel #" + index; // This would have each tab with the text ‘Panel #X’ where X = index
			}
		 });

			//
			jQuery(".gallery").colorbox({rel:'gallery'});

		//initialise plugins Ââåðõ è êîíòàêòû
		var scrollDiv = document.createElement('div');
		var scrollDivUp = document.createElement('div');
		var scrollDivBasket = document.createElement('div');
		jQuery(scrollDiv).attr('id', 'toTop').html('^ Ââåðõ').appendTo('body');
		jQuery(scrollDivUp).attr('id', 'upTop').html('<a href=\'?show_aux_page=2\'>ICQ:&nbsp;454975707&nbsp;skype:slonik.biz&nbsp;</a>').appendTo('body');
		jQuery(scrollDivBasket).attr('id', 'basket_img').html('<a href=\'?shopping_cart=yes\'><img src=\'images/cart_link.png\' border=\'0\'></a>').appendTo('body');

		jQuery(window).scroll(function () {
		        if (jQuery(this).scrollTop() != 0) {
		        jQuery('#toTop').fadeIn();
				jQuery('#upTop').fadeIn();
				jQuery('#basket_img').fadeIn();
		        } else {
		        jQuery('#toTop').fadeOut();
				jQuery('#upTop').fadeOut();
				jQuery('#basket_img').fadeOut();
		        }
		    });
		    jQuery('#toTop').click(function () {
		        jQuery('body,html').animate({scrollTop: 0},800);
		    });
		});
	
	});
	
	function search_cat(){
       var agt = navigator.userAgent.toLowerCase();
       var is_bsd   = (agt.indexOf("bsd") != -1);
       var is_x11   = (agt.indexOf("x11") != -1);
       var is_linux = (agt.indexOf("linux") != -1);
       var is_mac   = (agt.indexOf("mac") != -1);
       obj = document.getElementById('search_form_adv').style;
       if ( is_bsd || is_x11 || is_linux || is_mac ) {
             obj.top = '20px';
       }
       obj.display = (obj.display != 'block' ? 'block' : 'none');
}
	function search_google(){
       var agt = navigator.userAgent.toLowerCase();
       var is_bsd   = (agt.indexOf("bsd") != -1);
       var is_x11   = (agt.indexOf("x11") != -1);
       var is_linux = (agt.indexOf("linux") != -1);
       var is_mac   = (agt.indexOf("mac") != -1);
       obj = document.getElementById('cse_google').style;
       if ( is_bsd || is_x11 || is_linux || is_mac ) {
             obj.top = '20px';
       }
       obj.display = (obj.display != 'block' ? 'block' : 'none');
}


	function open_window(link,w,h){ //opens new window
		var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
		newWin = window.open(link,'newWin',win);
		newWin.focus();
	}

	function open_printable_version(link) //opens new window
	{
		var win = "menubar=no,location=no,resizable=yes,scrollbars=yes";
		newWin = window.open(link,'perintableWin',win);
		newWin.focus();
	}

	function confirmDelete(id, ask, url){ //confirm order delete
		temp = window.confirm(ask);
		if (temp) //delete
		{
			window.location=url+id;
		}
	}

	

	function confirmUnsubscribe() //unsubscription confirmation
	{
		temp = window.confirm('{/literal}{$smarty.const.QUESTION_UNSUBSCRIBE}{literal}');
		if (temp) //delete
		{
			window.location="index.php?killuser=yes";
		}
	}

	function validate(){ // newsletter subscription form validation
		if (document.subscription_form.email.value.length<1){
			alert("{/literal}{$smarty.const.ERROR_INPUT_EMAIL}{literal}");
			return false;
		}
		if (document.subscription_form.email.value == 'Email'){
			alert("{/literal}{$smarty.const.ERROR_INPUT_EMAIL}{literal}");
			return false;
		}
		return true;
	}
	function validate_disc() // review form verification
	{
		if (document.formD.nick.value.length<1)
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_NICKNAME}{literal}");
			return false;
		}

		if (document.formD.topic.value.length<1)
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_MESSAGE_SUBJECT}{literal}");
			return false;
		}

		return true;
	}
	function validate_search()
	{

		if (document.Sform.price1.value!="" && ((document.Sform.price1.value < 0) || isNaN(document.Sform.price1.value)))
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_PRICE}{literal}");
			return false;
		}
		if (document.Sform.price2.value!="" && ((document.Sform.price2.value < 0) || isNaN(document.Sform.price2.value)))
		{
			alert("{/literal}{$smarty.const.ERROR_INPUT_PRICE}{literal}");
			return false;
		}

		return true;
	}


