    var winReference = null;


// Open a window at a given position on the screen
function openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName) {
	
	// ie 4.5 and 5.0 mac - windows are 2 pixels too short; if a statusbar is used, the window will be an additional 15 pixels short
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf("mac") != -1 && agent.indexOf("msie") != -1 && (agent.indexOf("msie 4") != -1 || agent.indexOf("msie 5.0") != -1) ) {
		height += (status) ? 17 : 2;
	}

	// Adjust width if scrollbars are used (pc places scrollbars inside the content area; mac outside) 
	width += (scrollbars != '' && scrollbars != null && agent.indexOf("mac") == -1) ? 16 : 0;

	var properties = 'width=' + width + ',height=' + height + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ((status) ? ',status' : '') + ',scrollbars' + ((scrollbars) ? '' : '=no') + ((moreProperties) ? ',' + moreProperties : '');
	var reference = openWindow(url, name, properties, openerName);
	
	return reference;
}


// Open a window at the center of the screen
function openCenteredWindow(url, name, width, height, status, scrollbars, moreProperties, openerName) {
	var x, y = 0;
	if (screen) {
      x = (screen.availWidth - width) / 2;
	   y = (screen.availHeight - height) / 2;
   }
	if (!status) status = '';
	if (!openerName) openerName = '';
	var reference = openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName);
	return reference;
}	


// Open a window at the center of the parent window
function openCenteredOnOpenerWindow(url, name, width, height, status, scrollbars, moreProperties, openerName) {
	var centerX = 0;
   var centerY = 0;
   if (window.screenX != null && window.outerWidth) {
      centerX = window.screenX + (window.outerWidth / 2);
      centerY = window.screenY + (window.outerHeight / 2);
   }
   else if (window.screenLeft) {
      if (document.documentElement) {
         centerX = window.screenLeft + (document.documentElement.offsetWidth / 2);
         centerY = window.screenTop + (document.documentElement.offsetHeight / 2);
      }
      else if (document.body && document.body.offsetWidth) {
         centerX = window.screenLeft + (document.body.offsetWidth / 2);
         centerY = window.screenTop + (document.body.offsetHeight / 2);
      }
   }
   
   if (centerX == 0) {
      openCenteredWindow(url, name, width, height, status, scrollbars, moreProperties, openerName);
   }
   var x = parseInt(centerX - (width / 2));
   var y = parseInt(centerY - (height / 2));
	if (!status) status = '';
	if (!openerName) openerName = '';
	var reference = openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName);
	return reference;
}	


// Open a full-screen window (different from IE's fullscreen option)
function openMaxedWindow(url, name, scrollbars, openerName) {
	var x, y = 0;
	var width  = 600;
	var height = 800;
	if (screen) {
      if (screen.availLeft) {
         x = screen.availLeft;
         y = screen.availTop;
      }
      width  = screen.availWidth - 6;
	   height = screen.availHeight - 29;
   }
	var reference = openPositionedWindow(url, name, width, height, x, y, false, scrollbars, openerName);
	return reference;
}


// Core utility function that actually creates the window and gives focus to it
function openWindow(url, name, properties, openerName) {

	// ie4.x pc can't give focus to windows containing documents from a different domain
	// in this case, initially load a local interstisial page to allow focussing before loading final url
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) == 4 && agent.indexOf("msie 5") == -1 && agent.indexOf("msie5") == -1 && agent.indexOf("win") != -1 && url.indexOf('http://') == 0) {
		winReference = window.open('about:blank', name, properties);
		
		setTimeout('if (winReference && !winReference.closed) winReference.location.replace("' + url + '")', 300);
	}
	else {
		winReference = window.open(url, name, properties);
	}

	// ie doesn't like giving focus immediately (to new window in 4.5 on mac; to existing ones in 5 on pc)
	setTimeout('if (winReference && !winReference.closed) winReference.focus()', 200);
	
	if (openerName) self.name = openerName;
	return winReference;
}


