function PopUp(theURL,winName,features)
{
	window.open(theURL,winName,features);
}


function setparam(action,param,value){
	var act, p, p1, s;
	p = action.indexOf(param);
	if (p!=-1){s = action.substr(p+param.length);
		p1 = s.search("&");
		if (p1!=-1){action = action.substr(0, p+param.length) + value + s.substr(p1);}
		else{action = action.substr(0, p+param.length) + value;}
	}
	else{if (action.indexOf("?")!=-1){action += "&"+param+value;}
		else{action += "?"+param+value;}}
	return action;
}

function checkselector(form){
	if (form != null){
		var act, price, category, t;
		price = form.pricefilter;
		category = form.categoryfilter;
		act = new String(form.action);
	
		if (category != null){act = setparam(act,'CAT_ID=', category.value);}
		if	(act.indexOf(",")!=-1){act = "readymadeprodtype.asp" + act.substr(act.indexOf("?"), act.length);}
		if (price != null){	
				priceArr = price.value.split('_')
					minPrice = priceArr[0]
					maxPrice = priceArr[1]
				}
                                else {
                                        minPrice = 0
                                        maxPrice = 9999999
                                }

		act = setparam(act,'numPriceMin=', minPrice);
		act = setparam(act,'numPriceMax=', maxPrice);
		act = setparam(act,'fprice=', price.value);
	
		form.action = act;
		form.submit();
	}
}	


var i,s, s1, p, ops, fprice, pt_id;
s = new String(document.location.search);
if (document.ReadyMode != null){document.ReadyMode.action += s;}

fprice=""; pt_id="";
if (s.length!=0){
	p = s.indexOf("fprice");
	if (p!=-1){s1 = s.substr(p+7);
		p1 = s1.search("&");
		if (p1!=-1){fprice = s1.substr(0, p1);}
		else{fprice = s1.substr(0);}
	}
	
	p = s.indexOf("CAT_ID");
	if (p!=-1){s1 = s.substr(p+7);
		p1 = s1.search("&");
		if (p1!=-1){pt_id = s1.substr(0, p1);}
		else{pt_id = s1.substr(0);}
	}
	
	if (document.ReadyMode.pricefilter != null){
		ops	= document.ReadyMode.pricefilter.options;
		for (i=0; i<ops.length; i++){if (ops[i].value === fprice){ops[i].selected = true;break;}}
	}
	if (document.ReadyMode.categoryfilter != null){
		ops	= document.ReadyMode.categoryfilter.options;
		for (i=0; i<ops.length; i++){if (ops[i].value === pt_id){ops[i].selected = true; break;}}
	}
}
