// JavaScript Document
	
   $(function() {  
   $(".newsticker-jcarousellite").jCarouselLite({  
           vertical: false,  
            visible: 3,  
           auto:3400,  
           speed:800,
		   hoverPause: true,
		   btnNext: "#btnLeftscroll",
		   btnPrev: "#btnRightscroll",
		   scrolldir: false
        });  
    });  


	function comp()
	{
		var val1 = $("#compare1").val();
		var val2 = $("#compare2").val();
		
		if ((val1=='') || (val2==undefined))
		{
				alert("Please Select Atleast Two Products");
		}
		
		else
		{
			window.location='compare.html';
		}
	}
	
$(document).ready(function(){   
	stringFun = (function() {
	var img = Array();
	img[0] = 'images/bannerone.jpg';
	img[1] = 'images/bannertwo.jpg';
	var imgname = $("#banner").attr("src");
	if(imgname == img[0]){
		
	$("#divBanner").attr("class","bannerinner");
	$("#banner").attr("src",img[1]);
	
	}
	else{
	$("#divBanner").attr("class","bannerouter");
	$("#banner").attr("src",img[0]);
	}
	setTimeout("stringFun();",4000)
	});
	//stringFun();

	$("#error").hide();
	$("a[rel^='prettyOverlay'],a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.35, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true /* true/false */
	});

	$("#brandselect").change(function(){
		var idd = $(this).val();
		var bname = $("#brandselect option:selected").text();
		if(idd != 0 || idd != '0X'){
			window.location = 'brand_'+bname+'_'+idd+'.html';
		}
		return false;
	});
	$("#TB_ImageOff").livequery('click', function(){
		$("#TB_window").fadeOut("slow");
	});
	$('<div id="loading" class="loading">Please wait...</div>').appendTo("body").hide();
	$('div#example1-1 a').livequery('click', function() {
	var dataId = $(this).attr('id');
	if(dataId!=''){
		$(".loading").fadeIn("slow");
		$('#shoppingcart').html('Loading...');
			$.ajax({
				url : 'details.html',
				type : 'POST',
				dataTypes : 'html',
				data : 'id='+dataId,
				success	: function(a,b){
					$('#shoppingcart').hide().fadeIn("slow").html(a);compareremove
				},
				error : function(a,b){
						alert("error");
					}
			});
		}
		return false;
	});	

	$("img.signin").livequery("click",function(){
		var pid = $("#pid").val();
		var frmdata = $("#loginid").serialize()+'&ajax=true';
		$("#signinfield").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
		$.ajax({
			url:'sign-in.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b)
			{
				if(a==1){
					if(pid>0){ 
						window.location = 'addproduct-C0P'+pid+'.html';
					}else{
						window.location = 'shopping-cart.html';
					}
				}
				else if(a==2)
				{
					window.location = 'checkout.html';
				}
				else{
					$("#signinfield").html(a);
				}
			},
			error:function(){
				$("#signinfield").html("<div class='ajax-loader'>error</div>");		
			}
		});
	});

	$(".submitConfirm").livequery("click",function(){
		var frmdata = $("#register").serialize()+'&ajax=true';
		$.ajax({
			url:'register.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				if(a==1){
					window.location = 'sign-in.html';
				}else{
					$("#error").show().html(a);
				}
			},
			error:function(){
				$("#signinfield").html("<div class='ajax-loader'>error</div>");		
			}
		});
	});

	$(".formbox").click(function(){
		$(".innerchk1").each( function () {
			var status = $(this).attr("checked");
			if(status == true){
				$(this).attr("checked",false);
			}else{
				$(this).attr("checked",true);
			}
		});
	});

	$("#reset").click(function() {
		return false;
	});

	$("#changepass-submit").click(function(){
		var frmdata = $("#changepassword").serialize()+'&ajax=true';
		var opassword = $("#opassword").val();
		var npassword = $("#opassword").val();
		var cpassword = $("#opassword").val();
		if(opassword=='' || npassword=='' | cpassword ==''){
			$("#message").html('<div class="errormessage">All Fields Should not be empty</div>').fadeOut(9000);
			return false;
		}
		$("#signinfield").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
		$.ajax({
			url:'change-password.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				$("#message").fadeIn(300).html(a).fadeOut(3000);
			},
			error:function(){
				$("#signinfield").html("<div class='ajax-loader'>error</div>");		
			}
		});
	});
		$("#shopping_update").click(function(){
			var frmdata = $("#shopping").serialize()+'&ajax=true';
			$.ajax({
				url:'shopping-cart.html',
				type:'POST',
				dataType:'html',
				data:frmdata,
				success:function(a,b){
					window.location = 'shopping-cart.html';
				},
				error:function(){
					$("#signinfield").html("<div class='ajax-loader'>error</div>");		
				}
			});
		 });	
		
		$("#updateaddressConfirm").click(function(){
			var frmdata = $("#address_add").serialize()+'&ajax=true';
			$.ajax({
				url:'address-book.html',
				type:'POST',
				dataType:'html',
				data:frmdata,
				success:function(a,b){
					$("#error").show();
					if(a == 1){
						window.location = 'address-book.html';
					}else{
						$("#error").html(a);
					}
				},
				error:function(){
				}
			});
		 });
