// JavaScript Document
$(document).ready(function() {
 


	
	
	
	
	
	
	$('#nav').accordion({initShow:'#current'});
	
	
	
	$("a[rel='gallery-lightbox']").colorbox({slideshow:true,slideshowSpeed:4000});$("a[rel='lightbox']").colorbox();
 
});



function submitcomment(){
	
	
	$.post('/dsdcms/addcomment.php?ts=', { 
comment_page: document.getElementById('comment_page').value,
comment_email: document.getElementById('comment_email').value,
comment_name: document.getElementById('comment_name').value,
comment_comment: document.getElementById('comment_comment').value,
captcha: document.getElementById('captcha').value
},
	function(data) {
		if (data.status == "added"){
			$('#comment_form').html('<p>Comment submitted.</p>');
		}else if(data.status == "captcha_error"){
			$('#captcha_error').html('You typed the charachters wrong');
		}
		}, "json")
	

}



function submitlogin(){
	
	$.post('/dsdcms/login.php?ts=', { 
login_user: document.getElementById('login_user').value,
login_pwd: document.getElementById('login_pwd').value
},
	function(data) {
		if (data.status == "success"){
			location.reload();
		}else if(data.status == "error"){
			$('#status_login').html('Invalid Login');
		}
		}, "json")

}





// JavaScript Document

 function timestamper(){d = new Date(); return d.getTime();}
 
 
function initshopoptions(pid){
	$('#prod-options').load('/dsdcms/shopoptionsA.php?pid='+pid);
}

function initshopoptionsB(){
	var e = document.getElementById("optionA");
	var aid = e.options[e.selectedIndex].value;
	$('#prod-optionsB').load('/dsdcms/shopoptionsB.php?aid='+aid, function() {
											aprice = document.getElementById("aprice").value;
											pprice = document.getElementById("pprice").value;
											if (aprice != 0 && aprice != ''){
												document.getElementById("displayprice").innerHTML = aprice;
											}else{
												document.getElementById("displayprice").innerHTML = pprice;
											}
											
											
																		   });	
	
}

function selectoptionB(){
	var f = document.getElementById("optionB");
	var bid = f.options[f.selectedIndex].value;
		$.ajax({
 type: "GET",
 data: ({
bid: bid}),
  url: '/dsdcms/getbprice.php?ts='+timestamper(),
  success: function(data) {
	  
	  
	  if (data != '0'){
		  document.getElementById("displayprice").innerHTML = data;
	  }else{
		 
		 									aprice = document.getElementById("aprice").value;
											pprice = document.getElementById("pprice").value;
											if (aprice != 0 && aprice != ''){
												document.getElementById("displayprice").innerHTML = aprice;
											}else{
												document.getElementById("displayprice").innerHTML = pprice;
											}
		  
	  }
  }
});
	
}

function submitaddtocart(){
	if ($("#addtocart").valid()){
		$("#addtocart").submit();
	}
}












// Remove item from cart
function remove_line(line_num){
	document.getElementById(line_num).value = "0";
	$('#update').submit();	
}