// Close parent popup
// Call from onload event handler of any page that could be created from a dialog
function closeParentDialog() {
	if (top.opener && isWindowPopup(top.opener)) {
		root = top.opener.top.opener;
		top.opener.close();
		top.opener = root;
	}
}


// Check if a window is a popup
function isWindowPopup(win) {
	return ((win.opener) ? true : false);
}

function clickSearchBar(element){
	if(element.value == 'Type Search Here') {
		element.value = '';
		//element.style.color = '#000000';
	}
}

function keySearchBar(element){
	
	var searchReal = $("#searchBar").val();
	keySearchAjax(searchReal);
	
}


function blurSearchBar(element){
	if(element.value == '') {
		element.value = 'Type Search Here';
		//element.style.color = '#AAAAAA';
	}
}
function closeSearchBar(element){
	document.getElementById('searchBar').value = 'Type Search Here';
	//document.getElementById('searchBar').style.color = '#AAAAAA';
	element.style.display = 'none';
	location.reload(true);
}



function showBrands(){
	document.getElementById('brand_model_bg').style.display = 'block';
	document.getElementById('brand_model').style.display = 'block';
}
function hideBrands(){
	document.getElementById('brand_model_bg').style.display = 'none';
	document.getElementById('brand_model').style.display = 'none';
}
function showBrandSlide(element){
	document.getElementById('branda').style.display = "none";
	document.getElementById('brandd').style.display = "none";
	document.getElementById('brandh').style.display = "none";
	document.getElementById('brandn').style.display = "none";
	document.getElementById('brands').style.display = "none";
	document.getElementById('brandw').style.display = "none";
	document.getElementById(element).style.display = "block";
}

function openCertDetails()
{
	var referer = "https://www.iqtoys.co.nz";
	
	certDetailsUrlWithReferer = "https://seal.thawte.com/thawtesplash?form_file=fdf/thawtesplash.fdf&dn=www.iqtoys.co.nz&lang=en";

	thewindow = window.open(certDetailsUrlWithReferer,
		"newWindow", config="height=500,width=516,toolbar=no,menubar=no," +
		"scrollbars=yes,resizable=no,location=no,directories=no,status=yes");
}