// CHECK ALL FOR DELETE
		$(".delete").click(function(){
			var status = $(this).attr("checked");
			if(status == true){
				$(".deleteinner").each( function () {
					$(this).attr("checked",true);
				});				
			}else{
				$(".deleteinner").each( function () {
					$(this).attr("checked",false);
				});
			}
		});
		$(".deleteinner").click(function(){
			$(".deleteinner").each( function () {
				var status = $(this).attr("checked");											 
				if(status == false){
					$(".delete").attr("checked",false);
				}
			});
		});
// CHECK ALL FOR CHECKOUT
		$(".checkout").click(function(){
			var status = $(this).attr("checked");
			if(status == true){
				$(".checkoutinner").each( function () {
					$(this).attr("checked",true);
				});
			}else{
				$(".checkoutinner").each( function () {
					$(this).attr("checked",false);
				});
			}
		});
		
		$(".checkoutinner").click(function(){
			$(".checkoutinner").each( function () {
				var status = $(this).attr("checked");											 
				if(status == false){
					$(".checkout").attr("checked",false);
				}
			});
		});

	$("#checkoutoff").click(function(){
		$("#checkoutoffline").slideDown("Slow");
	});

	$("#checkouton").click(function(){
		$("#checkoutoffline").slideUp();
	});

	$(".buttonOut,.buttonIn").livequery("click",function(){
		var imgurl = Array();
		imgurl[0]='http://www.theitdepot.com/details-C2P3369.html';
		imgurl[1]='http://www.theitdepot.com/details-C25P4019.html';
		imgurl[2]='http://www.theitdepot.com/details-C45P3955.html';
		imgurl[3]='http://www.theitdepot.com/details-C19P4025.html';
		imgurl[4]='http://www.theitdepot.com/details-C5P375.html';
		var img = $(this).attr("id");
		$("#homebanner").css({ backgroundImage : "url(images/homebanner/"+img+".jpg)" });
		$(".buttonOut").addClass("buttonIn");
		$(".buttonOut").removeClass("buttonOut");
		imgcnt = $(this).text() - 1;
		$("#homebannerlinks").attr({href:imgurl[imgcnt]});
		$(this).addClass("buttonOut");
	});

$("#selectaddress").livequery("change",function(){
		var id = $(this).val();
		$("#error").hide();
		var frmdata = 'id='+id+'&ajax=true';
		$.ajax({
			url:'checkout.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				$("#address_update").html(a);
			},
			error:function(){
				$("#signinfield").html("<div class='ajax-loader'>error</div>");		
			}
		});
	});	

	$("#checkout").livequery("submit",function(){
		var data = $("#address_update").html();
		if(data == ''){	
			$("#error").show();
			$("#error").html("Select a Delevery address").fadeOut(2500);
			return false;
		}else{
			$("#address_update").append('<input name="action" type="hidden" value="insert" />');
			return true;	
		}
	});

	$("#draft").click(function(){
		$("#cashpayment").show();
		$("#cheqpayment").hide();
	})

	$("#dd,#cheque").click(function(){
		$("#cashpayment").hide();
		$("#cheqpayment").show();
	})

	$("#update_offline").click(function(){
		$("#errmsgs").hide();
		var payment_branch = $("#payment_branch").val();
		var transaction_id = $("#transaction_id").val();
		var  msg = '';
		if($("#draft")[0].checked==true){
			if(payment_branch==''){
				msg +='* Pls Enter Bank Name & Branch Name<br />';
			}
		}
		if($("#dd")[0].checked==true){
			if(transaction_id==''){
				msg += '* Pls Enter Draft Number<br />';
			}
		}
		if($("#cheque")[0].checked==true){
			if(transaction_id==''){
				msg += '* Pls Enter Cheque Number<br />';
			}
		}

		if(msg==''){
			var data = $("#address_update").html();
			if(data == ''){	
				$("#error").show();
				$("#error").html("Select a Delevery address").fadeOut(2500);
				return false;
			}else{
				$("#checkout").attr({action:'thanks.html'});
        		var a = $("#checkout").attr("action");
				document.checkout.submit();
				return true;
			}
		}else{
			$("#errmsgs").show();
			$("#offlineerror").html(msg);
			return false;
		}
	});
	
	$("#orderstatusbtn").click(function(){
		var frmdata = $("#chkorderstatus").serialize()+'&ajax=true';
		$.ajax({
			url:'order-status.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				$("#orderresult").html(a);
			},
			error:function(a,b){
			}
		});
	});
