// JavaScript Document


//----------------------------------------------------------------------
//PRINT MODEL PROFILE

function creatXMLHttp(){
	try{
		return new ActiveXObject("Microsoft.XMLHTTP");
		
	}catch(e){
		try{
			return new XMLHttpRequest();
		}catch(e){
			return null;	
		}
	}
	return null;
}

//----------------------------------------------------------------------
function upModelPrint(a,b){
	
	//SELECT A PHOTO AT LEAST
	var upMG = document.getElementById("MG");
	var lenMG = upMG.value;	
	var box_arr = new Array();	
	var box_sel = "";	
	var box_num = 0;
	
	for (i=1; i<=lenMG; i++){
		box_arr[i] = document.getElementById("MG"+i);
		if (box_arr[i].checked){
			box_sel += "," + box_arr[i].value;
			box_num +=1;
		}
	}
	if (box_num<=0){
		alert("Check a picture at least.");
		return false;
	}
	if (box_num>8){
		alert("Too many pictures. Please check 8 images only.");
		return false;
	}

	//PTwin = window.open(url,"ptWin");
	//PTwin.document.write(a+" , "+b+" , "+box_sel);
	
	//SEND MODEL PROFILE TO SERVER
	url="client/mdlt_model_pt.php?pid="+escape(a)+"&unit="+escape(b)+"&arr="+escape(box_sel);
	xmlhttp=creatXMLHttp();
	if(xmlhttp)
	{
		xmlhttp.onreadystatechange=check;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
	
}
//----------------------------------------------------------------------
function check(){
	
	if(xmlhttp.readyState==4 && xmlhttp.status==200)
	{
		PTwin = window.open("print.html","FMI");
		PTwin.document.write(xmlhttp.responseText);
		PTwin.window.print();
	}
}
//----------------------------------------------------------------------