// JavaScript Document
//Modified by atom
//2009-2-3

//Clean the cache
$.ajaxSetup ({
    cache: false 
});


//Comment_add in prouduct detail
function Comment_submit(){
var comment_product_id = $("#comment_product_id").val();
var comment_memo = $("#comment_memo").val();
if(comment_product_id == "" || comment_memo == ""){
	alert("Input your comment");
	return false;
	}

$.ajax({
  type: "get",
  url: "../Comment_add.asp",
  data: "comment_product_id=" + comment_product_id + "&comment_memo=" + comment_memo,
  cache: false,
  beforeSend: function(XMLHttpRequest){
		//$("#commentsubmitbutton").html("Submitting..."); 
		},
  success: function(html){
	if(html == "y"){
	alert("Successfully public");	
	$("#comment_content").load("../commentshow.asp?Product_id="+comment_product_id);
	}else{
	 alert("Sorry,can not public your comment,please try again");  	
	}
  },
  complete: function(XMLHttpRequest, textStatus){
		//$("#commentsubmitbutton").html("Public");  
  },
  error: function(){
		alert("error");
		}

}); 

}



//Clone the enter key for search button
function SearchKeyDown(){
 if (event.keyCode == 13){
	 event.returnValue=false;  
     Search_submit();
	 }
}

//Search form submit
function Search_submit(){
// var search_key = document.getElementById("search_key").value;  
var search_key = $("#search_key").val();  
 if(search_key == "")
	alert("Pls input the search word");	
 else
    window.location.href="../search.asp?search_key="+search_key+"";
	}
	
	
//inquiry detail add from here/////////////////////////////
function inquiry_detail_add(product_id){
var inquery_detail_product_id = product_id;
var inquery_detail_product_counts = $("#productcounts" + product_id).val();
if(inquery_detail_product_counts == "" || isNaN(inquery_detail_product_counts) == true){
  alert("Please enter the correct qty");
  return false;
}
$.ajax({
  type: "get",
  url: "../inquiry_detail_add.asp",
  data: "inquery_detail_product_id=" + inquery_detail_product_id + "&inquery_detail_product_counts=" + inquery_detail_product_counts,
  cache: false,
  beforeSend: function(XMLHttpRequest){
		
		},
  success: function(html){
	if(html == "you login first before inquiry"){
	 if(confirm("you should login first before inquiry,\n\nwould you like to login now?")){
	 window.location.href = "../login.html";
	 }
	}else{
	 if(confirm(html)){
	  window.location.href = "../myaccount.html" 
	 }
	}
  },
  complete: function(XMLHttpRequest, textStatus){
		 
  },
  error: function(){
		alert("error");
		}

}); 

}




/*For detail page begin here*********************************************************************************/
function changeurl(id){
document.getElementById("rollphoto").src = id;
}

function originalurl(id){
var f1 = document.getElementById("rollphoto");
f1.src = id;
}



function showvideo(videourl){
if(document.getElementById("spyvideo").style.display == ""){
document.getElementById("spyvideo").style.display = "none";
document.getElementById("spyvideo").innerHTML ="";
document.getElementById("showvideobutton").src = "007/images/007_26.gif";	
}
else
document.getElementById("spyvideo").style.display = "";
document.getElementById("spyvideo").innerHTML = ' <div class="Row5_ul_li2_div1" style="text-align:center"><embed src="../../WoddonUI/mv/'+videourl+'" width=460 height=300 autostart=ture showcontrols=false loop="true"></embed><br /><input type="button" value="Close Video" onclick="closevideo();"/></div>';
document.getElementById("3dphoto").style.display = "none";
document.getElementById("inquire").style.display = "none";
document.getElementById("3dphoto").innerHTML ="";
document.getElementById("inquire").innerHTML ="";
document.getElementById("showvideobutton").src = "007/images/007_26_on.gif";	
}


function closevideo(){
document.getElementById("spyvideo").style.display = "none";
document.getElementById("spyvideo").innerHTML = "";
document.getElementById("showvideobutton").src = "007/images/007_26.gif";	
}

function show3d(url3d){
if(document.getElementById("3dphoto").style.display == ""){
document.getElementById("3dphoto").style.display = "none";
document.getElementById("3dphoto").innerHTML ="";
document.getElementById("show3dbutton").src = "007/images/007_27.gif";	
}
else
document.getElementById("3dphoto").style.display = "";
document.getElementById("3dphoto").innerHTML = ' <div class="Row5_ul_li2_div1" style="text-align:center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="460" height="250"><param name="movie" value="'+url3d+'"><param name="quality" value="high"><embed src="'+url3d+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="295" height="220"></embed></object><input type="button" value="Close 3D photo" onclick="close3d();"/></div>';
document.getElementById("spyvideo").style.display = "none";
document.getElementById("spyvideo").innerHTML ="";
document.getElementById("inquire").style.display = "none";
document.getElementById("inquire").innerHTML ="";
document.getElementById("show3dbutton").src = "007/images/007_27_on.gif";	
}

function close3d(){
document.getElementById("3dphoto").style.display = "none";
document.getElementById("3dphoto").innerHTML = "";
document.getElementById("show3dbutton").src = "007/images/007_27.gif";	
}

function downshow_off(){
	alert("Pls login first");
	return false;
	}


function downshow_on(url){
	window.location.href=url;
	}



/************************************************************************************************************/