// COMPARE OPTIONS

/*$(".remove_compare").livequery("click",function(){
			var pid=$(this).attr('id');
			frmdata="rid="+pid+"&ajax=true";
			//$("#comparedisplay").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
			$.ajax({
				url:'compare.html',
				type:'POST',
				dataType:'html',
				data:frmdata,
				success:function(a,b){
					window.location="compare.html"
				},
				
			});
		});


		$(".compareremove").livequery("click",function(){
			var pid=$(this).attr('id');
			frmdata=$("#frm_compare").serialize()+"&did="+pid;
			//$("#comparedisplay").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
			$.ajax({
				url:'compare-filter.php',
				type:'POST',
				dataType:'html',
				data:frmdata,
				success:function(a,b){
					$("#comparedisplay").html(a);
				},
				
			});
		}); */
		
		
		$(".remove_compare").livequery("click",function(){
			var pid=$(this).attr('id');
			frmdata="rid="+pid+"&ajax=true";
			$.ajax({
			url:'compare.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				window.location="compare.html"
			},
			error:function(a,b){
					alert(a);
			}
		});
		});
		
		
		$(".compareremove").livequery("click",function(){
			var pid=$(this).attr('id');
			frmdata=$("#frm_compare").serialize()+"&did="+pid;
			//$("#comparedisplay").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
			$.ajax({
				url:'compare-filter.php',
				type:'POST',
				dataType:'html',
				data:frmdata,
				success:function(a,b){
					$("#comparedisplay").html(a);
				},
				error:function(a,b){
					alert(a);
			}
			});
		});
		
		
		
		$(".compareclass").livequery("click",function(){
			var pid=$(this).val();
			var val = $("#compare3").val();
			//alert(val);
			var check=$("#compare"+pid).attr("checked");
			if((val!=undefined) && (check==true)) 
			{
				alert("Only Three Values Can be Checked Out");
				$("#compare"+pid).attr("checked",false);
			}
			frmdata=$("#frm_compare").serialize()+"&pid="+pid;
			//$("#comparedisplay").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
			$.ajax({
				url:'compare-filter.php',
				type:'POST',
				dataType:'html',
				data:frmdata,
				success:function(a,b)
				{
					if(a==0)
					{
						$("#compare"+pid).attr("checked",false);
						alert("Please select Same Category Products");
					}
					else
					{
						$("#comparedisplay").show().html(a);
					}
				},
				error:function(a,b){
						//alert(a);
				}
			});
		});
		
	


// FILTER OPTION STARTS	
	$(".filterchk").livequery("click",function(){
								   
		$("#pageno").val("1");
		var frmdata = $("#frm_filter").serialize()+'&ajax=true&filter=true';
		
		$("#displaycontent").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
		$.ajax({
			url:'products-filter.php',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				$("#displaycontent").html(a);
			},
			error:function(a,b){
					alert(a);
			}
		});
	});	



// Remove compare items

	$(".pageclass").livequery("click",function(){
		var id = $(this).attr("id");
		$("#pageno").val(id);
			var frmdata = $("#frm_filter").serialize()+'&ajax=true&filterpaging=true';
				$("#displaycontent").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
				$.ajax({
				url:'products-filter.php',
				type:'POST',
				dataType:'html',
				data:frmdata,
				success:function(a,b){
					$("#displaycontent").html(a);
					//alert(a);
				},
				error:function(a,b){
					alert(a);
				}
			});	
		return false;
	});	
