
$(document).ready(function(){
	
	
	
	///////////////////////////////////////////////////////////// Review Order
	
	$('#show_review_order').toggle(function() {
		$("#dialog-orders").dialog({autoOpen:false, modal: true, width:600, height:400});
	  $('#review_order').show();
	  $(this).html("Hide Review Orders");
	  
	}, function() {
	 $('#review_order').hide("");
	  $('#order_list').hide("");
	 $(this).html("Review Orders");
	});
	
	
	/////////////////////////////////////////////////////////////////////////
	var dates = $('#from, #to').datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			numberOfMonths: 1,
			dateFormat:'yy-mm-dd',
			onSelect: function(selectedDate) {
				var option = this.id == "from" ? "minDate" : "maxDate";
				var instance = $(this).data("datepicker");
				var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
				dates.not(this).datepicker("option", option, date);
			}
		});

	
	///////////////////////////////////////////////////////////////
	$('#get_orders').click(function () {
		$("#dialog-orders").dialog({autoOpen:false, modal: true, width:600});
			$('#order_list').html("");
				$('#order_list').show("");
			$('#order_list').html("<img src='images/load.gif'/>");
				 $.ajax({
					  type: "GET",
					  url: "include/controller/orders.php",
					  data: "action=review&orderid="+this.id+"&mindate="+$('#from').val()+"&maxdate="+$('#to').val(),
					  success: function(msg){
						$('#order_list').html(msg);
					  }
					
					}); 
			});
	
	
	/////////////////////////////////////////////////////////////Order details
	
	//////on order.html
	
	/////////////////////////////////////////////////////////////////////////
	var dates1 = $('#from_edit, #to_edit').datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			numberOfMonths: 1,
			dateFormat:'yy-mm-dd',
			onSelect: function(selectedDate) {
				var option1 = this.id == "from_edit" ? "minDate" : "maxDate";
				var instance1 = $(this).data("datepicker");
				var date1 = $.datepicker.parseDate(instance1.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance1.settings);
				dates1.not(this).datepicker("option", option1, date1);
			}
		});

	
	///////////////////////////////////////////////////////////////
	
	////////////////////////////////////////////////////////////order edit
	
	
	
	$('#show_edit_order').toggle(function() {
		$("#dialog-orders").dialog({autoOpen:false, modal: true, width:600});
	  $('#edit_order').show("");
	  $(this).html("Hide Shipping / Billing Addreses");
	  
	}, function() {
	 $('#edit_order').hide("");
	 $('#order_list').hide("");
	 $(this).html("Change Shipping / Billing Addreses");
	});
	
	/////////////////////////////////////////////////////////////
	
	$('#get_orders_edit').click(function () {
	//	alert("hello");
			$('#order_list').html("");
				$('#order_list').show("");
			$('#order_list').html("<img src='images/load.gif'/>");
				 $.ajax({
					  type: "GET",
					  url: "include/controller/orders.php",
					  data: "action=edit&orderid="+this.id+"&mindate="+$('#from_edit').val()+"&maxdate="+$('#to_edit').val(),
					  success: function(msg){
						$('#order_list').html(msg);
					  }
					
					}); 
			});
	
	
	/////////////////////////////////////////////////////////////Print Invoices
	
	var dates2 = $('#from_invoice, #to_invoice').datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			numberOfMonths: 1,
			dateFormat:'yy-mm-dd',
			onSelect: function(selectedDate) {
				var option2 = this.id == "from_invoice" ? "minDate" : "maxDate";
				var instance2 = $(this).data("datepicker");
				var date2 = $.datepicker.parseDate(instance2.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance2.settings);
				dates2.not(this).datepicker("option", option2, date2);
			}
		});
	
	
	///////////////////////////////////////////////////////////////////////////////show invoices
	
	$('#show_invoice').toggle(function() {
		$("#dialog-orders").dialog({autoOpen:false, modal: true, width:600});
	  $('#print_invoice').show("");
	  $(this).html("Hide Print Invoice");
	  
	}, function() {
	 $('#print_invoice').hide("");
	 $('#order_list').hide("");
	 $(this).html("Print Invoice");
	});
	
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	
	$('#get_invoice').click(function () {
	//	alert("hello");
			$('#order_list').html("");
				$('#order_list').show("");
			$('#order_list').html("<img src='images/load.gif'/>");
				 $.ajax({
					  type: "GET",
					  url: "include/controller/orders.php",
					  data: "action=invoice&orderid="+this.id+"&mindate="+$('#from_invoice').val()+"&maxdate="+$('#to_invoice').val(),
					  success: function(msg){
						$('#order_list').html(msg);
					  }
					
					}); 
			});
	
	
	/////////////////////////////////////////////////////////////Show Variation
	$('#show_variation').toggle(function() {
		$("#dialog-variation").dialog({autoOpen:false, modal: true, width:400});
	  $('#variation').show("");
	  ///////////////////////////////////////////////
	  $('#variation').html("");
				$('#variation').html("<img src='images/load.gif'/>");
				 $.ajax({
					  type: "GET",
					  url: "include/controller/variations.php",
					  data: "action=show",
					  success: function(msg){
						$('#variation').html(msg);
					  }
					
					}); 
	  ///////////////////////////////////////////////////
	  $(this).html("Hide Show Variations");
	  
	}, function() {
	 $('#variation').hide("");	 
	 $(this).html("Show Variations");
	});
	
	////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////Show Variation
	$('#edit_variation').toggle(function() {
		$("#dialog-variation").dialog({autoOpen:false, modal: true, width:400});
	  $('#variation').show("");
	  ///////////////////////////////////////////////
	  $('#variation').html("");
				$('#variation').html("<img src='images/load.gif'/>");
				 $.ajax({
					  type: "GET",
					  url: "include/controller/variations.php",
					  data: "action=edit",
					  success: function(msg){
						$('#variation').html(msg);
					  }
					
					}); 
	  ///////////////////////////////////////////////////
	  $(this).html("Hide Edit Variations");
	  
	}, function() {
	 $('#variation').hide("");	 
	 $(this).html("Edit Variations");
	});
	
	//////////////////////////////////////////////////////////////////// Billing
	$('#show_information').click(function() {
		$("#dialog-information").dialog({autoOpen:false, modal: true, width:400});
		
	 $("#dialog-information").dialog('open');
	 
	});
	
	
	//////////////////////////////////////////////////////////////////////////my info
	$('#show_myinfo').click(function() {
		$("#dialog-myinfo").dialog({autoOpen:false, modal: true, width:400});
	 $("#dialog-myinfo").dialog('open');
	 
	});
	/////////////////////////////////////////////////////////////////
	
	$('#update_myinfo').click(function () {
			//	alert("Success");
				$.post("include/functions/update_info_action.php", $("#form_myinfo").serialize(),
				function(data){
					if(data == 1)
					{
						alert("Success");
					 $("#dialog-myinfo").dialog('close');
					}else
					alert(data);
					
								
					}

				
				);
			});
			
	//////////////////////////////////////////////////////////////chnage pass
	
	$('#change_password').click(function() {
		$("#dialog-password").dialog({autoOpen:false, modal: true, width:400});
	 $("#dialog-password").dialog('open');
	 
	});
	
	////////////////////////////////////////////////////// Change Pass
	$('#update_password').click(function () {
			//	alert("Success");
				$.post("include/functions/change_pass_action.php", $("#form_pass").serialize(),
				function(data){
					if(data == 1)
					{
						//alert(data);
						alert ("Password Successfully Changed");
					 $("#dialog-password").dialog('close');
					}else
					alert (data);
					
								
					}

				
				);
			});
	
	/////////////////////////////////////////////////////////////Terms and Conditions
	$('#show_terms').click(function() {
		$("#terms").dialog({autoOpen:false, modal: true, width:600, height:400,buttons: {Ok: function() {$(this).dialog('close');}}});
		
		 $.ajax({ type: "GET",
					  url: "include/controller/terms.php",
					  data: "orderid="+this.id,
					  success: function(msg){
						$('#terms').html(msg);
					  }
					
					}); 
	 $("#terms").dialog('open');
	 
	});
	
	
	///////////////////////////////////////////////////////////////////////////////
		$('#helpsave').click(function() {
		$("#dialog-what").dialog({autoOpen:false, modal: true, width:300, height:200,buttons: {Ok: function() {$(this).dialog('close');}}});
		 $("#dialog-what").dialog('open');
	 
	});
	//////////////////////////////////////////////////////////////////////////////////
		
	 //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	
	$("ul.topnav li").hover(function() { //When trigger is clicked...
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).find("ul.subnav").slideDown('').show(); //Drop down the subnav on click
		//$(this).parent().css("background-color","#349A44"); //Drop down the subnav on click
		//$(this).css("background-color","#349A44");

		
		}, function(){	
		//$(this).css("background-color","#032243");
			$(this).find("ul.subnav").hide('');
			$(this).find("ul.subnav").slideUp(''); //When the mouse hovers out of the subnav, move it back up
		});

		
	



		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
		$("#dialog").dialog("destroy");
		
		var name = $("#name"),
			sname = $("#sname"),
			ssname = $("#ssname"),
			semail = $("#semail"),
			ssemail = $("#ssemail"),
			remail = $("#remail"),
			aemail = $("#aemail"),
			aname = $("#aname"),
			oemail = $("#oemail"),
			oname = $("#oname"),
			otelephone = $("#otelephone"),
			oprice = $("#oprice"),
			amessage = $("#amessage"),
			ssmessage = $("#ssmessage"),
			samessage = $("#samessage"),
			phone = $("#phone"),
			ssphone = $("#ssphone"),
			
			
			allFields = $([]).add(name).add(sname).add(semail).add(remail).add(aemail).add(aname).add(oname).add(oemail).add(oprice)
			tips = $(".validateTips");

		function updateTips(t) {
			tips
				.text(t)
				.addClass('ui-state-highlight');
			setTimeout(function() {
				tips.removeClass('ui-state-highlight', 1500);
			}, 500);
		}
		
		function checkRegexp(o,regexp,n) {

			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass('ui-state-error');
				updateTips(n);
				return false;
			} else {
				return true;
			}

		}
			

		function checkLength(o,n,min,max) {

			if ( o.val().length > max || o.val().length < min ) {
				o.addClass('ui-state-error');
				updateTips("Length of " + n + " must be between "+min+" and "+max+".");
				return false;
			} else {
				return true;
			}

		}

		
		
		$("#dialog-form-ask").dialog({
			autoOpen: false,
			height: 550,
			width: 600,
			modal: true,
			buttons: {
				'Ask a Question': function() {
					var bValid = true;
					allFields.removeClass('ui-state-error');
					bValid = bValid && checkLength(aname,"Name",3,25);
					bValid = bValid && checkLength(amessage,"Message",3,1024);
					bValid = bValid && checkLength(aemail,"Email",6,80);
					bValid = bValid && checkLength(phone,"Phone",6,15);
					bValid = bValid && checkRegexp(aemail,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. ui@jquery.com");
					if (bValid) {
							$.post("include/controller/question.php", $("#f22").serialize(),
				function(data){
					if(data != 0)
					{alert(data);$(this).dialog('close');}
					else{alert(data);$(this).dialog('close');}		
				});
		$(this).dialog('close');
						
					}
				},close: function() {
				$(this).dialog('close');

				}
			}

			
		});
		
		
		$("#dialog-form-ask2").dialog({
			autoOpen: false,
			height: 300,
			width: 400,
			modal: true,
			buttons: {
				'Ask a Question': function() {
					var bValid = true;
					allFields.removeClass('ui-state-error');
					bValid = bValid && checkLength(ssname,"Name",3,25);
					bValid = bValid && checkLength(ssphone,"Phone",8,25);
					bValid = bValid && checkLength(ssemail,"Email",6,80);
					bValid = bValid && checkRegexp(ssemail,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. ui@jquery.com");
					bValid = bValid && checkLength(ssmessage,"Message",6,1024);
					if (bValid) {
							$.post("include/controller/ask.php", $("#fq").serialize(),
				function(data){
					if(data != 0)
					{alert(data);$(this).dialog('close');}
					else{alert(data);$(this).dialog('close');}		
				});
		$(this).dialog('close');
						
					}
				},close: function() {
				
				$(this).dialog('close');

			
				}
			}

			
		});
		
		
		
		
		$("#dialog-form-offer").dialog({
			autoOpen: false,
			height: 550,
			width: 600,
			modal: true,
			buttons: {
				'Make an Offer': function() {
					var bValid = true;
					allFields.removeClass('ui-state-error');
					
					bValid = bValid && checkLength(oname,"Name",3,25);
					bValid = bValid && checkLength(oprice,"Price",1,25);	
					bValid = bValid && checkLength(oemail,"Email",6,80);
					bValid = bValid && checkLength(otelephone,"otelephone",6,80);
													
					bValid = bValid && checkRegexp(oemail,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. ui@jquery.com");
					if (bValid) {					
							$.post("include/functions/offer_action.php", $("#foffer").serialize(),
				function(data){
					if(data != 0)
					{alert(data);$(this).dialog('close');}
					else{alert(data);(this).dialog('close');}
					}

				
				);
		
							$(this).dialog('close');
					}
				},close: function() {
				$(this).dialog('close');

				}
			}

			
		});
		
		
		
		
		
		
		
		$("#dialog-form").dialog({
			autoOpen: false,
			height: 550,
			width: 600,
			modal: true,
			buttons: {
				'Email a Friend': function() {
					var bValid = true;
					allFields.removeClass('ui-state-error');
					bValid = bValid && checkLength(name,"Friend's Name",3,25);
					bValid = bValid && checkLength(sname,"Your Name",3,25);									
					bValid = bValid && checkLength(semail,"Your email",6,80);
					bValid = bValid && checkLength(remail,"Friends email",6,80);
					bValid = bValid && checkRegexp(semail,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. ui@jquery.com");
					bValid = bValid && checkRegexp(remail,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. ui@jquery.com");
					bValid = bValid && checkLength(samessage,"message",6,1024);
					
					if (bValid) {
							$.post("include/controller/email.php", $("#f11").serialize(),
				function(data){
					if(data != 0)
					{alert(data);$(this).dialog('close');}
					else{alert(data);$(this).dialog('close');}
					}

				
				);
		$(this).dialog('close');
						
					}
				},close: function() {
				$(this).dialog('close');

				}
			}

			
		});
		
		
		
		$('#email').click(function() {
			//alert("hello email clicked");
				$('#dialog-form').dialog('open');
			});
			$('#question').click(function() {
				$('#dialog-form-ask').dialog('open');
			});
			
			$('#offer').click(function() {
				$('#dialog-form-offer').dialog('open');
			});

	
			$('#question1').click(function() {
				//alert("hello");
				$('#dialog-form-ask2').dialog('open');
			});

	
	
$('#send').click(function() {
				alert("hello");			});
	
	
	
	
	
	
	//////////////////////////////////////////////////////////
	

	$("a.jqzoom").fancybox();
	$("a.cart").fancybox();


	$(function() {

    $('#name').focus(function() {

      $(this).val('');

      });

 });
 
 $(function() {

    $('#question1').focus(function() {

      $(this).val('');

      });

 });

	
	
	


$('#copy').change(function () {
		
				
				if($('input[name=copy]').attr('checked'))
				{$("#billing").hide();}else{$("#billing").show();}
				
			});
				if($('input[name=copy]').attr('checked'))
				{$("#billing").hide();}else{$("#billing").show();}
				
			$('#billcountry').change(function () {		
				
				if($('input[name=copy]').attr('checked'))
				{if($('#billcountry').val()!='0'  ){$("#form1").action='#';$("#form1").submit();}}
				
			});
			
			$('#copy').change(function () {		
				
				if($('input[name=copy]').attr('checked'))
				{if($('#billcountry').val()!='0'  ){$("#form1").action='#';$("#form1").submit();}}else
				{if($('#stxtCountry').val()!='0'  ){$("#form1").action='#';$("#form1").submit();}}
				
			});
			
			$('#stxtCountry').change(function () {
		
				
				
				if($('#stxtCountry').val()!='0'  ){$("#form1").action='#';$("#form1").submit();}
				
			});
			
			$('#addtocart').click(function () {
				var showVar=$('input[id=drop_var]').attr('checked');
				//alert(showVar);
				if(showVar)
				{
					if( validate() )
					{
						
							if($('input[id=terms_check]').attr('checked'))
							{
								$("#f1").submit();
							}else
							alert("Please Check the Terms and Conditions box to continue")
					}
				}
				else
				{
					if($('input[id=terms_check]').attr('checked'))
					{
						$("#f1").submit();
					}else
					alert("Please Check the Terms and Conditions box to continue")
				}
				
			});



$('#payment').change(function () {
		
				if($("#payment").val() == 2 && $("#payment").val() != 5 )
				{$("#skipjack").show('');$("#authorize").hide('');}
				else if($("#payment").val() == 5  )
				{$("#skipjack").hide('');$("#authorize").show('');}
				else{$("#skipjack").hide();$("#authorize").hide('')}
			});
$(function() {
	var options = {
	    zoomWidth:300,
	    zoomHeight: 340,
            xOffset: 10,
			position: "right",
            yOffset: 0		
            
	}
	$(".jqzoom").jqzoom(options);
});

			$('#slideshow').cycle({
		fx:     'scrollLeft', 
    timeout: 5000, 
    nowrap: true,
    next:   '#next2', 
    prev:   '#prev2' ,
	end: hello_s
	});
	
	function hello_s() { 
  //  alert("#slideshow")
	 $('#slideshow').cycle({
		fx:     'scrollLeft', 
    nowrap: true,
    next:   '#next2', 
    prev:   '#prev2' ,
		timeout: 0,
		end: hello_s
		 
	});
} 
	
	$('#slideshow_sold').cycle({
		fx:     'scrollLeft', 
    timeout: 5500, 
    nowrap: true,
    next:   '#soldnext2', 
    prev:   '#soldprev2' ,
	end: hello_so
	});
	
	function hello_so() { 
  //  alert("#slideshow_sold")
	 $('#slideshow_sold').cycle({
			fx:     'scrollLeft', 
    timeout:0, 
    nowrap: true,
    next:   '#soldnext2', 
    prev:   '#soldprev2' ,
	end: hello_so
		 
	});
} 
	
	
	$('#slideshow_sale').cycle({
		fx:     'scrollLeft', 
    timeout: 4500, 
    nowrap: true,
    next:   '#salenext2', 
    prev:   '#saleprev2' ,
	end: hello_sa
	});

	
		function hello_sa() { 
   // alert("#slideshow_sale")
	 $('#slideshow_sale').cycle({
		fx: 'scrollLeft' ,// choose your transition type, ex: fade, scrollUp, shuffle, etc...
		 nowrap: true,
    next:   '#salenext2', 
    prev:   '#saleprev2' ,
	end: hello_sa,
	timeout: 0		 
	});
} 
	
	
			$(function(){

			 $.ajax({ type: "GET",
					  url: "show_cart.php",
					  data: "orderid="+this.id,
					  success: function(msg){
						$('#cart').html(msg);
					  }
					
					}); 
			
		

	});
	
	

			
			
			if($('input[id=drop_var]').attr('checked'))
				{$("#user_var").show();}else{$("#user_var").hide();}
				
			$('#drop_var').change(function () {
		
				
				if($('input[id=drop_var]').attr('checked'))
				{$("#user_var").show();}else{$("#user_var").hide();}
				
			});

$('.update_var').click(function () {
				alert("hello");
				$.post("include/functions/update_var.php", $("#fvar").serialize(),
				function(data){
					if(data > 0)
					{
						alert("Addresses Successfully Updated");
						$('#edit').hide("");
					}
					else
					alert("Nothing Updated");
					}

				
				);
			});
	
		$('.update_billing').click(function () {
				//alert("hello");
				$.post("include/functions/update_billing_info.php", $("#f2").serialize(),
				function(data){
					if(data > 0)
					{
						alert("Addresses Successfully Updated");
						 $("#dialog-information").dialog('close');
					}
					else
					alert("Nothing Updated");
					}

				
				);
			});
	
	

	$('#show_bill').toggle(function() {
  $('#bill_div').show("");
  $(this).html("Hide Billing Information");
  
}, function() {
 $('#bill_div').hide("");
 $(this).html("Show Billing Information");
});
	
	
	
				
			
	$('#show_order').toggle(function() {
  $('#order_div').show("");
  $(this).html("Hide Orders");
  
}, function() {
 $('#order_div').hide("");
 $(this).html("Show Orders");
});
		
		
			$('#show_var').toggle(function() {
  $('#var_div').show("");
  $(this).html("Hide Variation");
  
}, function() {
 $('#var_div').hide("");
 $(this).html("Show Variations");
});
	$('#close').click(function () {
				$('#edit').hide("");
				
			});
			
			$('a.edit').click(function () {
				$('#edit').show("");
				//alert("hello");
				 $.ajax({
					  type: "GET",
					  url: "include/functions/order_edit.php",
					  data: "orderid="+this.id,
					  success: function(msg){
						$('#edit').html(msg);
					  }
					
					}); 
			});
			
			
			
			$('a.edit_var').click(function () {
				$('#edit_var').show("");
				//alert("hello");
				 $.ajax({
					  type: "GET",
					  url: "include/functions/edit_variations.php",
					  data: "varid="+this.id,
					  success: function(msg){
						//  alert(msg);
						$('#edit_var').html(msg);
					  }
					
					}); 
			});
			
			
			
			
			
			
			$('.update').click(function () {
				//alert("hello");
				$.post("include/functions/update_order.php", $("#f1").serialize(),
				function(data){
					if(data == 1)
					{
						alert("Addresses Successfully Updated");
						$('#edit').hide("");
					}
					else
					alert("Fail to Update. Please Try Again Later");
					}

				
				);
			});
			
			
			  
			
		/////////////////////////////// SIGNUP FORM SUBMIT //////////////////////////////
		
	
				
			//////////////////////////////////////////////////////////////	
			
			
		
	}
	///////////////////////////////////////
	
	
	
	
	
	
	////////////////////////////////////////////
	
);

// JavaScript Document