$(document).ready(function() {   

	$('#wishlist-purchased').hide();
	$('.show-purchased').click(function(){
		$('#wishlist-purchased').slideDown();
		$(this).hide();
	});



	/* 24 Hour Delivery ... show/hide text */
	$('.quickdelivery').each(function(){
		if($.browser.msie){
			$(this).hover(
				function(){
					$(this).find('.quickdeliverytext').show();
				},
				function(){
					$(this).find('.quickdeliverytext').hide();
				}
			);
		}
		else{
			$(this).hover(
				function(){
					$(this).find('.quickdeliverytext').css({zIndex:99}).fadeIn();
				},
				function(){
					$(this).find('.quickdeliverytext').css({zIndex:99}).fadeOut();
				}
			);
		}
	});



	/* EXPAND / CONTRACT Batteries*/
	$('#batttoggle').click(function() { 
		$('#battery-hidden').show(); 
		$('#batttoggle').hide();
	});	

	
	$('#img').cycle({
			timeout:0, 
			pager:  '#thumbnails',
			pagerAnchorBuilder: function(idx, slide) { 
				return '<a class="imgbox" href="#" style=\"background-image:url(' +  jQuery(slide).attr("alt") + ')\"></a>'; 
			} 
		});	
	$('#homeslide').cycle({
		timeout:6000, 
		pager:  '#nav',
		pagerAnchorBuilder: function(idx, slide) { 
			return '<a href="#">' + slide.title + '</a>'; 
		} 
	});
	$('a.play').addClass('playhighlight');
	$('a.play').removeClass('play');
	$('#pause').click(function() { 
		$('#homeslide').cycle('pause'); 
		$(this).addClass('pausehighlight');
		$(this).removeClass('pause');
		$('#play').removeClass('playhighlight');
		$('#play').addClass('play');
	});
	$('#play').click(function() { 
		$('#homeslide').cycle('resume'); 
		$(this).addClass('playhighlight');
		$(this).removeClass('play');
		$('#pause').removeClass('pausehighlight');
		$('#pause').addClass('pause');
	});
		
	$('#addreview').click(function() {
		if($("#review_block").is(":hidden")){
			$("#review_block").slideDown("slow");
		}
		else{
			$("#review_block").slideUp("slow");
		}
	});	
	$('#add_review').click(function() {
		if($("#review_block").is(":hidden")){
			$("#review_block").slideDown("slow");
		}
		else{
			$("#review_block").slideUp("slow");
		}
	});	
	$('#emailshare').click(function() {
		if($("#gift_idea").is(":hidden")){
			$("#gift_idea").slideDown("slow");
		}
		else{
			$("#gift_idea").slideUp("slow");
		}
	});	
		$("#notify_btn").click(function () {
			$("#notify_btn").hide();
			$("#notify_btn2").show();
			$("#notify").slideDown("slow");
		});
		$("#notify_btn2").click(function () {
			$("#notify_btn").show();
			$("#notify_btn2").hide();
			$("#notify").slideUp("slow");

		});
	
	
	/* EXPAND / CONTRACT */
	$('#expand').click(function() { 
		$('#allbrands').slideDown(); 
		$(this).hide();
		$('#contract').css('display', 'block');										
	});	
	$('#contract').click(function() { 
		$('#allbrands').slideUp(); 
		$(this).hide();
		$('#expand').css('display', 'block');										
	});
	

	
	
	
	

		
			function getSpecialsPage(page){
				$("#specials").find(".container").html("<div class='loader'></div>");
				$.ajax({
				   type: "POST",
				   url: "rpc/getSpecialsHtml.php",
				   data: "page=" + page,
				   success: function(html){							
						$("#specials").find(".container").html(html);
						$('.quickdelivery').each(function(){
							if($.browser.msie){
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').show();
									},
									function(){
										$(this).find('.quickdeliverytext').hide();
									}
								);
							}
							else{
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeIn();
									},
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeOut();
									}
								);
							}
						});
					}
				});
				

			}
			function getNewPage(page){
				$("#new").find(".container").html("<div class='loader'></div>");
				$.ajax({
				   type: "POST",
				   url: "rpc/getNewHtml.php",
				   data: "page=" + page,
				   success: function(html){							
						$("#new").find(".container").html(html);
						$('.quickdelivery').each(function(){
							if($.browser.msie){
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').show();
									},
									function(){
										$(this).find('.quickdeliverytext').hide();
									}
								);
							}
							else{
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeIn();
									},
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeOut();
									}
								);
							}
						});
					}
				});
				

			}	

			function getRecentPage(page){
				$("#recent").find(".container").html("<div class='loader'></div>");
				$.ajax({
				   type: "POST",
				   url: "rpc/getRecentHtml.php",
				   data: "page=" + page,
				   success: function(html){							
						$("#recent").find(".container").html(html);
						$('.quickdelivery').each(function(){
							if($.browser.msie){
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').show();
									},
									function(){
										$(this).find('.quickdeliverytext').hide();
									}
								);
							}
							else{
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeIn();
									},
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeOut();
									}
								);
							}
						});
					}
				});
				

			}				
			function getReviewPage(page){
				$("#review").find(".container").html("<div class='loader'></div>");
				$.ajax({
				   type: "POST",
				   url: "rpc/getReviewHtml.php",
				   data: "page=" + page,
				   success: function(html){							
						$("#review").find(".container").html(html);
						$('.quickdelivery').each(function(){
							if($.browser.msie){
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').show();
									},
									function(){
										$(this).find('.quickdeliverytext').hide();
									}
								);
							}
							else{
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeIn();
									},
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeOut();
									}
								);
							}
						});
					}
				});
				

			}	
			function getCatNewPage(page){
				$("#category-new").find(".container").html("<div class='loader'></div>");
				$.ajax({
				   type: "POST",
				   url: "/rpc/getCategoryNewHtml.php",
				   data: "page=" + page + "&category_safe=" + $("#category_safe").val(),				  
				   success: function(html){							
						$("#category-new").find(".container").html(html);
						$('.quickdelivery').each(function(){
							if($.browser.msie){
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').show();
									},
									function(){
										$(this).find('.quickdeliverytext').hide();
									}
								);
							}
							else{
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeIn();
									},
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeOut();
									}
								);
							}
						});
					}
				});
				

			}

			function getCatComingPage(page){
				$("#category-coming").find(".container").html("<div class='loader'></div>");
				$.ajax({
				   type: "POST",
				   url: "/rpc/getCategoryComingHtml.php",
				   data: "page=" + page + "&category_safe=" + $("#category_safe").val(),				  
				   success: function(html){							
						$("#category-coming").find(".container").html(html);
						$('.quickdelivery').each(function(){
							if($.browser.msie){
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').show();
									},
									function(){
										$(this).find('.quickdeliverytext').hide();
									}
								);
							}
							else{
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeIn();
									},
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeOut();
									}
								);
							}
						});
					}
				});
				

			}
	
			function getAgeNewPage(page){
				$("#age-new").find(".container").html("<div class='loader'></div>");
				$.ajax({
				   type: "POST",
				   url: "/rpc/getCategoryNewHtml.php",
				   data: "page=" + page + "&age_safe=" + $("#age_safe").val(),				  
				   success: function(html){							
						$("#age-new").find(".container").html(html);
						$('.quickdelivery').each(function(){
							if($.browser.msie){
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').show();
									},
									function(){
										$(this).find('.quickdeliverytext').hide();
									}
								);
							}
							else{
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeIn();
									},
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeOut();
									}
								);
							}
						});
					}
				});
				

			}	


			function getPriceNewPage(page){
				$("#price-new").find(".container").html("<div class='loader'></div>");
				$.ajax({
				   type: "POST",
				   url: "/rpc/getCategoryNewHtml.php",
				   data: "page=" + page + "&pricefrom=" + $("#pricefrom").val() + "&priceto=" + $("#priceto").val(),				  
				   success: function(html){							
						$("#price-new").find(".container").html(html);
						$('.quickdelivery').each(function(){
							if($.browser.msie){
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').show();
									},
									function(){
										$(this).find('.quickdeliverytext').hide();
									}
								);
							}
							else{
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeIn();
									},
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeOut();
									}
								);
							}
						});
					}
				});
				

			}				
			function getCatSpecialsPage(page){
				$("#category-specials").find(".container").html("<div class='loader'></div>");
				$.ajax({
				   type: "POST",
				   url: "/rpc/getCategorySpecialsHtml.php",
				   data: "page=" + page + "&category_safe=" + $("#category_safe").val(),				  
				   success: function(html){							
						$("#category-specials").find(".container").html(html);
						$('.quickdelivery').each(function(){
							if($.browser.msie){
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').show();
									},
									function(){
										$(this).find('.quickdeliverytext').hide();
									}
								);
							}
							else{
								$(this).hover(
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeIn();
									},
									function(){
										$(this).find('.quickdeliverytext').css({zIndex:99}).fadeOut();
									}
								);
							}
						});
					}
				});
				

			}								
			$("#specials").find(".left-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#specials").find(".current-page").val()) - 1);
					getSpecialsPage( page );
					$("#specials").find(".current-page").val(page);
				}		
				if(parseFloat($("#specials").find(".current-page").val()) <= 1){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}	
				$("#specials").find(".right-btn").removeClass("inactive");			
			});
			$("#specials").find(".right-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#specials").find(".current-page").val()) + 1);
					getSpecialsPage( page );
					$("#specials").find(".current-page").val(page);					
				}	
				if(parseFloat($("#specials").find(".current-page").val()) >= 4 ){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}
				$("#specials").find(".left-btn").removeClass("inactive");
			});	
	
	
			$("#new").find(".left-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#new").find(".current-page").val()) - 1);
					getNewPage( page );
					$("#new").find(".current-page").val(page);
				}		
				if(parseFloat($("#new").find(".current-page").val()) <= 1){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}	
				$("#new").find(".right-btn").removeClass("inactive");			
			});
			$("#new").find(".right-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#new").find(".current-page").val()) + 1);
					getNewPage( page );
					$("#new").find(".current-page").val(page);					
				}	
				if(parseFloat($("#new").find(".current-page").val()) >= 4 ){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}
				$("#new").find(".left-btn").removeClass("inactive");
			});	
			
			
			$("#recent").find(".left-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#recent").find(".current-page").val()) - 1);
					getRecentPage( page );
					$("#recent").find(".current-page").val(page);
				}		
				if(parseFloat($("#recent").find(".current-page").val()) <= 1){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}	
				$("#recent").find(".right-btn").removeClass("inactive");			
			});
			$("#recent").find(".right-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#recent").find(".current-page").val()) + 1);
					getRecentPage( page );
					$("#recent").find(".current-page").val(page);					
				}	
				if(parseFloat($("#recent").find(".current-page").val()) >= 4 ){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}
				$("#recent").find(".left-btn").removeClass("inactive");
			});	
			
			
		$("#review").find(".left-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#review").find(".current-page").val()) - 1);
					getReviewPage( page );
					$("#review").find(".current-page").val(page);
				}		
				if(parseFloat($("#review").find(".current-page").val()) <= 1){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}	
				$("#review").find(".right-btn").removeClass("inactive");			
			});
			$("#review").find(".right-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#review").find(".current-page").val()) + 1);
					getReviewPage( page );
					$("#review").find(".current-page").val(page);					
				}	
				if(parseFloat($("#review").find(".current-page").val()) >= 4 ){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}
				$("#review").find(".left-btn").removeClass("inactive");
			});	
	
	
			$("#category-new").find(".left-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#category-new").find(".current-page").val()) - 1);
					getCatNewPage( page );
					$("#category-new").find(".current-page").val(page);
				}		
				if(parseFloat($("#category-new").find(".current-page").val()) <= 1){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}	
				$("#category-new").find(".right-btn").removeClass("inactive");			
			});
			$("#category-new").find(".right-btn").click(function(){
				if(!$(this).hasClass("inactive")){
				
					page = ( parseFloat($("#category-new").find(".current-page").val()) + 1);
					getCatNewPage( page );
					$("#category-new").find(".current-page").val(page);					
				}	
				if(parseFloat($("#category-new").find(".current-page").val()) >= 4 ){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}
				$("#category-new").find(".left-btn").removeClass("inactive");
			});	
			

	
			$("#category-coming").find(".left-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#category-coming").find(".current-page").val()) - 1);
					getCatComingPage( page );
					$("#category-coming").find(".current-page").val(page);
				}		
				if(parseFloat($("#category-coming").find(".current-page").val()) <= 1){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}	
				$("#category-coming").find(".right-btn").removeClass("inactive");			
			});
			$("#category-coming").find(".right-btn").click(function(){
				if(!$(this).hasClass("inactive")){
				
					page = ( parseFloat($("#category-coming").find(".current-page").val()) + 1);
					getCatComingPage( page );
					$("#category-coming").find(".current-page").val(page);					
				}	
				if(parseFloat($("#category-coming").find(".current-page").val()) >= 4 ){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}
				$("#category-coming").find(".left-btn").removeClass("inactive");
			});	
						
			
			$("#age-new").find(".left-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#age-new").find(".current-page").val()) - 1);
					getAgeNewPage( page );
					$("#age-new").find(".current-page").val(page);
				}		
				if(parseFloat($("#age-new").find(".current-page").val()) <= 1){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}	
				$("#age-new").find(".right-btn").removeClass("inactive");			
			});
			$("#age-new").find(".right-btn").click(function(){
				if(!$(this).hasClass("inactive")){				
					page = ( parseFloat($("#age-new").find(".current-page").val()) + 1);
					getAgeNewPage( page );
					$("#age-new").find(".current-page").val(page);					
				}	
				if(parseFloat($("#age-new").find(".current-page").val()) >= 4 ){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}
				$("#age-new").find(".left-btn").removeClass("inactive");
			});	
			

			$("#price-new").find(".left-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#price-new").find(".current-page").val()) - 1);
					getPriceNewPage( page );
					$("#price-new").find(".current-page").val(page);
				}		
				if(parseFloat($("#price-new").find(".current-page").val()) <= 1){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}	
				$("#price-new").find(".right-btn").removeClass("inactive");			
			});
			$("#price-new").find(".right-btn").click(function(){
				if(!$(this).hasClass("inactive")){				
					page = ( parseFloat($("#price-new").find(".current-page").val()) + 1);
					getPriceNewPage( page );
					$("#price-new").find(".current-page").val(page);					
				}	
				if(parseFloat($("#price-new").find(".current-page").val()) >= 4 ){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}
				$("#price-new").find(".left-btn").removeClass("inactive");
			});	
						
			
			
			
			$("#category-specials").find(".left-btn").click(function(){
				if(!$(this).hasClass("inactive")){
					page = ( parseFloat($("#category-specials").find(".current-page").val()) - 1);
					getCatSpecialsPage( page );
					$("#category-specials").find(".current-page").val(page);
				}		
				if(parseFloat($("#category-specials").find(".current-page").val()) <= 1){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}	
				$("#category-specials").find(".right-btn").removeClass("inactive");			
			});
			$("#category-specials").find(".right-btn").click(function(){
				if(!$(this).hasClass("inactive")){
				
					page = ( parseFloat($("#category-specials").find(".current-page").val()) + 1);
					getCatSpecialsPage( page );
					$("#category-specials").find(".current-page").val(page);					
				}	
				if(parseFloat($("#category-specials").find(".current-page").val()) >= 4 ){
					$(this).addClass("inactive");
				}
				else{
					$(this).removeClass("inactive");
				}
				$("#category-specials").find(".left-btn").removeClass("inactive");
			});		
		
	
	
	/* FOOTER BREADCRUMBS */
	$('#ftr_crumbs').append($('#hdr_crumbs').html());
	
			getSpecialsPage( 1 );
			$("#specials").find(".current-page").val(1);				
			getReviewPage( 1 );
			$("#reviews").find(".current-page").val(1);				
			getNewPage( 1 );
			$("#new").find(".current-page").val(1);	
			getRecentPage( 1 );
			$("#recent").find(".current-page").val(1);	
			getCatSpecialsPage( 1 );
			$("#category-specials").find(".current-page").val(1);				
			getCatNewPage( 1 );
			$("#category-coming").find(".current-page").val(1);				
			getCatComingPage( 1 );
			$("#category-new").find(".current-page").val(1);	
			getPriceNewPage( 1 );
			$("#price-new").find(".current-page").val(1);		
			getAgeNewPage( 1 );
			$("#age-new").find(".current-page").val(1);	
			$(".notify_action").click(function(){
				$.ajax({
				   type: "POST",
				   url: "/rpc/getNotifyModal.php",
				   data: "item_order_num=" + $(this).attr("id"),
				   success: function(html){																
						$('body').prepend(html);
						$("a.close").click(function(){
							$(".modal").remove();													
						});
						//$(".modal").click(function(){
						//	$(".modal").remove();
						//});
					 
					}
				});
			});
			$(".review_action").click(function(){
				$.ajax({
				   type: "POST",
				   url: "/rpc/getReviewModal.php",
				   data: "item_order_num=" + $(this).attr("id"),
				   success: function(html){																
						$('body').prepend(html);
						$("a.close").click(function(){
							$(".modal").remove();													
						});
						//$(".modal").click(function(){
						//	$(".modal").remove();
						//});
					 
					}
				});
			});	
			$(".share_modal_action").click(function(){
				$.ajax({
				   type: "POST",
				   url: "/rpc/getShareModal.php",
				   data: "item_order_num=" + $(this).attr("id"),
				   success: function(html){		
						$(".modal").remove();
						$('body').prepend(html);
						$("a.close").click(function(){
							$(".modal").remove();													
						});
						//$(".modal").click(function(){
						//	$(".modal").remove();
						//});
					 
					}
				});
			});				
	
	
	
	
});

      function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }

