// JavaScript Document
function trade_item(frm,val){
	itm 		= 	val.split("##");
	id	=	itm[0];
	item_name		=	itm[1];
	hcp_id			=	itm[2];
	status			=	itm[3];
	expected_price	=	itm[4];
	frm.action="?id="+id;
	document.getElementById("quote_box").style.display="";
	if(status!=1){
	document.getElementById("dtls").style.display = "";
	document.getElementById("err_box").style.display = "none";
	document.getElementById("lbl_item").innerHTML=item_name;
	document.getElementById("lbl_exp_price").innerHTML=expected_price;
 	frm.item_id.value=id;
	frm.item_name.value=item_name;
	frm.hcp_id.value=hcp_id;
	frm.expected_price.value=expected_price;
	}
	else{
	document.getElementById("err_box").style.display="";
	document.getElementById("dtls").style.display="none";
	}
}
function enlarge(i,nm){
					window.open("enlarge_photo.php?path="+i+"&nm="+nm,"mywindow","toolbar=0,status=0,scrollbars=1,width=auto,height=auto,resizable=yes");

	}
function assignUsers(id){
					window.open("hcp.assign.users.php?id="+id,"mywindow","toolbar=0,status=0,scrollbars=1,width=560,height=308,resizable=no");

	}	
function final_item(frm,val){
	
	itm 				= 	val.split("##");
	id 					=  	itm[0];
	item_name			=	itm[1];
	price				=	itm[2];
	expected_price		=	itm[3];
	cost_code			=	itm[4];
	document.getElementById("final_box").style.display="";
	document.getElementById("lbl_fitem").innerHTML=item_name;
	document.getElementById("lbl_fprice").innerHTML=price;
	document.getElementById("lbl_fexp_price").innerHTML=expected_price;
	document.getElementById("lbl_fcostcode").innerHTML=cost_code;
 	frm.item_id2.value=id;
	frm.item_name2.value=item_name;
	frm.price2.value=price;
}

function maketrade(id){
 window.open("hcp.makefortrade.php?id="+id,"mywindow","toolbar=0,status=0,scrollbars=1,  width=330,height=150");
}
function maketrade_user(id,hcp_id){

 window.open("hcp_user.makefortrade.php?id="+id+"&hcp_id="+hcp_id,"mywindow","toolbar=0,status=0,scrollbars=1,  width=300,height=150");
}
function accept_trade(tr_id,id,hcp_id){ 

	 if(window.confirm('Are you sure? you want to accept this trade.')){
		 document.location.href="hcp.accept_trade.php?tr_id="+tr_id+"&item_id="+id+"&hcp_id="+hcp_id;
	 }
}
function approve_trade(tr_id,id,hcp_id){ 

	 if(window.confirm('Are you sure? you want to approve this item for trade.')){
		 document.location.href="hcp.approve_trade.php?tr_id="+tr_id+"&item_id="+id+"&hcp_id="+hcp_id;
	 }
}
function approve_reutrn_request(id){ 

	 if(window.confirm('Are you sure? you want to approve this item return request.')){
		 document.location.href="hcp.approve_return_request.php?id="+id;
	}
}

function deny_retun_item(id){
	window.open("hcp.deny_return.php?id="+id,"denyWindow","toolbar=0,status=0,scrollbars=1,width=560,height=308,resizable=no");
//	if(window.confirm('Are you sure? you want to deny this trade.')){

	// }
}
function deny_liq(id){
	window.open("hcp.deny_liq.php?id="+id,"denyWindow","toolbar=0,status=0,scrollbars=1,width=560,height=308,resizable=no");
}
function deny_liqr(id){
	window.open("hcp.deny_liq.php?pg=hcp.liq.items.php&id="+id,"denyWindow","toolbar=0,status=0,scrollbars=1,width=560,height=308,resizable=no");
}

function deny_disp(id){
	window.open("hcp.deny_disp.php?id="+id,"denyWindow","toolbar=0,status=0,scrollbars=1,width=560,height=308,resizable=no");
}
function deny_trade(it_id,tr_id,url){
	window.open("hcp.deny_trade.php?it_id="+it_id+"&tr_id="+tr_id+"&lnk="+url,"denyWindow","toolbar=0,status=0,scrollbars=1,width=560,height=308,resizable=no");
//	if(window.confirm('Are you sure? you want to deny this trade.')){

	// }
}

function setLiquidationFee(fee,liq_fee,fld){
	liquidationFee = (fee*liq_fee)/100;
	fld.value=liquidationFee;
}

function make_enable(id,mod){
	if(mod==1){
		document.getElementById(id).style.display="";
	}
	else{
			document.getElementById(id).style.display="none";
	}
}


function get_detail(ctl) {
if(ctl>0){
$('item_detail').innerHTML='<center><img src="images/loading.gif"><br>loading...</center>';
	var url 	= 'load.detail.php';
	var params = 'id='+ctl;
//document.write(params);
	var myAjax = new Ajax.Request(url, {method: 'get', parameters: params, onComplete: status_message});
}
}
function status_message(a){

if(a.responseText!= ""){
$("item_detail").innerHTML=a.responseText;
}else{

}
}

function check_selection(ctl1,ctl2,mod){
if(mod==1){
if(ctl1.checked){
	ctl2.checked=false;	
	}
}
else{
if(ctl2.checked){
	ctl1.checked=false;	
}
}


}
function showHide(elm,me){
	if(me.checked){
	elm.style.display='';
	}
	else{
		elm.style.display='none';
	}
}
//Getting User Details....
function get_udetail(ctl) {
if(ctl>0){
$('user_detail').innerHTML='<center><img src="images/loading.gif"><br>loading...</center>';
	var url 	= 'user.load.php';
	var params = 'id='+ctl;
//document.write(params);
	var myAjax = new Ajax.Request(url, {method: 'get', parameters: params, onComplete: ustatus_message});
}
}
function ustatus_message(a){

if(a.responseText!= ""){
$("user_detail").innerHTML=a.responseText;
}else{

}
}
function cleardates(sdt,edt){
sdt.value="";
edt.value="";
}
function print_report(ttl,url){
win = window.open(url,"mywindow","toolbar=0,status=0,scrollbars=1,  width="+(screen.width-100)+",height="+(screen.height-100));
win.ttl=ttl;
win.moveTo(0,0);
win.print();
}

//Getting User Details...


///////////////////////////////////////////////////////////////////////
function hcp_pickup_add_display_category_description(){
	if($("#hcp_cat").val()){
		var id = $("#hcp_cat").val();
		var cd = $("div#cat_desc"+id).html();
		$("div#cat_desc").html(cd);
	}else{
		$("div#cat_desc").html("");
	}
}