var Server=top.location.host;
if(Server=="localhost")
	var https_url="";
else
	var https_url = (("https:" == document.location.protocol) ? "https://www.theitdepot.com/" : "http://www.theitdepot.com/");
if(Server=="localhost")
	var web_https_url="";
else
	var web_https_url = "https://www.theitdepot.com/";

function klinnk_gateway()
{
	document.ECom.submit();
}

function oos_inform()
{
	var email=$("#email").val();
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	if(email=="")
	{
		alert("Please Enter Your Email");
		return false;
	}
	if(!pattern.test(email))
	{
		alert("Please Enter Valid Email ID");
		return false;
	}
	var frmdata = $("#oos_form").serialize();
	$.ajax({
		url:'outofstock_informme.php',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b){
			if(a==1)
			{
				alert("Thank you for using Stock Availability");
				return false;
			}
			else
			{
				alert(a);
				return false;
			}
		},
		error:function(a,b){
				alert(a);
		}
	});	
}
function check_availability()
{
	var model=$("#model").val();
	var brand=$("#brand").val();
	var email=$("#email").val();
	var mobile=$("#mobile").val();
	if(model=="")
	{
		alert("Please Enter Model Name");
		return false;
	}
	if(brand=="")
	{
		alert("Please Enter brand Name");
		return false;
	}
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	if(email=="")
	{
		alert("Please Enter Your Email");
		return false;
	}
	if (!pattern.test(email))
	{
		alert("Please Enter Valid Email ID");
		return false;
	}
	if(mobile=="")
	{
		alert("Please Enter Your Mobile Number");
		return false;
	}
	if(Number(mobile)==0)
	{
		alert("Please Enter Your Valid 10 Digit Mobile Number");
		return false;
	}
	var frmdata = $("#enquiry").serialize()+'&enquiry=true';
	$.ajax({
		url:'laptop_charger_check.php',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b){
			if(a==1)
			{
				window.location="laptop_charger_check.php?sentmail=true";
			}
			else
			{
				alert(a);
			}
		},
		error:function(a,b){
				alert(a);
		}
	});	
	
}


function barebonepc_addtocart(bpc_id)
{
	var pid = $("#pid").val();
	var frmdata = $("#bpc_products").serialize()+'&addtocart=true';
	$.ajax({
	url:'barebonepc_details.php',
	type:'POST',
	dataType:'html',
	data:frmdata,
	success:function(a,b)
	{
		//alert(a);
		//$("#display_error").html(a);
		window.location = web_https_url+'shopping-cart.html';
	},
	error:function(){
		$("#signinfield").html("<div class='ajax-loader'>error</div>");		
	}
	});
}

function lowestprice()
{
	//$("#filter_display").html("<div class='ajax-loader' style='height:150px'><img src='images/ajax-loader.gif'></div>");
	var frmdata = $("#tellus_lowestprice").serialize()+'&tellus_lowestprice=true';
	$.ajax({
		url:'details.php',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b){
			if(a==1)
			{
				alert("Thank you for your feedback");
				$("#facebox").hide();
			}
			else
			{
				alert(a);
			}
		},
		error:function(a,b){
				alert(a);
		}
	});	
}

function filter_click(subcategory,brand,price,feature,orderby,displayno,freeship_yes,clearence_yes)
{
	$("#pageno").val("1");
	if(displayno!="")
	{
		$("#filter-limit").val(displayno);
		$("#filter_display_limit").html(displayno);
	}
	if(orderby!="")
	{
		$("#filter-orderby").val(orderby);
		if(orderby=="price_asc")
			ord="Price: Low to High";
		else if(orderby=="price_desc")
			ord="Price: High to Low";
		else if(orderby=="brand_asc")
			ord="Brand: A to Z";
		else if(orderby=="brand_desc")
			ord="Brand: Z to A";
		$("#filter_order_by").html(ord);
	}
	$("#free_shipping").val(freeship_yes);
	$("#clearence").val(clearence_yes);
	if(subcategory!="")
	{
		if($("#"+subcategory).is(':checked'))
			$("#"+subcategory).attr('checked', false);
		else
			$("#"+subcategory).attr('checked', true);
	}
	if(brand!="")
	{
		if($("#"+brand).is(':checked'))
			$("#"+brand).attr('checked', false);
		else
			$("#"+brand).attr('checked', true);
	}
	if(price!="")
	{
		if($("#"+price).is(':checked'))
			$("#"+price).attr('checked', false);
		else
			$("#"+price).attr('checked', true);
	}
	if(feature!="")
	{
		if($("#"+feature).is(':checked'))
			$("#"+feature).attr('checked', false);
		else
			$("#"+feature).attr('checked', true);
	}
	var DivHeight = document.getElementById("filter_display").offsetHeight;
	$("#filter_display").html("<div class='ajax-loader' style='height:"+DivHeight+"px'><img src='images/ajax-loader.gif'></div>");
	var frmdata = $("#frm_filter").serialize()+'&ajax=true&filter=true';
	$.ajax({
		url:'category_filter.php',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b){
			$("#filter_display").html(a);
			$("#PageTop").focus();
		},
		error:function(a,b){
				alert(a);
		}
	});
}


//AutoComplete Javascript Start
$().ready(function() {
	
	$("#keywords").autocomplete("search_product.php", {
		width: 300,
		selectFirst: false
	});
	
	/*$("#keywords").result(function(event, data, formatted) {
		if (data)
			document.getElementById("ProductId").value=data[1];
			//$(this).parent().next().find("input").val(data[1]);
	});*/
	
	
	function formatItem(row) {
		return row[0] + " (<strong>id: " + row[1] + "</strong>)";
	}
	function formatResult(row) {
		return row[0].replace(/(<.+?>)/gi, '');
	}
	
});
//AutoComplete Javascript End
	$(".submitConfirm").livequery("click",function(){
		var frmdata = $("#register").serialize()+'&ajax=true';
		$.ajax({
			url:https_url+'register.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				if(a==1){
					window.location = web_https_url+'myaccount.html';
				}else{
					b="<div class='erroemessage'>"+a+"</div>";
					$("#error").show().html(b);
					$("#bottom_error").show().html(b);
					alert(a);
				}
			},
			error:function(){
				$("#signinfield").html("<div class='ajax-loader'>error</div>");		
			}
		});
	});


