var httpobj=null;
function callasp(partem)
{
var xmlhttp = false;
var partem;

try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlhttp = false;
  }
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  xmlhttp = new XMLHttpRequest();
}
  CallServer();
function CallServer() {
	xmlhttp.open("GET","view_info.asp?pid="+escape(partem)+"&sFlag=p_product",true);
	xmlhttp.onreadystatechange=changes
	xmlhttp.send(null);
}
function changes() {
  if (xmlhttp.readyState == 4) {
    var response = xmlhttp.responseText;
	   document.getElementById("span1").innerHTML=response;
  }
}
}
function getHttpObj(){
try {
     httpobj = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
   try {
    httpobj = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e2) {
    httpobj = false;
       }
   }
if (!httpobj && typeof XMLHttpRequest != 'undefined') {
  httpobj = new XMLHttpRequest();
 }
}

function getPrintingProduct(printPid){
	(document.getElementById("trhouqi")).style.display="none";
	getHttpObj();
	httpobj.open("GET","view_info.asp?pid="+escape(printPid)+"&sFlag=print",true);
	httpobj.onreadystatechange=responsePrint
	httpobj.send(null);
}
function responsePrint(){
	if (httpobj.readyState == 4) {
   	var price=httpobj.responseText;
	var p_value=document.getElementById("span3");
	p_value.innerHTML=price;
  }
}
function getMount(printPid){
	getHttpObj();
	httpobj.open("GET","view_info.asp?pid="+escape(printPid)+"&sFlag=getMount",true);
	httpobj.onreadystatechange=responseMount
	httpobj.send(null);
}
function responseMount(){
	if (httpobj.readyState == 4) {
   	var price=httpobj.responseText;
	var p_value=document.getElementById("span4");
	p_value.innerHTML=price;
  }
}
function getHouqi(printPid){
	var StrPid=printPid.split("|");
	getHttpObj();
	httpobj.open("GET","view_info.asp?pid="+escape(printPid)+"&sFlag=Houqi",true);
	httpobj.onreadystatechange=responseHouqi
	httpobj.send(null);
}
function responseHouqi(){
	if (httpobj.readyState == 4) {
   	var price=httpobj.responseText;
	(document.getElementById("trhouqi")).style.display="block";
	var p_value=document.getElementById("span5");
	p_value.innerHTML=price;
	
  }
}

function DPIchange(dpivalue){
	getHttpObj();
	var p_product=document.getElementById("p_product").value;
	httpobj.open("GET","view_info.asp?id="+escape(p_product)+"&dip="+dpivalue+"&sFlag=dpichange",true);
	httpobj.onreadystatechange=backchange
	httpobj.send(null);
}
function backchange(){
	if (httpobj.readyState == 4) {
   	var price=httpobj.responseText;
	var p_value=document.getElementById("span2");
	p_value.innerHTML=price;
  }
}

function Calculation(){
	var price=document.getElementById("realprice").value;
	var p_C1=document.getElementById("p_C1").value;
	var p_C2=document.getElementById("p_C2").value;
	var p_dw=document.getElementById("p_dw").value;
	var p_total=document.getElementById("p_total");
	var p_num=document.getElementById("p_num").value;
	var p_m2=document.getElementById("p_m2");
	var totalprice;
	if(p_dw!="0"){
	  totalprice=Math.round(ConvertM(p_C1,p_C2,p_dw)*100)/100*parseInt(price);
	  alert(totalprice);
	  p_m2.value=Math.round(ConvertM(p_C1,p_C2,p_dw)*100)/100;
	  alert(p_num);
	   if(p_num!=null){
	  	totalprice=totalprice*parseInt(p_num);
	   }
		totalprice=Math.round(totalprice*100)/100;
		alert(totalprice);
	   p_total.value="US$"+(totalprice).toString();	
	}
	
	
}
function ConvertM(pc1,pc2,obj){
	var valueM;
	var fpc1=parseFloat(pc1);
	var fpc2=parseFloat(pc2);
	if(obj=="Inch"){
		valueM=fpc1*fpc2/144;
	}
	if(obj=="TF"){
		valueM=fpc1*fpc2;
	}
	if(obj=="CM"){
		valueM=fpc1*fpc2/929;
	}
	if(obj=="MM"){
		valueM=fpc1*fpc2/929;
		valueM=valueM/10000;
	}
	if(obj=="M"){
		valueM=fpc1*fpc2/929;
		valueM=valueM*10000;
	}
	return valueM;
}
function ConvertInch(str,obj){
	var valueInch;
	var strunit=parseInt(str);
	if(obj=="Inch"){
		valueInch=strunit;
	}
	if(obj=="CM"){
		valueInch=Math.round(strunit*100/2.54)/100;
	}
	if(obj=="MM"){
		valueInch=Math.round(strunit*100/25.4)/100;
	}
	if(obj=="TF"){
		valueInch=strunit*12;
	}
	if(obj=="M"){
		strunit=strunit*100;
		valueInch=strunit/2.54;
	}
	return valueInch;
}
function ConvertCM(str,obj){
	var valueInch;
	var strunit=parseInt(str);
		if(obj=="Inch"){
		valueInch=strunit*2.54;
	}
	if(obj=="CM"){
		valueInch=strunit;
	}
	if(obj=="MM"){
		valueInch=strunit/10;
	}
	if(obj=="TF"){
		valueInch=strunit*2.54*12;
	}
	if(obj=="M"){
		valueInch=strunit*100;
	}
	return parseInt(valueInch);
}

