
$(document).ready(function(){
	$('.calculator').hide();
	$('div.CatRetailer').hide();
	$('#home_Cat').change(function(){
		var category = $('#home_Cat option:selected').text();	
		category = category.replace(' & ', '|');
		var vval = $.ajax({ 
			type: "POST", url: "calculator.php",
 			data: "category="+category, async: false
		}).responseText;
		$('#home_Retailer').html(vval);
		$('#in_home_Retailer').text('Now Choose your retailer...');
	});
	$('#home_Retailer').change(function(){
		var sval = $.ajax({ 
			type: "POST", url: "calculator.php",
 			data: "shop_id="+($(this).val()), async: false
		}).responseText;
		$('.calculator').show('200');
		$('.calculator').html(sval);
	});
	 $(document).click(function() {
		 $('div.CatRetailer').hide();
		$('.styled').css({'display': 'block'}); 
		$('#slideshow').css({'display': 'block'});
		$('.newlocdis').css({'display': 'block'});
	 });
	 $(document).mouseover(function() {
		 $('div.CatRetailer').hide();
		$('.styled').css({'display': 'block'}); 
		$('#slideshow').css({'display': 'block'});
		$('.newlocdis').css({'display': 'block'});
	 });
	$('div#tabs ul li.headerCat').mouseover(function(){
		$('div#all_cat').hide();
		var category = $(this).attr('id');
		$('div#'+category+'HD').show();
		var divheight=$('div#'+category+'HD');
		if(divheight.height()>190 && divheight.width()>722){
		$('.styled').css({'display': 'none'});
		$('#slideshow').css({'display': 'none'});
		}
		else{
		$('.styled').css({'display': 'block'});
		$('#slideshow').css({'display': 'block'});
		}
		if(divheight.height()>140){
		$('.newlocdis').css({'display': 'none'});
		}
		else{
		$('.newlocdis').css({'display': 'block'});
		}
		return false;		
	});
$("div#tabs ul li.headerCat").mouseout(function(){
var category=$(this).attr("id");
$(this).find('div#'+category+'HD').hide();
});

$('div#tabs ul li.headerCat2').click(function()
 {			
		$('div#all_cat').hide();
		$('div.CatRetailer').hide();
		var category = $(this).attr('id');
              var category1 = category+'HD';
		var urrl = document.domain;
		$('#'+category1).load('http://'+urrl+'/headermenu.php?type='+category);
		$('div#'+category+'HD').show();	
		var divheight=$('div#'+category+'HD');
		if(divheight.height()>290 && divheight.width()>722){
		$('.styled').css({'display': 'none'});
		$('#slideshow').css({'display': 'none'});
		}
		else{
		$('.styled').css({'display': 'block'});
		$('#slideshow').css({'display': 'block'});
		}
		if(divheight.height()>140){
		$('.newlocdis').css({'display': 'none'});
		}
		else{
		$('.newlocdis').css({'display': 'block'});
		}
		return false;		
	});

});

$(document).ready(function(){$('li#online-deals').addClass('online-deals-sel');$('li#local-offers').addClass('local-offers-norm');$("div.search div.online-deals").show();$("input[name='serch_cat']").val('online-deals');$("div.search ul li").click(function(){var tab_cls=$(this).attr('id');if(tab_cls!="whatis"){$('li#local-offers').removeClass('local-offers-sel');$('li#online-deals').removeClass('online-deals-sel');$('li#local-offers').addClass('local-offers-norm');$('li#online-deals').addClass('online-deals-norm');$("input[name='serch_cat']").val(tab_cls);$('li#'+tab_cls).removeClass(tab_cls+'-norm');$('li#'+tab_cls).addClass(tab_cls+'-sel');$("div.search div").hide();$("div.search div."+tab_cls).show();$("div.search div."+tab_cls+" div").show()}});if($("input[name='print_voc']").val()==1){$('li#online-deals').addClass('online-deals-norm');$('li#local-offers').removeClass('local-offers-norm');$('li#local-offers').addClass('local-offers-sel');$("div.search div").hide();$("div.search div.local-offers").show();$("div.search div.local-offers div").show()}});
function slideSwitch(){var $active=$('div.RTslideshow DIV.active');if($active.length==0)$active=$('div.RTslideshow DIV:last');var $next=$active.next().length?$active.next():$('div.RTslideshow DIV:first');$active.addClass('last-active');$next.css({opacity:0.0}).addClass('active').animate({opacity:1.0},1000,function(){$active.removeClass('active last-active')})}$(function(){setInterval("slideSwitch()",4000)});
function slideSwitch1(){var $active=$('div.LTslideshow DIV.active');if($active.length==0)$active=$('div.LTslideshow DIV:last');var $next=$active.next().length?$active.next():$('div.LTslideshow DIV:first');$active.addClass('last-active');$next.css({opacity:0.0}).addClass('active').animate({opacity:1.0},1000,function(){$active.removeClass('active last-active')})}$(function(){setInterval("slideSwitch1()",4000)});
$(document).ready(function(){
$('div a.show_detail').click(function(){
var id=$(this).attr('id').split('A');
$('div#div_detail'+id[1]).slideToggle('slow');
$(this).text(($('div a#A'+id[1]).text()=='Show details')?'Hide details':'Show details');
});
});
$(function(){
	if ($("#searchField").length > 0){
		setAutoComplete("searchField", "results", "../merchants.php?search=");
	}
});

$(function () {
    var tabContainers = $('div.tabs > div[class!="tabs-title"]');
    $('div.tabs ul.tabNavigation a').click(function () {
        tabContainers.hide().filter(this.hash).show();
        
        $('div.tabs ul.tabNavigation a').parent().removeClass('active');
        $(this).parent().addClass('active');
     
        return false;
    }).filter(':first').click();
});
$(function () {
    var tabContainers12 = $('div.tabs1 > div[class!="tabs-title12"]'); 
    $('div.tabs1 ul.tabNavigation12 a').click(function () {
        tabContainers12.hide().filter(this.hash).show();      
        $('div.tabs1 ul.tabNavigation12 a').parent().removeClass('active');
        $(this).parent().addClass('active');        
        return false;
    }).filter(':first').click();
});
function add_favorite() {
    url="http://"+document.domain+"/"
    title="PSdiscounts - Cashback Shopping"
    if (document.all)
    window.external.AddFavorite(url, title);
    else if (window.sidebar)
    window.sidebar.addPanel(title, url, "");
}
function cleartxt(frm){frm.email.value =" ";}
function fn_sort(opt){
	document.sort_frm.sort_val.value = opt ;
	document.sort_frm.submit();	
}
var regex_email = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$/;
function submit_reg_form(frm) {
	var password = frm.password.value;
  if (!regex_email.test(frm.email.value)) {
    alert("Email address seems to be invalid, please check it"); frm.email.focus(); return false;
  }else if (frm.email.value != frm.email_confirm.value) {
    alert("Confirm Email address does not match with email address, please check it"); frm.email_confirm.focus(); return false;
  }else if (frm.password.value == "" || password.length <= 5) {
    alert("Password should have minimum 6 characters, please change it"); frm.password.focus(); return false;
  }else if (frm.password.value != frm.password_confirm.value) {
    alert("Confirmation password does not match with Password value, please check it"); frm.password_confirm.focus(); return false;
  }else if (!frm.agree_conditions.checked) {
    alert("Please check on checkbox if you agree with Terms and Conditions."); frm.agree_conditions.focus(); return false;
  }
  return true;
}
function submit_reg_popform(frm) {
  if (!regex_email.test(frm.email.value)) {
    alert("Email address seems to be invalid, please check it"); frm.email.focus(); return false;
  }else if (frm.email.value != frm.email_confirm.value) {
    alert("Confirm Email address does not match with email address, please check it"); frm.email_confirm.focus(); return false;
  }else if (!frm.agree_conditions.checked) {
    alert("Please check on checkbox if you agree with Terms and Conditions."); frm.agree_conditions.focus(); return false;
  }
  return true;
}
function submitreg_homeform(frm){ 
  if (!regex_email.test(frm.email.value)) {
    alert("Email address seems to be invalid, please check it"); frm.email.focus(); return false;
  }
  return true;
}
function submit_pw_reset_form(frm) {
  if (!regex_email.test(frm.email.value)) {
    alert("E-mail address seems to be invalid, please check it"); frm.email.focus(); return false;
  }
  return true;
}
function make_link(url){window.location = url;}
function submit_login_form(frm) {
  var password = frm.password.value;
  if (!regex_email.test(frm.email.value)) {
    alert("E-mail address seems to be invalid, please check it"); frm.email.focus(); return false;
  } else if (frm.password.value == "" || password.length <= 5) {
    alert("Password is empty or has less than 6 characters, please check it"); frm.password.focus(); return false;
  }
  return true;
}
function fntabsel(tab){
	if(tab == 'tb2'){ 
		document.getElementById('TT').style.display = 'none';
		document.getElementById('TS').style.display = 'block';
		document.getElementById('t1').className = '';
		document.getElementById('t2').className = 'active';
	}
	if(tab == 'tb1'){ 
		document.getElementById('TS').style.display = 'none';
		document.getElementById('TT').style.display = 'block';
		document.getElementById('t1').className = 'active';
		document.getElementById('t2').className = '';
	}
}
function ValidSubmit(frmcategory) {
  var chk;
  for (var i=0; i<frmcategory.category.length; i++)  { 
   if (frmcategory.category[i].checked)  {
     chk = frmcategory.category[i].value; 
   }
  } 
if (chk != "Transaction Enquiries"){
	frmcategory.action="submit.php?c="+chk;
	frmcategory.submit();
}
if(chk == "Transaction Enquiries"){
  if(frmcategory.emailnew.value == "user"){
     frmcategory.action="submit.php?c="+chk+"&str=1";
	 frmcategory.submit();
  } else {
     frmcategory.action="submit.php?c="+chk;
	 frmcategory.submit();    
  }
 }
}
function ltrim(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function trim(str) {
	return ltrim(rtrim(str));
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}
function ValidBusinessSub(frmbusiness){
if(frmbusiness.name.value==""){
   alert("Please Enter The Name!");
   return false;
  }

  if(frmbusiness.email){
    if(document.frmbusiness.email.value==""){
     alert("Please Enter The Email!");
     return false;

    } else if(frmbusiness.email.value !=""){

      if (!regex_email.test(frmbusiness.email.value)) {
        alert("Email address seems to be invalid, please check it");frmbusiness.email.focus(); return false;
      }
    }
  }
  if(frmbusiness.subject.value==""){
   alert("Please Enter The Subject!");
   return false;
  }
 var str;
  var str2;
   str = frmbusiness.message.value;
   str2 = trim(str);
  if(str2 == ""){
   alert("Please Enter The Message!");
   return false;
  }
  if(frmbusiness.Seccode1.value==""){
   alert("Please Enter The Security code");
   return false;
  }
  val = frmbusiness.act.value;
  val1 = frmbusiness.cname.value;
  frmbusiness.action="submit.php?c="+val1;
  frmbusiness.submit();
}
function ValidBusinessSub1(frmbusiness){
  if(frmbusiness.subject.value==""){
   alert("Please Enter The Subject!");
   return false;
  }
  var str;
  var str2;
   str = frmbusiness.message.value;
   str2 = trim(str);
  if(str2 == ""){
   alert("Please Enter The Message!");
   frmbusiness.message.focus();
   return false;
  } 
  val1 = frmbusiness.checknew.value;
  frmbusiness.action="submit.php?c="+val1;
  frmbusiness.submit();
}
$(document).ready(function(){
	var ccval = $('#catTabVal').val();
	$('div#black_card_cashbackP').hide();
	if(ccval !=''){
		$('div.catTabs ul li#'+ccval).css({"background" :"url('../img/offer_menu.gif') no-repeat 0 -32px"})
		$('div.catTabs ul li#'+ccval+' a').css({"background" :"url('../img/offer_menu.gif') no-repeat right -32px", "color":"#2760AD"})
		$('div#'+ccval+'T').show();
		$('div#'+ccval+'P').show();
	}else{
		$('div.catTabs ul li:first-child').css({"background" :"url('../img/offer_menu.gif') no-repeat 0 -32px"})
		$('div.catTabs ul li:first-child a').css({"background" :"url('../img/offer_menu.gif') no-repeat right -32px", "color":"#2760AD"})
		$('div#all_offersT').show();
		$('div#all_offersP').show();
	}
	$('div.catTabs ul li').mouseover(function(){
		var id = $(this).attr('id');
		$(this).css({"background" :"url('../img/offer_menu.gif') no-repeat 0 -32px"});
		$('div.catTabs ul li#'+id+' a').css({"background" :"url('../img/offer_menu.gif') no-repeat right -32px", "color":"#2760AD"})
	});
	$('div.catTabs ul li').mouseout(function(){
		var id = $(this).attr('id');
		if($('div#'+id+'T').is(':visible')){
		}else{
			$(this).css({"background" :"url('../img/offer_menu.gif') no-repeat 0 0"});
			$('div.catTabs ul li#'+id+' a').css({"background" :"url('../img/offer_menu.gif') no-repeat right 0"})
		}
	});
	$('#catTabVal').val('all_offers');
	$('div.catTabs ul li').click(function(){
		$('div.catTabs ul li').removeClass('Selectedclass');
		$('div.catTabs ul li').removeClass('unSelectedclass');
		$('div.tab_container').removeClass('tabdisop');
		$('div.tab_container').removeClass('tabdiscl');
		var id = $(this).attr('id');
		var v = $('input[name="USIN"]').val();
	var x = $('input[name="HDKey"]').val()
	if((id == 'ret_vouchers' || id == 'gift_card' || id == 'retailer_voucher') && !v){
		$("#basic-modal-content11").load("http://"+document.domain+"/pop.php?popusn=1&hdkey="+x);
		$('#basic-modal-content11').modal1();
	}else{
		$("input[name='catTabVal']").val(id);
		$('div.catTabs ul li').css({"background" :"url('../img/offer_menu.gif') no-repeat 0 0px"})
		$('div.catTabs ul li a').css({"background" :"url('../img/offer_menu.gif') no-repeat right 0px"})
		$('div.catTabs ul li#'+id).css({"background" :"url('../img/offer_menu.gif') no-repeat 0 -32px"})
		$('div.catTabs ul li#'+id+' a').css({"background" :"url('../img/offer_menu.gif') no-repeat right -32px", "color":"#2760AD"})
		$('div.tab_container').hide();
		$('div#'+id+'T').show();
		$('div#'+id+'P').show();
		}
	});
       $(document).click(function() {
             $('div#LoginLightBox').hide('slow');
	      $('div#all_cat').hide('slow');
	      $('div#subtabs ul li#mem_login a').css({'background-position': 'left top', 'color':'#000000'});
	      $('div#subtabs ul li#mem_login a span').css({'background-position': 'right top', 'color':'#000000'});
       });
 $(document).click(function() {
 	$('div#all_cat').hide('slow');
 });
	$('div#subtabs ul li#mem_login').click(function(){
		$('div#all_cat').hide('slow');
		if($('div#LoginLightBox').is(':visible')){
			$('div#LoginLightBox').hide('slow');
		}else{
			$('div#LoginLightBox').show('slow');
			
		}
		 return false;

	});
	$('div#LoginLightBox').click(function(e) {
	       e.stopPropagation();
       });
	$('div#tabs ul li.cate').click(function(){
		$('div#LoginLightBox').hide('slow');
		$('div.CatRetailer').hide('slow');
		$('div#all_cat').show('slow');
		 return false;
	});	
	$('div#all_cat').click(function(e) {
	       e.stopPropagation();
       });
	
});
$(function(){$('select.styled').customStyle();$('select.selcate').customStyle2();$('select.styled1').customStyle3();$('select.styled2').customStyle4()});
(function($){$.fn.extend({customStyle:function(options){if(!$.browser.msie||($.browser.msie&&$.browser.version>6)){return this.each(function(){var currentSelected=$(this).find(':selected');$(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute',opacity:0,fontSize:$(this).next().css('font-size')});var selectBoxSpan=$(this).next();var selectBoxWidth=parseInt($(this).width())-parseInt(selectBoxSpan.css('padding-left'))-parseInt(selectBoxSpan.css('padding-right'));var selectBoxSpanInner=selectBoxSpan.find(':first-child');selectBoxSpan.css({display:'inline-block'});selectBoxSpanInner.css({width:selectBoxWidth,display:'inline-block'});var selectBoxHeight=parseInt(selectBoxSpan.height())+parseInt(selectBoxSpan.css('padding-top'))+parseInt(selectBoxSpan.css('padding-bottom'));$(this).height(selectBoxHeight).change(function(){if($(this).val()=='a-z'){var value='A-Z'}else if($(this).val()=='new'){var value='Newest First'}else if($(this).val()=='pound'){var value='Highest £'}else if($(this).val()=='percentage'){var value='Highest %'}selectBoxSpanInner.text(value).parent().addClass('changed')})})}}})})(jQuery);
(function($){$.fn.extend({customStyle2:function(options){if(!$.browser.msie||($.browser.msie&&$.browser.version>6)){return this.each(function(){var id1=$(this).attr('id');var currentSelected=$(this).find(':selected');$(this).after('<span class="customStyleSelectBox2" id="sp'+id1+'"><span class="customStyleSelectBoxInner2" id="in_'+id1+'">'+currentSelected.text()+'</span></span>').css({position:'absolute',opacity:0,fontSize:$(this).next().css('font-size')});var selectBoxSpan=$(this).next();var selectBoxWidth=parseInt($(this).width())-parseInt(selectBoxSpan.css('padding-left'))-parseInt(selectBoxSpan.css('padding-right'));var selectBoxSpanInner=selectBoxSpan.find(':first-child');selectBoxSpan.css({display:'inline-block'});selectBoxSpanInner.css({width:selectBoxWidth,display:'inline-block'});var selectBoxHeight=parseInt(selectBoxSpan.height())+parseInt(selectBoxSpan.css('padding-top'))+parseInt(selectBoxSpan.css('padding-bottom'));$(this).height(selectBoxHeight).change(function(){var id=$(this).attr('id');selectBoxSpanInner.text($('#'+id+' option:selected').text()).parent().addClass('changed')})})}}})})(jQuery);
(function($){$.fn.extend({customStyle3:function(options){if(!$.browser.msie||($.browser.msie&&$.browser.version>6)){return this.each(function(){var currentSelected=$(this).find(':selected');$(this).after('<span class="customStyleSelectBox3"><span class="customStyleSelectBoxInner3">'+currentSelected.text()+'</span></span>').css({position:'absolute',opacity:0,fontSize:$(this).next().css('font-size')});var selectBoxSpan=$(this).next();var selectBoxWidth=parseInt($(this).width())-parseInt(selectBoxSpan.css('padding-left'))-parseInt(selectBoxSpan.css('padding-right'));var selectBoxSpanInner=selectBoxSpan.find(':first-child');selectBoxSpan.css({display:'inline-block'});selectBoxSpanInner.css({width:selectBoxWidth,display:'inline-block'});var selectBoxHeight=parseInt(selectBoxSpan.height())+parseInt(selectBoxSpan.css('padding-top'))+parseInt(selectBoxSpan.css('padding-bottom'));$(this).height(selectBoxHeight).change(function(){var id=$(this).attr('id');selectBoxSpanInner.text($('#'+id+' option:selected').text()).parent().addClass('changed')})})}}})})(jQuery);
(function($){$.fn.extend({customStyle4:function(options){
	if(!$.browser.msie||($.browser.msie&&$.browser.version>6)){
		return this.each(function(){
			var currentSelected=$(this).find(':selected');
			$(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute',opacity:0,fontSize:$(this).next().css('font-size')});
			var selectBoxSpan=$(this).next();
			var selectBoxWidth=parseInt($(this).width())-parseInt(selectBoxSpan.css('padding-left'))-parseInt(selectBoxSpan.css('padding-right'));
			var selectBoxSpanInner=selectBoxSpan.find(':first-child');
			selectBoxSpan.css({display:'inline-block'});
			selectBoxSpanInner.css({width:132,display:'inline-block'});
			var selectBoxHeight=parseInt(selectBoxSpan.height())+parseInt(selectBoxSpan.css('padding-top'))+parseInt(selectBoxSpan.css('padding-bottom'));
			$(this).height(selectBoxHeight).change(function(){var id=$(this).attr('id');
			selectBoxSpanInner.text($('#'+id+' option:selected').text()).parent().addClass('changed')})

		})
	}
}})})(jQuery);