function CheckoutRegisterConfirm()
{
	var frmdata = $("#register").serialize()+'&ajax=true';
	$.ajax({
		url:https_url+'sign-up.html',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b)
		{
			if(a==1){
				window.location = web_https_url+'checkout.html';
			}else{
				b="<div class='erroemessage'>"+a+"</div>";
				$("#error").show().html(b);
				$("#bottom_error").show().html(b);
				alert(a);
			}
		},
		error:function()
		{
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
	});
}

function SignInFormSubmit()
{
	document.forms['loginid'].submit();
}
function RegisterFormSubmit()
{
	document.forms['register'].submit();
}

function search_page(page,keywords,viewall,viewbyprice)
{
	document.getElementById("page").value=page;
	document.getElementById("keywords").value=keywords;
	document.getElementById("viewall").value=viewall;
	document.getElementById("viewbyprice").value=viewbyprice;
	document.search_page.submit();
}


// BUILD OWN PC FUNCTIONS //


function get_prize(id,divid,imgdiv)
{
	a=id.split('#');
	img_name=a[1];
	imgpath=a[2];
	itemcategory=a[3];
	itemproduct=a[4];
	pid=a[0];
	old_amt=$("#"+divid).text();
	//old_amt=old_amt.substring(3);
	tprice = $("#total_prize").text();
	$.ajax({
		url:'buildownpc-details.html?showprice=true&prodid='+pid+'&old_price='+old_amt+'&net_amt='+tprice,
		type:'POST',
		dataType:'html',
		success:function(a,b)
		{
			old_amt=$("#"+divid).text();
			//old_amt=old_amt.substring(3);
			if (old_amt=='')
			{
				old_amt=0;
			}
			if(pid==0)
			{
				img_name='no-image.jpg';
				imgpath="http://www.theitdepot.com/images/proimages/";
				i="<img src ="+imgpath+img_name+" alt='No Image' width=68 height=66 title='No Image' border = 0>";
				$("#"+imgdiv).html(i);
				b="Rs."+0;
				//$("#"+divid).text(a);
			}
			else
			{
				i="<img src ="+imgpath+img_name+" alt='"+itemproduct+"' width=68 height=66 title='"+itemproduct+"' border = 0>";
				$("#"+imgdiv).html(i);
				//$("#"+divid).text(a);
			}
			$("#display_total").html(a);
			newprice=$("#new_price").val();
			$("#"+divid).text(newprice);
			//tprice = $("#total_prize").text();
			/*tprice=tprice.substring(3);
			sub_total=Math.round(parseInt(tprice) - parseInt(old_amt));
			newamt = $("#"+divid).text();
			newamt = newamt.substring(3);	
			grand_total=Math.round(parseInt(sub_total) + parseInt(newamt));
			discount_percent=0.02;
			discount_prize=Math.round(parseInt(grand_total) * parseFloat(discount_percent));
			alert(discount_prize);
			grant_tot=Math.round(parseInt(grand_total) - parseInt(discount_prize));
			alert(grant_tot);
			$("#total_prize").html("Rs."+grand_total);
			$("#discount_prize").html("Rs."+discount_prize);
			$("#grand_prize").html("Rs."+grant_tot);*/
		},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
	});
}


function add_moreproduts()
{
	document.getElementById("other_categories").style.display="block";
}


function get_moreproducts()
{
	document.getElementById("otherproducts").style.display="block";
	document.getElementById("other_prod_select").style.display="block";
	$("#other_prod_select").html("<div class='buildownpc_ajax-loader'><img  src='images/ajax-loader.gif'></div>");
	id=document.getElementById("ownpc_category").value; 
	var frmdata = 'id='+id+'&ajax=true';
	$.ajax({
		url:'buildownpc-details.html?catid='+id,
		type:'POST',
		dataType:'html',
		success:function(a,b)
		{
			document.getElementById("otherproducts").style.display="block";
			$("#other_prod_select").html(a);
		},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
	});
	
}

function removeFormField(id)
{
	id1=id.substring(4);
	product_amt=$("#bop_prize"+id1).text();
	product_amt=product_amt.substring(3);
	disc_per=$("#disc_per").val();
	tprice = $("#total_prize").text();
	sub_total=Math.round(parseInt(tprice) - parseInt(product_amt));
	disc_amt=Math.round(parseInt(sub_total) * parseFloat(disc_per));
	net_amt=Math.round(parseInt(sub_total) - parseInt(disc_amt));
	$("#total_prize").html(sub_total);
	$("#discount_prize").html(disc_amt);
	$("#grand_prize").html(net_amt);
	$(id).remove();
}


function addFormField()
{
	var id = document.getElementById("id").value;
	var category=document.getElementById("ownpc_category").value;
	var product=document.getElementById("other_products").value;
	var frmdata = $("#bop_products").serialize()+'&bop_list=true';
	document.getElementById("product_listings").style.display="block";
	$("#product_listings").html("<div class='buildownpc_ajax-loader'><img  src='images/ajax-loader.gif'></div>");
	$.ajax({
		url:'buildownpc-details.html',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b)
		{
			id1=id-1;
			$("#divTxt").append(a);
			product_amt=$("#bop_prize"+id1).text();			
			product_amt=product_amt.substring(3);	
			disc_per=$("#disc_per").val();
			tprice = $("#total_prize").text();
			sub_total=Math.round(parseInt(product_amt) + parseInt(tprice));
			disc_amt=Math.round(parseInt(sub_total) * parseFloat(disc_per));
			net_amt=Math.round(parseInt(sub_total) - parseInt(disc_amt));
			$("#total_prize").html(sub_total);
			$("#discount_prize").html(disc_amt);
			$("#grand_prize").html(net_amt);
			document.getElementById("product_listings").style.display="none";
		}
	});
	id = (id - 1) + 2;
	document.getElementById("id").value = id;
}


function get_details(details)
{
	var address=document.getElementById(details).value;
	a=address.split('#');
	pid=a[0];
	itemcategory=a[3];
	itemproduct=a[4];
	window.open("details-"+itemproduct+"_C"+itemcategory+"P"+pid+".html");	
}




//  BUILD OWN PC ENDS //




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

function advsearch_validation()
{
	var brand_list	=	document.getElementById("brand_list").value;
	var cate		=	document.getElementById("cate").value;
	var max_price	=	document.getElementById("max_price").value;
	var min_price	=	document.getElementById("min_price").value;
	var cate		=	document.getElementById("cate").value;
	if(brand_list=='' && cate=='')
	{
		alert("Please Select BrandList or Category");
		return false
	}
	if(max_price!='' && min_price!='')
	{
		if(parseInt(min_price)>=parseInt(max_price))
		{
			alert("Maxmium Prize should be greater than Minimum Prize");
			return false;
		}
	}
	$("#search_content").html("<div class='ajax-loader'><img  src='images/loading.gif'></div>");
	var frmdata = $("#adv_search").serialize()+'&action=true';
	$.ajax({
		url:'advanced_search.html',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b)
		{
			$("#search_content").html(a);
		},
		error:function(){
			$("#search_content").html("<div class='ajax-loader'>error</div>");		
		}
	});
}

$(".NewsletterSignUp").livequery("click",function(){
	var email=$("#news_email").val();
	var name=$("#news_name").val();
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	if(email=="")
	{
		alert("Please Enter Your Email ID");
		return false;
	}
	if (!pattern.test(email))
	{
		alert("Please Enter Valid Email ID");
		return false;
	}
	if(name=="")
	{
		alert("Please Enter Your Name");
		return false;
	}
	frmdata="news_email="+email+"&news_name="+name+"&register=true";
	$.ajax({
		   url:'newsletter_signup.php',
		   type:'POST',
		   dataType:'html',
		   data:frmdata,
		   success:function(a,b){
			   if(a=="Active")
			   {
				   alert("Your Eamil Id Was Already Registered");
				   return false;
			   }
			   else
			   {
					alert("Thank you for your subscribtion. \n Please Verify your mail and Confirm");
					window.location = 'http://www.theitdepot.com/newsletter_signup_thanks.php?e='+a;
			   }
		   },
		   error:function(a,b){
			   alert(a);
		   }
 	});
})

$(".adv_pageclass").livequery("click",function(){
	var id = $(this).attr("id");
	$("#pageno").val(id);
		var frmdata = $("#search").serialize()+'&search_paging=true';
			$("#search_content").html("<div class='ajax-loader'><img  src='images/loading.gif'></div>");
			$.ajax({
			url:'advanced_search.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				$("#search_content").html(a);
			},
			error:function(a,b){
				alert(a);
			}
		});	
	return false;
});	


function contact_us()
{
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	var user_id			=	document.getElementById("usr_name").value;
	var usr_mail		=	document.getElementById("usr_mail").value;
	var usr_mobile		=	document.getElementById("usr_mobile").value;
	var sales_support	=	document.getElementById("sales_support").value;
	var txt_captcha		=	document.getElementById("txt_captcha").value;
	var captcha			=	document.getElementById("captcha").value;
	var captcha			=	captcha.toLowerCase(); 

	if(user_id=='')
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please Enter the Name";
		$("#errormessage").html(a);
		return false
	}
	if(usr_mail=='')
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please Enter the E-Mail";
		$("#errormessage").html(a);
		return false
	}
	if (!pattern.test(usr_mail))
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please enter Correct Email ID";
		$("#errormessage").html(a);
		return false;
	}

	if(usr_mobile!='' && isNaN(usr_mobile)) 
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please Enter the Valid Mobile Number";
		$("#errormessage").html(a);
		return false
	}

	if(sales_support=='')
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please Enter the Sales and Support";
		$("#errormessage").html(a);
		return false
	}
	
	if(txt_captcha=='')
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please Enter The Security Code";
		$("#errormessage").html(a);
		return false;
	}
	if(txt_captcha!='' && txt_captcha!=captcha)
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please Enter the Valid Security Code";
		$("#errormessage").html(a);
		return false;
	}

	else
	{
		var frmdata = $("#contactus").serialize()+'&page=true';
		$.ajax({
		url:'static-pages.html',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b)
		{
			alert("Thank You for visiting www.theitdepot.com. A support executive shall get in touch wih you shortly");
			window.location = 'http://www.theitdepot.com';				
			return true;
		}

		});
	}
}


function refer_friend()
{
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	var user_id			=	document.getElementById("user_id").value;
	var fri_name		=	document.getElementById("fri_name").value;
	var fri_emailid		=	document.getElementById("fri_emailid").value;
	var msg				=	document.getElementById("msg").value;
	var txt_captcha		=	document.getElementById("txt_captcha").value;
	var captcha			=	document.getElementById("captcha").value;
	var captcha			=	captcha.toLowerCase(); 

	if(user_id=='')
	{
		var username		=	document.getElementById("username").value;
		var password		=	document.getElementById("password").value;
		if(username=='')
		{
			document.getElementById("errormessage").style.display = 'block';
			a="Please Enter the E-Mail";
			$("#errormessage").html(a);
			return false
		}
		if(password=='')
		{
			document.getElementById("errormessage").style.display = 'block';
			a="Please Enter the password";
			$("#errormessage").html(a);
			return false
		}
	}


	if(fri_name=='')
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please Enter Referer name";
		$("#errormessage").html(a);
		return false;
	}
	if(fri_emailid=='')
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please Enter Referer Email";
		$("#errormessage").html(a);
		return false;
	}
	
	if (!pattern.test(fri_emailid))
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please enter Correct Email ID";
		$("#errormessage").html(a);
		return false;
	}
	if(msg=='')
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please Enter Message";
		$("#errormessage").html(a);
		return false;
	}
	if(txt_captcha=='')
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please Enter The Security Code";
		$("#errormessage").html(a);
		return false;
	}
	if(txt_captcha!='' && txt_captcha!=captcha)
	{
		document.getElementById("errormessage").style.display = 'block';
		a="Please Enter the Valid Security Code";
		$("#errormessage").html(a);
		return false;
	}
	var frmdata = $("#referral").serialize()+'&insert=true';
		$.ajax({
		url:'referral.html',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b)
		{
			if(a=='0')
			{
				document.getElementById("errormessage").style.display = 'block';
				a="This Email Id Already Exists";
				$("#errormessage").html(a);
			}
			else if(a=='2')
			{
				document.getElementById("errormessage").style.display = 'block';
				a="Please Enter Correct Login Details.<br /> If Not Registered, Please Register to Refer";
				$("#errormessage").html(a);
			}
			else
			{
				$("#referral").attr({action:'http://www.theitdepot.com/referral.html'});
				document.referral.submit();
				return true;
			}
		}

	});

}