function check(){
	var p_C1=document.getElementById("p_C1").value;
	var p_C2=document.getElementById("p_C2").value;
	if(p_C1!=null && p_C2==null){
		alert("?ªq?¤æ?øý?­Ñ!");
		return false;
	}
	else if(p_C1==null && p_C2==null){
		alert("?ªq?¤æ?øý?­Ñ!");
		return false;
	}else{
	document.cform.p_dw.focus();		
    }
}
function CheckForm(){
	
}
function CheckForm1(){
	var flag=true;
	var ftpobj=document.getElementById("uploadid").value;
	var reg=/^\w+ftp:\/\/\w+$/gi;
	if(!reg.test(ftpobj)){
		alert("¥s•g?øý?£K??úYFTP¹j?");
		flag=false;
	}
	return flag;
}
function GetSmallC(dpivalue){
	getHttpObj();
	httpobj.open("GET","view_info.asp?pid="+dpivalue+"&sFlag=getsmallc",true);
	httpobj.onreadystatechange=CallBack
	httpobj.send(null);
}
function CallBack(){
	if (httpobj.readyState == 4) {
   	var smallstr=httpobj.responseText;
	//alert(smallstr);
	var p_small=document.getElementById("span2");
	p_small.innerHTML=smallstr;
  }
}
function getZS(thisvalue){
	
	var jdzs=document.getElementById("jdzs");
	if(thisvalue==1440){
		jdzs.innerHTML="1400DPI,ºôÂI²ÓD,¼Q¥X¨Óµe­±è°D,´X¦Ì¥~½d³ò¦×²´Ú»­ø¨ìºôÂI";
	}else if(thisvalue==2440){
		jdzs.innerHTML="ºôÂI²Ó­PD, ªñ¶ZÂ÷Ú»¥i¿ï¾Ü¦¹ºë«×";
	}else{
		jdzs.innerHTML="¥i¿ï720dpi(¼Ð·Çºë«×)©Î1440dpi(°ªºë«×)";
	}	
}
function getcl(thisvalue){

	var jpcl=document.getElementById("jpcl");
	if(thisvalue=="¥ú­±"){
		jpcl.innerHTML="·m²´D,LING­±";
	}else if(thisvalue=="°×­±"){
		jpcl.innerHTML="°ª¯ÅD,°×­±";
	}else{
		jpcl.innerHTML="¥i¿ï¥ú­±©Î°×­±";
	}
	
	
}
function ComputeTotalPrice(){
	var productprice=document.getElementById("productprice").value;
	var unitprice=productprice.split("|");
	var width=document.getElementById("width").value;
	var height=document.getElementById("height").value;
	var units=document.getElementById("unit").value;
	var precision=document.getElementById("precision").value;
	var amount=document.getElementById("amount").value;
	var TotalObj=document.getElementById("Totalprice");
	var parentid=document.getElementById("pid").value;
	var orderbut=document.getElementById("orderbut");
	var totalprice,bprice,gprice,jprice;
	bprice=unitprice[0];
	gprice=unitprice[1];
	jprice=unitprice[2];
	if(width==""||height==""||units==""||precision==""||amount==""){
		alert("Please fill out the order content!!");
		return false;
	}
	var standardM=Math.round(ConvertM(width,height,units)*100)/100;
	if(productprice=="2.5|2.5|2.5|361"){
		var morelength=(height>width?height:width);
		var littlelength=(height>width?width:height);
		if(ConvertCM(littlelength,units)>60){
			totalprice=ConvertInch(morelength,units)*4*parseInt(amount);
		}else{
			totalprice=ConvertInch(morelength,units)*2.5*parseInt(amount);
		}
		document.getElementById("total").value=totalprice;
		TotalObj.innerHTML="US$"+(Math.round(totalprice)).toString();
		orderbut.style.display="block";
		return;
	}
	//if(parentid=="78"||parentid=="79"){
//		
//		if(ConvertInch(width,units)>40||ConvertInch(height,units)>40){
//			bprice=parseInt(unitprice[0])+7;
//			gprice=parseInt(unitprice[1])+7;
//			jprice=parseInt(unitprice[2])+7;
//		}
//	}
	if(precision==720){
		if(unitprice[0]==""||unitprice[0]==0){
		alert('This product do not have 720dpi price!');
		return false;
		}
		totalprice=standardM*(Math.round(bprice*100)/100)*parseInt(amount);
	}
	if(precision==1440){
		if(unitprice[1]==""||unitprice[1]==0){
		alert("This product do not have 1440dpi price!");
		return false;
		}
		totalprice=standardM*(Math.round(gprice*100)/100)*parseInt(amount);
	}
	if(precision=="jj"){
		if(unitprice[2]==""||unitprice[2]==0){
		alert("This product do not have stand only!");
		return false;
		}
		totalprice=standardM*(Math.round(jprice*100)/100)*parseInt(amount);
	}
	var totalpricetoo=totalprice;
		if(parseInt(totalprice)<50){
			document.getElementById("pricenote").style.display="block";
			totalprice=50;
		}else{
			document.getElementById("pricenote").style.display="none";
		}
		document.getElementById("total").value=totalprice;
	    TotalObj.innerHTML="US$"+(Math.round(totalpricetoo)).toString();	
		orderbut.style.display="block";
}
	function turnto(){
		
		var parameter=document.getElementById("productprice").value;
		var strarr=parameter.split("|");
		document.orderform.action="online_index.asp?productID="+strarr[3];		
		orderform.submit();
	}
	function turnprint(){		
		var parameter=document.getElementById("Printid").value;
		//var strarr=parameter.split("|");
		document.printform.action="online_print.asp?productID="+parameter;		
		printform.submit();
	}
	function ComputePrintPrice(){
		var productprice=document.getElementById("shuliang").value;
		var orderbut=document.getElementById("orderbut1");
		var parmeter=productprice.split("|");
		var printprice=document.getElementById("printprice");
		var houqi=document.getElementsByName("houqi");
		var totalprice;
		
		if(parmeter[0]==""||parmeter[1]==""){
			alert("²£«~»ù®æ¦³»~");
		}else{
			var UnitPrice=parseFloat(parmeter[0]);
			for(var i=0;i<houqi.length;i++)
			if(houqi[i].checked){
				UnitPrice=UnitPrice+parseFloat((houqi[i].value).split("|")[0]);
				
			}
			totalprice=Math.round(parseInt(parmeter[1])*UnitPrice);
			if(totalprice<50){
			document.getElementById("pricenote").style.display="block";
			totalprice=50;
		}else{
			document.getElementById("pricenote").style.display="none";
		}
			document.getElementById("UnitPrice").value=Math.round(UnitPrice*1000)/1000;	
			printprice.innerHTML="US$"+(Math.round(parseInt(parmeter[1])*UnitPrice)).toString();
			document.getElementById("totalPrint").value=totalprice;
			orderbut.style.display="block";
		}
	}
	//function getRole(){ 
//	  var allCHK = document.body.all.tags('INPUT'); 
//	  
//	  var lstr = "" ; 
//	  for(i=0;i<allCHK.length;i++){ 
//		alert(houqi.length);
//		for(var i=0;i<houqi.length;i++)
//			if(houqi[i].checked)
//				alert(houqi[i].value)
//	  var inputList =document.getElementsByTagName("checkbox"); 
//		if(allCHK[i].type.toUpperCase()=="CHECKBOX" && allCHK[i].checked==true){ 
//		   if (lstr==""){ 
//			  lstr = allCHK[i].value; 
//		   }else {   
//		  lstr= lstr + "," + allCHK[i].value; 
//		  } 
//			   
//		  
//		 } 
//	  } 
//	  alert(lstr); 
//	  return lstr ; 
//	} 
