﻿function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/////////////////////////////////////////////////

$(document).ready(function(){ var Slided = 0;
						   
 //$.preloadCssImages();
	
$('#nav-lang a').fadeTo(500, 0.3);
$('#nav-lang a').hover(function(){ $(this).stop(false, true).fadeTo(300, 1); }, function(){ $(this).stop(false, true).fadeTo(300, 0.5); });
$('#nav-menu a').filter(function (index) { return $(this).attr("rel") != "pt"; }).hover(function(){ $(this).stop(false, true).fadeTo(0,0.5).fadeTo(300,1); }, function(){ $(this).stop(false, true).fadeTo(0,0.7).fadeTo(300,1); });


$('#header-search a').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });

$('.btn a').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });

//home
$('#nav-home-cate a').hover(function(){ $(this).stop(false, true).fadeTo(0,0.5).fadeTo(300,1); }, function(){ $(this).stop(false, true).fadeTo(0,0.7).fadeTo(300,1); });
$('#nav-home-fun a').hover(function(){ $(this).stop(false, true).fadeTo(0,0.5).fadeTo(300,1); }, function(){ $(this).stop(false, true).fadeTo(0,0.7).fadeTo(300,1); });
$('#nav-home-prd #more a').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });
$('#nav-home-prd #img a').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });

//product
$('.prd-item #img a').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });
$('.prd-item #add a').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });
$('.prd-item #details a').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });
$('.nav-prd-cate .prd-cate-sub').hover(function(){ $(this).stop(false, true).fadeTo(0,0.5).fadeTo(200,1); });

$('#imgPhoto').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });

//slideCate
if ($('.nav-prd-cate-sub').is("#showd")) { Slided++; }
$('.nav-prd-cate .prd-cate').click(function(){ 

	if ($(this).find('.nav-prd-cate-sub').is(':hidden')) { 
	
	  if(Slided == 0) { 
	  $('.nav-prd-cate-sub').stop(false, true).slideUp(500); Slided = 0;
	  $(this).find('.nav-prd-cate-sub').stop(false, true).slideDown('fast'); Slided++; }
	  else { 
		$('.nav-prd-cate-sub').stop(false, true).slideUp(500); Slided = 0;
		var that = $(this).find('.nav-prd-cate-sub');
		setTimeout( function(){ $(that).stop(false, true).slideDown('fast'); Slided++; },500); 
	  }
	}
	else {
	//$('.nav-prd-cate-sub').stop(false, true).slideUp(500); Slided = 0; } 
	$(this).find('.nav-prd-cate-sub').stop(false, true).slideUp('slow'); Slided = 0; } 
});

$('.nav-prd-cate .prd-cate').hover(function(){ if($(this).find('.nav-prd-cate-sub').is(':hidden')) $(this).addClass('cateOP');
												else $(this).addClass('cateCL'); }, 
								   function(){ $(this).removeClass('cateOP'); $(this).removeClass('cateCL'); });

$('.nav-prd-cate .prd-cate a').click(function(){ $('.nav-prd-cate-sub').stop().delay(500); });

//product details
//$('#content-prd-details #left a').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });
$('ul#nav-subprd .img a').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });
$('#content-prd-top .add a').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });

//enquiry list
$('ul#enq-list li').hover(function(){ $(this).stop(false, true).fadeTo(0,0.5).fadeTo(300,1); }, function(){ $(this).stop(false, true).fadeTo(0,0.7).fadeTo(300,1); });


$('ul#enq-list li #del a').hide(0); 
$('ul#enq-list li').hover(function(){ $(this).find('#del a').show(0); }, function(){ $(this).find('#del a').hide(0); }); 
$('ul#enq-list li').click(function(){ window.location.href="product_inner.php?id="+$(this).attr('rel'); }); 
$('ul#enq-list li #del a').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });

//enquiry form

$(".form-row").hover(
	function(){ if($(this).attr('id') != 'btnSub') $(this).stop(false, true).fadeTo(0,0.5).fadeTo(300,1); }, 
	function(){ if($(this).attr('id') != 'btnSub') $(this).stop(false, true).fadeTo(0,0.7).fadeTo(300,1); }
);
$('.form-row #frmBtn').hover(function(){ $(this).stop(false, true).fadeTo(300, 0.6); }, function(){ $(this).stop(false, true).fadeTo(300, 1); });

//stores
/*
$('#content-store-list .icoMap').hover(function(){ $(this).find('.mapDetails').stop().slideDown('fast'); }, function(){ $(this).find('.mapDetails').stop().delay(2000).fadeOut(100,function(){ $(this).find('#map').hide(); $(this).find('a.view').show(); });  });
*/
$('#content-store-list .icoMap').hover(function(){ 
$('.mapDetails').attr('rel', 'fadeout'); 
$(this).find('.mapDetails').attr('rel', 'slideout');

$('.mapDetails').filter(function (index) { return $(this).attr("rel") == "slideout"; 
}).stop(true, true).slideDown('fast');
$('.mapDetails').filter(function (index) { return $(this).attr("rel") == "fadeout"; }).stop(true, true).hide(0,function(){ $(this).find('#map').hide(); $(this).find('a.view').show(); }); }, 

function(){ $(this).find('.mapDetails').attr('rel', 'fadeout'); $(this).find('.mapDetails').stop(true, true).delay(1000).hide(0,function(){ $('.mapDetails').attr('rel', 'fadeout'); $(this).find('#map').hide(); $(this).find('a.view').show(); });  });

$('#content-store-list .viewMap a.view').click(function(){ 
$(this).parent().parent().find('#map').html( $(this).parent().parent().find('#map_google').val() ); 
$(this).parent().parent().find('#map').slideDown(); $(this).fadeOut(); });



//news list
$('ul#news-list li').hover(function(){ $(this).stop(false, true).fadeTo(0,0.5).fadeTo(300,1); }, function(){ $(this).stop(false, true).fadeTo(0,0.7).fadeTo(300,1); });

/* ----------------------------------------------------------------- */
$('ul#nav-menu li').hover( function(){ $(this).find('div#nav-menu-cate').stop(true, true).fadeTo('fast',1); }, 
					  	   function(){ $(this).find('div#nav-menu-cate').stop(true, true).fadeOut('fast',0); } );
 
});


/* ----------------------------------------------------------------- */