function validation()
{
	var brand_list	=	document.getElementById("brand_list").value;
	var cate		=	document.getElementById("cate").value;
	var max_price	=	document.getElementById("max_price").value;
	var min_price	=	document.getElementById("min_price").value;
	var cate		=	document.getElementById("cate").value;

	
	if(brand_list=='' && cate=='')
	{
		alert("Please Select BrandList or Category");
		return false
	}
	
	if(max_price!='' && min_price!='')
	{
		if(min_price >=max_price)
		{
			alert("Maxmium Prize should be greater than Minimum Prize");
			return false;
		}
	}
	else
	{
		var frmdata = $("#search").serialize()+'&action=true';
		$.ajax({
			url:'advanced_search.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b)
			{
				$("#search_content").html(a);
			},
			error:function(){
				$("#get_subcategory").html("<div class='ajax-loader'>error</div>");		
			}
		});
	}
}

function search_getsubcate()
{
	var cateid=document.getElementById("cate").value;
	$.ajax({
		url:'advanced_search.html?categoryid='+cateid+'&category=true',
		type:'POST',
		dataType:'html',
		success:function(a,b)
		{
			$("#get_subcategory").html(a);
			//$("#errormsg").html();
		},
		error:function(){
			$("#get_subcategory").html("<div class='ajax-loader'>error</div>");		
		}
	});
}

function coupon_verify()
{
	var coupan=document.getElementById("coupan").value;
	var logitech_coupon=document.getElementById("logitech_coupon").value;
	var sub_total=document.getElementById("sub_total").value;
	if(sub_total!="")
	{
		stotal=Number(sub_total);
		if(stotal<0)
		{
			alert("Invalid Selection of Coupon \n Already Sub total Less Than Zero");
			return false;
		}
	}
	$("#coupon_verification").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
	$.ajax({
		url:https_url+'shipping-method.html?coupon='+coupan+'&coupon_code=true&logitech_coupon='+logitech_coupon,
		type:'POST',
		dataType:'html',
		success:function(a,b)
		{
			$("#coupon_verification").html(a);
			$("#errormsg").html();
		},
		error:function(){
			$("#coupon_verification").html("<div class='ajax-loader'>error</div>");		
		}
	});
}

function cart_check_signin()
{
	document.getElementById("checkout_product_session").value = "0";
	var frmdata = $("#loginid").serialize()+'&checkout_signin=true';
	$.ajax({
	url:https_url+'sign-in.html',
	type:'POST',
	dataType:'html',
	data:frmdata,
	success:function(a,b)
	{
		if(a==1)
		{
			window.location = web_https_url+'checkout.html';				
		}
	},
	error:function(){
		$("#signinfield").html("<div class='ajax-loader'>error</div>");		
	}
	});
}

function bop_checkout()
{
	msg="";
	processors=document.getElementById('ownpc_processors').value;
	a=processors.split('#');
	processorsid=a[0];
	if(processorsid==0)
	{
		msg="Please select Processor \n";
	}
	mboard=document.getElementById('ownpc_mboard').value;
	a=mboard.split('#');
	mboardid=a[0];
	if(mboardid==0)
	{
		//msg+="Please select Mother Board \n";
	}
	ram=document.getElementById('ownpc_ram').value;
	a=ram.split('#');
	ramid=a[0];
	if(ramid==0)
	{
		msg+="Please Select Memory Ram \n";
	}
	harddrives=document.getElementById('harddrives_details').value;
	a=harddrives.split('#');
	harddrivesid=a[0];
	if(harddrivesid==0)
	{
		msg+="Please select Hard Disc \n";
	}
	cabinets=document.getElementById('ownpc_cabinets').value;
	a=cabinets.split('#');
	cabinetsid=a[0];
	if(cabinetsid==0)
	{
		msg+="Please Select Cabinet \n";
	}
	if(msg!="")
	{
		alert(msg);
		return false;
	}
	else
	{
		var pid = $("#pid").val();
		var frmdata = $("#bop_products").serialize()+'&checkout_signin=true';
		$.ajax({
		url:'buildownpc.html',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b)
		{
				window.location = web_https_url+'checkout.html';	
		},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
		});
	}
}

function bop_shoppingcart()
{
	msg="";
	processors=document.getElementById('ownpc_processors').value;
	a=processors.split('#');
	processorsid=a[0];
	if(processorsid==0)
	{
		msg="Please select Processor \n";
	}
	mboard=document.getElementById('ownpc_mboard').value;
	a=mboard.split('#');
	mboardid=a[0];
	if(mboardid==0)
	{
		//msg+="Please select Mother Board \n";
	}
	ram=document.getElementById('ownpc_ram').value;
	a=ram.split('#');
	ramid=a[0];
	if(ramid==0)
	{
		msg+="Please Select Memory Ram \n";
	}
	harddrives=document.getElementById('harddrives_details').value;
	a=harddrives.split('#');
	harddrivesid=a[0];
	if(harddrivesid==0)
	{
		msg+="Please select Hard Disc \n";
	}
	cabinets=document.getElementById('ownpc_cabinets').value;
	a=cabinets.split('#');
	cabinetsid=a[0];
	if(cabinetsid==0)
	{
		msg+="Please Select Cabinet \n";
	}
	if(msg!="")
	{
		alert(msg);
		return false;
	}
	else
	{
		var pid = $("#pid").val();
		var frmdata = $("#bop_products").serialize()+'&checkout_signin=true';
		$.ajax({
		url:'buildownpc.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>");		
		}
		});
	}
}

function bop_check_logout()
{
	msg="";
	processors=document.getElementById('ownpc_processors').value;
	a=processors.split('#');
	processorsid=a[0];
	if(processorsid==0)
	{
		msg="Please select Processor \n";
	}
	mboard=document.getElementById('ownpc_mboard').value;
	a=mboard.split('#');
	mboardid=a[0];
	if(mboardid==0)
	{
		//msg+="Please select Mother Board \n";
	}
	ram=document.getElementById('ownpc_ram').value;
	a=ram.split('#');
	ramid=a[0];
	if(ramid==0)
	{
		msg+="Please Select Memory Ram \n";
	}
	harddrives=document.getElementById('harddrives_details').value;
	a=harddrives.split('#');
	harddrivesid=a[0];
	if(harddrivesid==0)
	{
		msg+="Please select Hard Disc \n";
	}
	cabinets=document.getElementById('ownpc_cabinets').value;
	a=cabinets.split('#');
	cabinetsid=a[0];
	if(cabinetsid==0)
	{
		msg+="Please Select Cabinet \n";
	}
	if(msg!="")
	{
		alert(msg);
		return false;
	}
	else
	{
		var pid = $("#pid").val();
		var frmdata = $("#bop_products").serialize()+'&checkout_signout=true';
		$.ajax({
		url:'buildownpc.html',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b)
		{
			if(a==1)
			{
				window.location = web_https_url+'checkout.html';
			}
			else 
			{
				alert("Please Enter Valid Email and Password");	
			}
		},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");	
		}
		});
	}
}

function bop_cart_logout()
{
	msg="";
	processors=document.getElementById('ownpc_processors').value;
	a=processors.split('#');
	processorsid=a[0];
	if(processorsid==0)
	{
		msg="Please select Processor \n";
	}
	mb_length=$('#ownpc_mboard option').length;
	mboard=document.getElementById('ownpc_mboard').value;
	a=mboard.split('#');
	mboardid=a[0];
	if(mboardid==0)
	{
		//msg+="Please select Mother Board \n";
	}
	ram=document.getElementById('ownpc_ram').value;
	a=ram.split('#');
	ramid=a[0];
	if(ramid==0)
	{
		msg+="Please Select Memory Ram \n";
	}
	harddrives=document.getElementById('harddrives_details').value;
	a=harddrives.split('#');
	harddrivesid=a[0];
	if(harddrivesid==0)
	{
		msg+="Please select Hard Disc \n";
	}
	cabinets=document.getElementById('ownpc_cabinets').value;
	a=cabinets.split('#');
	cabinetsid=a[0];
	if(cabinetsid==0)
	{
		msg+="Please Select Cabinet \n";
	}
	if(msg!="")
	{
		alert(msg);
		return false;
	}
	else
	{
		var pid = $("#pid").val();
		var frmdata = $("#bop_products").serialize()+'&checkout_signout=true';
		$.ajax({
		url:'buildownpc.html',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b)
		{
			if(a==1)
			{
				window.location = 'shopping-cart.html';				
			}
			else 
			{
				alert("Please Enter Valid Email and Password");		
			}
		},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
		});
	}
}


function cart_check()
{
	var uname = $("#username").val();
	var pword = $("#password").val();
	if(uname!="" || pword!="")
	{
		document.getElementById("login").style.display="none";
		document.getElementById("error_mess").style.display="block";
		$("#error_mess").html("<div class='ajax-loader'><img  src='images/loading.gif'></div>");
		document.getElementById("checkout_product_session").value = "0";
		var frmdata = $("#loginid").serialize()+'&checkout=true';
		$.ajax({
			url:https_url+'sign-in.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b)
			{
				document.getElementById("error_mess").style.display="none";
				document.getElementById("login").style.display="block";
				if(a==1)
				{
					window.location = web_https_url+'checkout.html';
				}
				else 
				{
					alert("Please Enter Valid Email and Password");		
				}
			},
			error:function(){
				$("#error_mess").html("<div class='ajax-loader'>error</div>");		
			}
		});
	}
	else
	{
		$("#loginid").attr({action:web_https_url+'sign-in.html'});
		document.loginid.submit();
		return true;
	}
}



function product_checkout_signin()
{
	var uname = $("#username").val();
	var pword = $("#password").val();
	if(uname!="" || pword!="")
	{
		document.getElementById("login").style.display="none";
		document.getElementById("error_mess").style.display="block";
		$("#error_mess").html("<div class='ajax-loader'><img  src='images/loading.gif'></div>");
		document.getElementById("checkout_product_session").value = "0";
		var frmdata = $("#loginid").serialize()+'&checkout=true';
		$.ajax({
			url:https_url+'sign-in.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b)
			{
				document.getElementById("error_mess").style.display="none";
				document.getElementById("login").style.display="block";
				if(a==1)
				{
					window.location = web_https_url+'checkout.html';
				}
				else 
				{
					alert("Please Enter Valid Email and Password");		
				}
			},
			error:function(){
				$("#error_mess").html("<div class='ajax-loader'>error</div>");		
			}
		});
	}
	else
	{
		$("#loginid").attr({action:web_https_url+'sign-up.html'});
		document.loginid.submit();
		return true;
	}
}



$("#selectaddress").livequery("change",function(){
		var id = $(this).val();
		$("#error").hide();
		var frmdata = 'id='+id+'&ajax=true';
		$.ajax({
			url:https_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>");		
			}
		});
	});	


function check_checkout_ebs()
{
	var amt=$("#grand_total").val();
	if(amt<=0)
	{
		alert("Invalid Amount");
		return false;
	}
	<!--$("#checkout").attr({action:'https://www.ebs.in/pg/www/ma/transaction/register/'});-->
	$("#checkout").attr({action:web_https_url+'ebs_checkout.php'});
	var a = $("#checkout").attr("action");
	document.checkout.submit();
	return true;
}

function check_checkout_klinnk()
{
	var amt=$("#grand_total").val();
	if(amt<=0)
	{
		alert("Invalid Amount");
		return false;
	}
	<!--$("#checkout").attr({action:'https://www.ebs.in/pg/www/ma/transaction/register/'});-->
	$("#checkout").attr({action:web_https_url+'klinnk_checkout.php'});
	var a = $("#checkout").attr("action");
	document.checkout.submit();
	return true;
}

function radio_validation()
{
	var counted=0;var countes=0;
	var element=document.getElementById("stotal").value;
	for(var j=0; j<element; j++)
	{
		
		if(document.getElementById("courier_id"+j).checked==true)
		{
			var cid=document.getElementById("courier_id"+j).value;
			var shipping_cost=document.getElementById("courier_cost"+cid).value;
			var countes=1;
		}
	}
	alert(shipping_cost);
	return false;
	if (countes!=1)
	{
		alert("Please select any Shipping Option");
		return false
	}
	else
	{
		$("#shipping_cost").val(shipping_cost);
		$("#shipping_method").attr({action:web_https_url+'order_confirm.html'});
		var a = $("#shipping_method").attr("action");
		document.shipping_method.submit();
		return true;
	}
}


function shiping_checking()
{
	frmdata=$('#checkout_details').serialize();
	$.ajax({
		url:https_url+'shipping_method.php',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b)
		{
			$('#checkout_content2').html(a);
			$('#checkout_content2').show();
		},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
	});
}


function checking()
{
	var chks = document.getElementsByName('ccheckbox[]');
	var count=0;
	for (var i = 0; i < chks.length; i++)
	{
		if (chks[i].checked)
		{
			count=count+1;
		}
	}
	var chks = document.getElementsByName('ccheckbox2[]');
	for (var i = 0; i < chks.length; i++)
	{
		if (chks[i].checked)
		{
			count=count+1;
		}
	}
	var chks = document.getElementsByName('checkbox_desktop[]');
	for (var i = 0; i < chks.length; i++)
	{
		if (chks[i].checked)
		{
			count=count+1;
		}
	}
	if(count=='0')
	{
		$("#errormsg").show();	
		return false;
	}
	document.shopping.submit();
}

function qty_update(shop_id)
{
	var zero='.00'
	shop_id=shop_id;
	var qty = $("#qty"+shop_id).val();
	if(Number(qty)<=0)
	{
		alert("Invalid Quantity");
		return false;
	}
	var webprice = $("#webprice"+shop_id).text();
	var total = $("#total"+shop_id).text();
	var g_tot = $("#grand_total").text();
	var sp_amt = $("#s_amt"+shop_id).val();
	if(!isNaN(sp_amt))
	{ 
		//var shipp_amt=Math.round((parseFloat(sp_amt) * parseFloat(qty))*100)/100;
		//$('#shipp_amt'+shop_id).html(shipp_amt+zero);
	}
	else
	{
		shipp_amt=0;
	}
	shipp_amt=0;
	var tot=Math.round(((parseFloat(qty) * parseFloat(webprice) + parseFloat(shipp_amt)))*100)/100;
	var grand_tot=Math.round((parseFloat(g_tot) - parseFloat(total)+ parseFloat(tot))*100)/100;
	$('#total'+shop_id).html(tot+zero);	
	$('#grand_total').html(grand_tot+zero);
	frmdata = 'shopid='+shop_id+'&qty='+qty;
	$.ajax({
		url:'shopping-cart.html',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b){
			},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
	});
}

function category_shopcart_addlist(id)
{
	$("#displaycontent").html("<div class='ajax-loader'><img  src='images/loading.gif'></div>");
	$.ajax({
		url:'addproduct.php?prodid='+id+'&shop_cart=true',
		type:'POST',
		dataType:'html',
		success:function(a,b)
		{
			$("#displaycontent").html(a);
		},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
	});
}

function shopcart_addlist(id)
{
	$("#shopping_cart").html("<div class='ajax-loader'><img  src='images/loading.gif'></div>");
	$.ajax({
		url:'details.php?prodid='+id+'&shopcart=true',
		type:'POST',
		dataType:'html',
		success:function(a,b)
		{
			$("#shopping_cart").html(a);
		},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
	});
}


function shopcart_addlist_index(id)
{
	
	$.ajax({
		url:'addproduct.php?prodid='+id+'&shop_cart_index=true',
		type:'POST',
		dataType:'html',
		success:function(a,b)
		{
			$("#total_products").html(a);
			window.location='shopping-cart.html';
		},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
	});	
}


	$(".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);
			}
			});
		});
	


function combo_qty_update(combo_updateid)
	{
		var zero='.00'
		var combo_webprice = $("#combo_webprice"+combo_updateid).text();
		var combo_qty = $("#combo_qty"+combo_updateid).val();
		if(Number(combo_qty)<=0)
		{
			alert("Invalid Quantity");
			return false;
		}
		var combo_shipamt = $("#combo_samt"+combo_updateid).val();
		var combo_tot = $("#combo_tot"+combo_updateid).text();
		var g_tot = $("#grand_total").text();
		var shipping_amt=Math.round(parseFloat(combo_shipamt) * parseFloat(combo_qty));
		var tot=Math.round((parseFloat(combo_qty) * parseFloat(combo_webprice) + parseFloat(shipping_amt)));
		var grand_tot=Math.round(parseFloat(g_tot) - parseFloat(combo_tot)+ parseFloat(tot));
		$('#combo_tot'+combo_updateid).html(tot+zero);	
		$('#combo_ship'+combo_updateid).html(shipping_amt+zero);
		$('#grand_total').html(grand_tot+zero);
		frmdata = 'combo_updateid='+combo_updateid+'&cqty='+combo_qty;
		$.ajax({
			url:'shopping-cart.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				
				},
			error:function(){
				$("#signinfield").html("<div class='ajax-loader'>error</div>");		
			}
		});
		
	}

function combo_del(cdel_id)
	{
		var zero='.00'
		var row = $("#row"+cdel_id).val();
		var total = $("#combo_tot"+cdel_id).text();
		var g_tot = $("#grand_total").text();
		var grand_tot=Math.round(parseFloat(g_tot) - parseFloat(total));
		$('#grand_total').html(grand_tot+zero);
		$('#combo_row'+cdel_id).hide().html();
		frmdata = 'combo_delid='+cdel_id;	
		$.ajax({
			url:'shopping-cart.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				},
			error:function(){
				$("#signinfield").html("<div class='ajax-loader'>error</div>");		
			}
		});		
	}