// FILTER OPTION ENDS
});
	$(document).keypress(function (e) {
		if(e.which == '13'){
			var frmdata = $("#loginid").serialize()+'&ajax=true';
			$("#signinfield").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
			$.ajax({
				url:'sign-in.html',
				type:'POST',
				dataType:'html',
				data:frmdata,
				success:function(a,b){
					if(a==1){
						window.location = 'shopping-cart.html';
					}else{
						$("#signinfield").html(a);
					}
				},
				error:function(){
					$("#signinfield").html("<div class='ajax-loader'>error</div>");
				}
			});
			return false;
		}
	});

	function Show(TabName){
		switch(TabName){
			case 'option1':
				document.getElementById("option1").style.display="inline";
				document.getElementById("option2").style.display="none";
				document.getElementById("option3").style.display="none";
				document.getElementById("option4").style.display="none";					
				document.getElementById("text1").className='featureTabThree';
				document.getElementById("text2").className='featureTabTwo';
				document.getElementById("text3").className='featureTabTwo';
				document.getElementById("text4").className='featureTabTwo';
				break;
			case 'option2':
				document.getElementById("option1").style.display="none";
				document.getElementById("option2").style.display="inline";
				document.getElementById("option3").style.display="none";
				document.getElementById("option4").style.display="none";					
				document.getElementById("text2").className='featureTabThree';
				document.getElementById("text1").className='featureTabTwo';
				document.getElementById("text3").className='featureTabTwo';
				document.getElementById("text4").className='featureTabTwo';
				break;
			case 'option3':
				document.getElementById("option1").style.display="none";
				document.getElementById("option2").style.display="none";
				document.getElementById("option3").style.display="inline";
				document.getElementById("option4").style.display="none";
				document.getElementById("text3").className='featureTabThree';
				document.getElementById("text1").className='featureTabTwo';
				document.getElementById("text2").className='featureTabTwo';
				document.getElementById("text4").className='featureTabTwo';
				break;
			case 'option4':
				document.getElementById("option1").style.display="none";
				document.getElementById("option2").style.display="none";
				document.getElementById("option3").style.display="none";
				document.getElementById("option4").style.display="inline";
				document.getElementById("text4").className='featureTabThree';
				document.getElementById("text3").className='featureTabTwo';
				document.getElementById("text1").className='featureTabTwo';
				document.getElementById("text2").className='featureTabTwo';
				break;
		}	
	}
	
	
	

	
	function ShowAnt(TabName){
			switch(TabName){
				case 'option1':
					document.getElementById("option1").style.display="block";
					document.getElementById("option2").style.display="none";
					document.getElementById("option3").style.display="none";
					document.getElementById("option4").style.display="none";
					document.getElementById("option5").style.display="none";
					document.getElementById("option6").style.display="none";
					document.getElementById("text1").className='antecon';
					document.getElementById("text2").className='antecoff';
					document.getElementById("text3").className='antecoff';
					document.getElementById("text4").className='antecoff';
					document.getElementById("text5").className='antecoff';
				    document.getElementById("text6").className='antecoff';
				break;
				case 'option2':
					document.getElementById("option1").style.display="none";
					document.getElementById("option2").style.display="block";
					document.getElementById("option3").style.display="none";
					document.getElementById("option4").style.display="none";
					document.getElementById("option5").style.display="none";
					document.getElementById("option6").style.display="none";
					document.getElementById("text1").className='antecoff';
					document.getElementById("text2").className='antecon';
					document.getElementById("text3").className='antecoff';
					document.getElementById("text4").className='antecoff';
					document.getElementById("text5").className='antecoff';
					document.getElementById("text6").className='antecoff';
				break;
				case 'option3':
					document.getElementById("option1").style.display="none";
					document.getElementById("option2").style.display="none";
					document.getElementById("option3").style.display="block";
					document.getElementById("option4").style.display="none";
					document.getElementById("option5").style.display="none";
					document.getElementById("option6").style.display="none";
					document.getElementById("text1").className='antecoff';
					document.getElementById("text2").className='antecoff';
					document.getElementById("text3").className='antecon';
					document.getElementById("text4").className='antecoff';
					document.getElementById("text5").className='antecoff';
					document.getElementById("text6").className='antecoff';
				break;
				case 'option4':
					document.getElementById("option1").style.display="none";
					document.getElementById("option2").style.display="none";
					document.getElementById("option3").style.display="none";
					document.getElementById("option4").style.display="block";
					document.getElementById("option5").style.display="none";
					document.getElementById("option6").style.display="none";
					document.getElementById("text1").className='antecoff';
					document.getElementById("text2").className='antecoff';
					document.getElementById("text3").className='antecoff';
					document.getElementById("text4").className='antecon';
					document.getElementById("text5").className='antecoff';
					document.getElementById("text6").className='antecoff';
				break;
					case 'option5':
					document.getElementById("option1").style.display="none";
					document.getElementById("option2").style.display="none";
					document.getElementById("option3").style.display="none";
					document.getElementById("option4").style.display="none";
					document.getElementById("option5").style.display="block";
					document.getElementById("option6").style.display="none";
					document.getElementById("text1").className='antecoff';
					document.getElementById("text2").className='antecoff';

					document.getElementById("text3").className='antecoff';
					document.getElementById("text4").className='antecoff';
					document.getElementById("text5").className='antecon';
					document.getElementById("text6").className='antecoff';
					break;
					case 'option6':
					document.getElementById("option1").style.display="none";
					document.getElementById("option2").style.display="none";
					document.getElementById("option3").style.display="none";
					document.getElementById("option4").style.display="none";
					document.getElementById("option5").style.display="none";
					document.getElementById("option6").style.display="block";
					document.getElementById("text1").className='antecoff';
					document.getElementById("text2").className='antecoff';
					document.getElementById("text3").className='antecoff';
					document.getElementById("text4").className='antecoff';
					document.getElementById("text5").className='antecoff';
					document.getElementById("text6").className='antecon';
				break;
			}
		}