var picSize = 50;
function doHandleNotif(){
	var td = event.srcElement;
	var tr = document.all.mainAucTbl.rows(td.rowid);
	if (tr.style.display == 'none'){
		td.innerText = 'סגור';
		tr.style.display = 'block';
	}else{
		td.innerText = 'הייתי קונה אם';	
		tr.style.display = 'none';
	}
}
function setPics(){
	var td;
	var img;
    for(var i in pics){
		var td = document.getElementById(i);
		img = pics[i];		
		if (img.width !=0){
			td.appendChild(img);
			if (img.width > img.height){
				img.height = img.height * (picSize/img.width);
				img.width = picSize;
			}else{
				img.width = img.width * (picSize/img.height);
				img.height = picSize;
			}
		}else{
			var fake = document.createElement("td");
			fake.appendChild(img);
			img.td = td;
			img.onreadystatechange = setImgSize;		
		}
	}
}
function setImgSize(){
    var img = event.srcElement;
	if (img.readyState != 'complete') return;
	if (img.width > img.height){
		img.height = img.height * (picSize/img.width);
		img.width = picSize;
	}else{
		img.width = img.width * (picSize/img.height);
		img.height = picSize;
	}
	img.td.appendChild(img);
}
function openInterest(prodId, desc, idx){
	var frm = eval('document.toolbarFrm_' + idx);

		var str = 'PartnerInterest.jsp?time=10&type=1' + 
				'&price='+ frm.price.value + '&prodId=' + prodId +"&keywords=" + desc;
	if (frm.email){
		str = str + '&email=' + frm.email.value;
	}
	
	if (frm.sms && frm.sms.value){
		str = str + '&sms=' + frm.smspref.value + frm.sms.value;
	}
	
	if (frm.smsOn && ! frm.smsOn.checked)
		str = str + '&smsOn=0';
	else
		str = str + '&smsOn=1';
	if(frm.days){
		str = str + '&days=' + frm.days.value;
	}
	window.open(str,'remote','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=100,top=350,height=210,width=374');
}
function filterAuctionsCat(catId){
	doAttFilters();
	var id = document.frmCatAuctions.hiddenSubCat.value != 0 ? document.frmCatAuctions.hiddenSubCat.value : catId;
	var fromPrice = document.frmCatAuctions.fromPrice.value;
	var toPrice = document.frmCatAuctions.toPrice.value;
	var orderBy = document.frmCatAuctions.orderBy.value;
	var keywords = document.frmCatAuctions.keywords.value;
	var parentCatId = document.frmCatAuctions.hiddenParentCatId.value;
	var makerId = document.frmCatAuctions.hiddenMaker.value;
	var auctionType = document.frmCatAuctions.hiddenAuctionType.value;
	var att0 = "";
	var att1 = "";
	var att2 = "";
	var att3 = "";
	var att4 = "";
	var attFilters = "";
	if (document.frmCatAuctions.att_0){
		att0 = document.frmCatAuctions.att_0.value;
	}
	if (document.frmCatAuctions.att_1){
		att1 = document.frmCatAuctions.att_1.value;
	}
	if (document.frmCatAuctions.att_2){
		att2 = document.frmCatAuctions.att_2.value;
	}
	if (document.frmCatAuctions.att_3){
		att3 = document.frmCatAuctions.att_3.value;
	}
	if (document.frmCatAuctions.att_4){
		att4 = document.frmCatAuctions.att_4.value;
	}
	if (document.frmCatAuctions.attFilters && document.frmCatAuctions.attFilters.value){
		attFilters = document.frmCatAuctions.attFilters.value;
	}
	
	if (document.frmCatAuctions.auc99){
		document.location.replace('./item_level.jsp?catId=' + id +'&orderBy=' + orderBy +'&fromPrice=' + fromPrice+'&toPrice=' + toPrice + '&keywords=' + keywords + '&parentCatId=' + parentCatId + '&maker=' + makerId +'&auc99=1' + '&att0=' + att0+ '&att1=' + att1+ '&att2=' + att2+ '&att3=' + att3+ '&att4=' + att4 + '&auctionType=' + auctionType + "&attFilters=" + attFilters);
	}
	else{
		document.location.replace('./item_level.jsp?catId=' + id +'&orderBy=' + orderBy +'&fromPrice=' + fromPrice+'&toPrice=' + toPrice+ '&keywords=' + keywords + '&parentCatId=' + parentCatId + '&maker=' + makerId + '&att0=' + att0+ '&att1=' + att1+ '&att2=' + att2+ '&att3=' + att3+ '&att4=' + att4 + '&auctionType=' + auctionType + "&attFilters=" + attFilters);
	}
}

function catSelectionChanged(parentId){
	document.frmCatAuctions.hiddenSubCat.value = document.frmCatAuctions.subCat.value;
	document.frmCatAuctions.hiddenParentCatId.value = parentId;
}

function makerSelectionChanged(){
	document.frmCatAuctions.hiddenMaker.value = document.frmCatAuctions.makers.value;
}

function auctionTypeChanged(){
	document.frmCatAuctions.hiddenAuctionType.value = document.frmCatAuctions.auctionType.value;
}

function repl(paramName,ParamValue) 
{ 
		var x = document.location.href;	
		//x+= document.location.search;
		var myParam = '?loadtree=true';
		var i = x.indexOf(myParam);
		if (i > -1){
			x = x.substring(0,i);
		}
			
        len = paramName.length;
        loc1= x.indexOf(paramName);
        if (loc1>-1) 
        { 
                loc1=loc1+len;
                var x1=x.substring(0,loc1);				
                loc2 = x.indexOf('&',loc1);
				var x2;				
                var x2=x.substring(loc2,x.length);
				if(loc2 != -1){				
	                x=x1+"="+ParamValue+x2;
				}else{
					x=x1+"="+ParamValue;
				}
        } 
        else 
        { 
                if(x.indexOf("?")>-1){
                        x=x+"&"+paramName+"="+ParamValue;
				}
                else{
                        x=x+"?"+paramName+"="+ParamValue;
				}
        } 	
        document.location.replace(x); 
}

function filterAuctionsKeyPress(aucID){
	 if (window.event.keyCode==13){
		filterAuctionsCat(aucID);
	}
}