function prod_delete(del_id)
	{
		var zero='.00'
		frmdata = 'delid='+del_id;		
		var row = $("#row"+del_id).val();
		var total = $("#total"+del_id).text();
		var g_tot = $("#grand_total").text();
		var grand_tot=Math.round(parseFloat(g_tot) - parseFloat(total));
		$('#grand_total').html(grand_tot+zero);
		$('#row'+del_id).hide().html();
		$.ajax({
			url:'shopping-cart.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				},
			error:function(){
				$("#signinfield").html("<div class='ajax-loader'>error</div>");		
			}
		});
	}

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';
		}
	}




	$("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:https_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 = web_https_url+'shopping-cart.html';
					}
				}
				else if(a==2)
				{
					window.location = web_https_url+'checkout.html';
				}
				else{
					$("#signinfield").html(a);
				}
			},
			error:function(){
				$("#signinfield").html("<div class='ajax-loader'>error</div>");		
			}
		});
	});



function cart_shop()
{
		var uname = $("#username").val();
		var pword = $("#password").val();
		if(uname!="" || pword!="")
		{
			document.getElementById("checkout_product_session").value = "0";
			var frmdata = $("#loginid").serialize();
			$.ajax({
			url:https_url+'sign-in.html?shop_cart=true',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b)
			{
					if(a==1)
					{
						window.location = web_https_url+'shopping-cart.html';		
					}
					else 
					{
						alert("Please Enter Valid Email and Password");		
					}
			},
			error:function(){
				$("#signinfield").html("<div class='ajax-loader'>error</div>");		
			}
		});
	}
	else
	{
		window.location = 'shopping-cart.html';		
	}
}


function cart_checkout_signin()
{
	var pid = $("#pid").val();
	document.getElementById("checkout_product_session").value = "0";
	var frmdata = $("#loginid").serialize();
	$.ajax({
		url:https_url+'sign-in.html?shop_cart=true',
		type:'POST',
		dataType:'html',
		data:frmdata,
		success:function(a,b)
		{
			window.location = web_https_url+'shopping-cart.html';		
		},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
	});
}



$(document).ready(function(){
	$("#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 brand = $(this).val();
		a=brand.split(':');
		bid=a[0];
		bname=a[1];
		if(bid != 0 || bid != '0X'){
			window.location = 'brand-'+bname+'_BR'+bid+'.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);
					$(".loading").fadeOut("slow");
				},
				error : function(a,b){
						alert("error");
					}
			});
		}
		return false;
	});	


	$("img.feedbacksubmit").livequery("click",function(){
		var fopt = $("#feed_option").val();
		var ftext = $("#feedbacktext").val();
		var femail = $("#feedbackemail").val();
		if(fopt!="" && ftext!="" && femail!="")
		{
			var frmdata = $("#feedback").serialize()+'&ajax=true';
			//$("#feedback_thanks").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
			$.ajax({
				url:'feedback_thanks.php',
				type:'POST',
				dataType:'html',
				data:frmdata,
				success:function(a,b)
				{
					alert('Thanks for your Input!');
					document.feedback.submit();
				},
				error:function(){
					$("#feedback_thanks").html("<div class='ajax-loader'>error</div>");		
				}
			});
		}
	});



	$(".CheckoutRegisterConfirm").livequery("click",function(){
		var frmdata = $("#register").serialize()+'&ajax=true';
		$.ajax({
			url:https_url+'sign-up.html',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				if(a==1){
					window.location = web_https_url+'checkout.html';
				}else{
					b="<div class='erroemessage'>"+a+"</div>";
					$("#error").show().html(b);
					$("#bottom_error").show().html(b);
					alert(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(25000);
				$("#message").html(a);
			},
			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);
				}
			});
		});

	$("#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");
	});



	$("#select_address").livequery("change",function(){
		var id = $(this).val();
		$("#error").hide();
		var frmdata = 'id='+id+'&ajax=true';
		$.ajax({
			url:https_url+'address-selection.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").show();
	})

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

	$("#update_offline").click(function(){
		$("#errmsgs").hide();
		var paymodeid = $("#paymodeid").val();		
		var payment_branch = $("#payment_branch").val();
		var transaction_id = $("#transaction_id").val();
		var  msg = '';
		if(paymodeid==4)
		{			
			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(payment_branch=='')
		{
			msg += '* Pls Enter Bank and Branch Name<br />';
		}
	
		if(msg==''){
			var data = $("#address_update").html();
			var amt=$("#grand_total").val();
			if(data == ''){	
				$("#error").show();
				$("#error").html("Select a Delivery address").fadeOut(2500);
				return false;
			}
			else if(amt<=0)
			{
				alert("Invalid Amount");
				return false;
			}
			else
			{
				document.getElementById("paymode_offline").value = 'Yes';
				$("#checkout").attr({action:'thanks.html'});
        		var a = $("#checkout").attr("action");
				document.checkout.submit();
				return true;
			}
		}else{
			$("#errmsgs").show();
			$("#offlineerror").html(msg);
			return false;
		}
	});
	
	$("#orderstatusbtn").change(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){
			}
		});
	});

// FILTER OPTION STARTS	(OLD)
	/*$(".filterchk").click(function(){
		$("#pageno").val("1");					   
		var frmdata = $("#frm_filter").serialize()+'&ajax=true&filter=true';
		$("#displaycontent").html("<div class='ajax-loader' style='height:550px'><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);
			}
		});
	});	*/


// FILTER OPTION STARTS	 (NEW)
	$(".filterchk").click(function(){
		$("#pageno").val("1");
		$("#filter_display").hide();
		$("#filter_hide_display").html("<div class='ajax-loader' style='height:150px'><img src='images/ajax-loader.gif'></div>");
		$("#filter_hide_display").show();
		var frmdata = $("#frm_filter").serialize()+'&ajax=true&filter_count=true&filter=0';
		$.ajax({
			url:'products-filter.php',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				$("#filter_hide_display").hide();
				$("#filter_display").show();
				$("#product_count").html(a);
			},
			error:function(a,b){
					alert(a);
			}
		});
	});	

	$(".categoryfilterchk").click(function(){
		$("#pageno").val("1");
		var DivHeight = document.getElementById("filter_display").offsetHeight;
		$("#filter_display").html("<div class='ajax-loader' style='height:"+DivHeight+"px'><img src='images/ajax-loader.gif'></div>");
		var frmdata = $("#frm_filter").serialize()+'&ajax=true&filter=true';
		$.ajax({
			url:'category_filter.php',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				$("#filter_display").html(a);
			},
			error:function(a,b){
					alert(a);
			}
		});
	});	

	$(".product_orderby").click(function()
	{
		$("#pageno").val("1");
		var frmdata = $("#frm_filter").serialize()+'&ajax=true&filter_count=0&filter=true';
		$("#displaycontent").html("<div class='ajax-loader' style='height:550px'><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);
			}
		});
	});
	
	
	$(".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);
				},
				error:function(a,b){
					alert(a);
				}
			});	
		return false;
	});	


	$(".categorypageclass").livequery("click",function(){
		var id = $(this).attr("id");
		$("#pageno").val(id);
			var frmdata = $("#frm_filter").serialize()+'&ajax=true&filterpaging=true';
				$("#filter_display").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
				$.ajax({
				url:'category_filter.php',
				type:'POST',
				dataType:'html',
				data:frmdata,
				success:function(a,b){
					$("#filter_display").html(a);
					$("#PageTop").focus();
				},
				error:function(a,b){
					alert(a);
				}
			});	
		return false;
	});	



// FILTER OPTION ENDS
});




	$(".antecpageclass").livequery("click",function(){
		var id = $(this).attr("id");
		$("#pageno").val(id);
			var frmdata = $("#frm_filter").serialize()+'&ajax=true&antecfilterpaging=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);
				}
			});	
		return false;
	});	

/*function signin_process()
{
	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 = 'address-selection.html';
			}
			else{
				$("#signinfield").html(a);
			}
		},
		error:function(){
			$("#signinfield").html("<div class='ajax-loader'>error</div>");		
		}
	});
}*/

/*$(document).keypress(function (e) {
		if(e.which == '13'){
			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 = 'address-selection.html';
					}
					else{
						$("#signinfield").html(a);
					}
				},
				error:function(){
					$("#signinfield").html("<div class='ajax-loader'>error</div>");		
				}
			});
			return false;
		}
	});*/

	$(".forgotpass").livequery("click",function(){
		emailid=document.getElementById("forgotpass").value;
		if(emailid=="")
		{
			alert("Please Enter Your Email ID");
			return false;
		}
		var frmdata = $("#forgotpass").serialize()+'&ajax=true';
			$("#forgotpass_display").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
			$.ajax({
			url:'forgot-password.php',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b)
			{
				if(a=="Success")
				{
					alert("New password mailed as per your request");
					window.location=web_https_url+"sign-in.html";
				}
				else
				{
					$("#forgotpass_display").html("Invalid request");
				}
			},
			error:function(a,b){
				alert(a);
			}
		});	
		return false;
	});	
	
	
		$(".compareclass").livequery("click",function(){
			var pid=$(this).val();
			var val = $("#compare3").val();
			var check=$("#compare"+pid).attr("checked");
			if((val!=undefined) && (check==true)) 
			{
				alert("Please Select Only Three Products at a time");
				$("#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 Sub Category Products to Compare");
					}
					else
					{
						$("#comparedisplay").show().html(a);
					}
				},
				error:function(a,b){
						//alert(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);
			}
		});
		});
	
	
	$(".recemd_friend").livequery("click",function(){
		var frmdata = $("#friend_recemd").serialize()+'&ajax=true';
		var friend_email = $("#friend_email").val();
		
		var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		
		if (!pattern.test(friend_email))
		{
				alert("Please enter Correct Email ID");
				return false;
		}
		
		$("#recemdfriend_display").html("<div class='ajax-loader'><img src='images/ajax-loader.gif'></div>");
		$.ajax({
			url:'recommend_friend.php',
			type:'POST',
			dataType:'html',
			data:frmdata,
			success:function(a,b){
				if(a!=''){
					alert('Your mail has been succeccfully to your friend.');
					window.location = 'index.html';
				}else{
					$("#recemdfriend_display").html("Invalid Request");
				}
			},
			error:function(){
				$("#recemdfriend_display").html("<div class='ajax-loader'>error</div>");		
			}
		});
		return false;
	});

	function recemd_friend()
	{
		var userid = $("#userid").val();
		if(userid=='')
		{
			alert("Please Login and Use Recemd a friend");
			return false;
		}
	}

	function print_orderhistor(invno)
	{
		if(invno!='')
			window.open ("invoice_printing.php?invno="+invno,"mywindow","toolbar=no,menubar=no,scrollbars=yes,resizable=no,width=1000,height=600"); 
		else
			alert("Please Select Invoiced Order");
	}
	
	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("option5").style.display="none";					
				document.getElementById("text1").className='featureTabThree';
				document.getElementById("text2").className='featureTabTwo';
				document.getElementById("text3").className='featureTabTwo';
				document.getElementById("text4").className='featureTabTwo';
				document.getElementById("text5").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("option5").style.display="none";					
				document.getElementById("text2").className='featureTabThree';
				document.getElementById("text1").className='featureTabTwo';
				document.getElementById("text3").className='featureTabTwo';
				document.getElementById("text4").className='featureTabTwo';
				document.getElementById("text5").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("option5").style.display="none";
				document.getElementById("text3").className='featureTabThree';
				document.getElementById("text1").className='featureTabTwo';
				document.getElementById("text2").className='featureTabTwo';
				document.getElementById("text4").className='featureTabTwo';
				document.getElementById("text5").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("option5").style.display="none";
				document.getElementById("text5").className='featureTabTwo';
				document.getElementById("text4").className='featureTabThree';
				document.getElementById("text3").className='featureTabTwo';
				document.getElementById("text1").className='featureTabTwo';
				document.getElementById("text2").className='featureTabTwo';
				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="inline";
				document.getElementById("text5").className='featureTabThree';
				document.getElementById("text4").className='featureTabTwo';
				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;
			}
		}
