var newwindow;
var previous=0;

function poptastic(url)
{
	newwindow=window.open(url,"inches","height=130,width=500,left=378,top=350");
	if (window.focus) {newwindow.focus()}
}

var group;
function loadOptions()
{
	var groups=document.search.cat.options.length;
	group=new Array(groups);
	var found_privacy = false;
	var found_child_safe = false;

	for (i=0; i<groups; i++) {
		group[i]=new Array();
		
		// check if privacy is in the list of options
		if(document.search.cat.options[i].value == "privacy")
			found_privacy = true;

		// check if child_safe is in the list of options
		if(document.search.cat.options[i].value == "child_safe")
			found_child_safe = true;

	}
	
	//wood
	group[0][0]=new Option("25mm slat", "25");
	group[0][1]=new Option("35mm slat", "35");
	group[0][2]=new Option("50mm slat", "50");
	
	//aluminium
	group[1][0]=new Option("Whites", "12");
	group[1][1]=new Option("Creams", "2");
	group[1][2]=new Option("Silvers", "4");
	group[1][3]=new Option("Blues", "1");
	group[1][4]=new Option("Yellows", "9");
	group[1][5]=new Option("Greens", "3");
	group[1][6]=new Option("Reds", "7");
	group[1][7]=new Option("Greys", "14");	
	group[1][8]=new Option("Blacks", "10");
	group[1][9]=new Option("Browns", "8"); // +
	group[1][10]=new Option("Oranges", "5"); // +
	group[1][11]=new Option("Pinks", "6"); // +
	group[1][12]=new Option("Beiges", "13"); // +
	group[1][13]=new Option("Golds", "23"); // +		
	group[1][14]=new Option("Wood effects", "18");

	//vertical
	group[2][0]=new Option("Whites", "12");
	group[2][1]=new Option("Creams", "2");
	group[2][2]=new Option("Blackout", "22");
	group[2][3]=new Option("Blues", "1");
	group[2][4]=new Option("Greys", "14");
	group[2][5]=new Option("Yellows", "9");
	group[2][6]=new Option("Greens", "3");
	group[2][7]=new Option("Reds", "7");
	group[2][8]=new Option("Pinks", "6");
	group[2][9]=new Option("Blacks", "10");
	group[2][10]=new Option("Browns", "8");
	group[2][11]=new Option("Real woods", "17");
	group[2][12]=new Option("Wood effects", "18");
	group[2][13]=new Option("PVC", "20");
	group[2][14]=new Option("Pattern", "19");
	group[2][15]=new Option("Oranges", "5");
	group[2][16]=new Option("Beiges", "13");
	
	//roller
	group[3][0]=new Option("Blackout", "0");
	group[3][1]=new Option("Whites", "12");
	group[3][2]=new Option("Creams", "2");
	group[3][3]=new Option("Blues", "1");
	group[3][4]=new Option("Greys", "14");
	group[3][5]=new Option("Yellows", "9");
	group[3][6]=new Option("Reds", "7");
	group[3][7]=new Option("Greens", "3");
	group[3][8]=new Option("Browns", "8");
	group[3][9]=new Option("Oranges", "5");
	group[3][10]=new Option("Lilacs", "16");
	group[3][11]=new Option("Pinks", "6");
	group[3][12]=new Option("Blacks", "10");
	group[3][13]=new Option("Beiges", "13");
	group[3][14]=new Option("Pattern", "19");
	
	//roman
	group[4][0]=new Option("Whites", "12");
	group[4][1]=new Option("Creams", "2");
	group[4][2]=new Option("Yellows", "9");
	group[4][3]=new Option("Reds", "7");
	group[4][4]=new Option("Blues", "1");
	group[4][5]=new Option("Beiges", "13");
	group[4][6]=new Option("Browns", "8");
	group[4][7]=new Option("Greens", "3");
	group[4][8]=new Option("Greys", "14");
	group[4][9]=new Option("Pinks", "6");
	group[4][10]=new Option("Patterns", "19");
	group[4][11]=new Option("Blacks", "10");
	group[4][12]=new Option("Oranges", "5");
	group[4][13]=new Option("Lilacs", "16");

	
	//pleated
	group[5][0]=new Option("Colors", "0");
	
	//velux

	group[6][0]=new Option("Roller","1");
	group[6][1]=new Option("Awning","2");
	group[6][2]=new Option("Pleated","3");
	group[6][3]=new Option("Venetian","4");
	group[6][4]=new Option("Blackout","5");

	/*
	group[6][0]=new Option("Blackouts","599");
	group[6][1]=new Option("Rollers","199");
	*/
	
	//silhouette
	group[7][0]=new Option("Whites", "12");
	group[7][1]=new Option("Creams", "2");
	group[7][2]=new Option("Blues", "1");
	group[7][3]=new Option("Yellows", "9");
	group[7][4]=new Option("Greys", "14");
	group[7][5]=new Option("Browns", "8");
	group[7][6]=new Option("Greens", "3");
	group[7][7]=new Option("Pinks", "6");
	
	//duette
	group[8][0]=new Option("Whites", "12");
	group[8][1]=new Option("Creams", "2");
	group[8][2]=new Option("Blues", "1");
	group[8][3]=new Option("Yellows", "9");
	group[8][4]=new Option("Oranges", "5");
	group[8][5]=new Option("Browns", "8");
	group[8][6]=new Option("Greens", "3");
	group[8][7]=new Option("Pinks", "6");
	group[8][8]=new Option("Reds", "7");
	
	// Facette
	group[9][0]=new Option("Whites", "12");
	group[9][1]=new Option("Creams", "2");
	group[9][2]=new Option("Blues", "1");
	group[9][3]=new Option("Greys", "14");
	group[9][4]=new Option("Browns", "8");
	group[9][5]=new Option("Lilacs", "16");
	group[9][6]=new Option("Beiges", "13");
	group[9][7]=new Option("Mauves", "11");
  
	//woven
	group[10][0]=new Option("Roman", "1");
	group[10][1]=new Option("Roll up", "2");
	
	//cellular
	group[11][0]=new Option("Whites","12");
	group[11][1]=new Option("Creams","2");
	group[11][2]=new Option("Blues","1");
	group[11][3]=new Option("Lilacs","16");
	
	// privacy found
	if(found_privacy) {
		//Privacy
		group[12][0]=new Option("50mm slat", "50");
		group[12][1]=new Option("63mm slat", "63");

		//Curtains
    	group[13][0]=new Option("Ready made","rm");
      group[13][1]=new Option("Trim Drop","dt");
//		group[13][0]=new Option("Creams","2");
//		group[13][1]=new Option("Reds","7");
//		group[13][2]=new Option("Blues","1");
//		group[13][3]=new Option("Browns","8");
//		group[13][4]=new Option("Pinks","6");
//		group[13][5]=new Option("Patterns","19");
//		group[13][6]=new Option("Blacks","10");
//		group[13][7]=new Option("Lilacs","16");
//	  group[13][8]=new Option("Yellows","9");

	}	
	else { // no privacy found
		//Curtains
   group[12][0]=new Option("Ready made","rm");
   group[12][1]=new Option("Trim Drop","dt");
//		group[12][0]=new Option("Creams","2");
//		group[12][1]=new Option("Reds","7");
//		group[12][2]=new Option("Blues","1");
//		group[12][3]=new Option("Browns","8");
//		group[12][4]=new Option("Pinks","6");
//		group[12][5]=new Option("Patterns","19");
//		group[12][6]=new Option("Blacks","10");
//		group[12][7]=new Option("Lilacs","16");
//  	group[12][8]=new Option("Yellows","9");
		
	}

	if(found_child_safe) { // if child safe, then I'm sure it's not privacy
		//Child Safe Blinds
		group[13][0]=new Option("Rollers", "64");
		group[13][1]=new Option("Blackouts", "0");
	}

	var categ=document.search.cat.options.selectedIndex;
	changeDrop(categ);
	previous=categ;
}

function changeDrop(x)
{
	/*var temp=document.search.slat;
	for (m=temp.options.length-1;m>0;m--)
		temp.options[m]=null;
	for (i=0;i<group[x].length;i++)
	{
		temp.options[i]=new Option(group[x][i].text,group[x][i].value);
	}
	temp.options[0].selected=true;*/
	
	var sel_slat=document.search.slat.value;
	var temp = document.search.slat;
  
  Element.stopObserving(temp, 'change');
  
	for (m=temp.options.length-1;m>0;m--)
		temp.options[m]=null;
		
	var i=0;
	var poz_index=0;
	if(group[x])
	for (i=0;i<group[x].length;i++)
	{
		temp.options[i]=new Option(group[x][i].text,group[x][i].value);
		if(group[x][i].value==sel_slat)
			poz_index=i;
	}

	document.search.slat.options.selectedIndex=poz_index;
	
	if(x==6)
	{	
		document.getElementById('s1').innerHTML = "Type";
		document.getElementById('s2').innerHTML = "Size";
		hideElement('width');
		showElement('type');

		populateSelect('type', Array("GGL","GHL","GPL","GGU","GPU"), 1);
		hideElement('drop');
		showElement('size');
		change_sizes(document.search.slat.value);
//populateSelect('size',Array('1','2','3','4','5','6','7','8','9','102','104','206','304','306','308','410','606','804','808','C01','C02','C04','F06','M04','M06','M08','P04','P10','S06','U04','U08'));
	}
	else 
	{
		if (previous==6) //dc anterior am avut categ velux stergem width si drop din input
		{
			document.search.drop.value="";
			document.search.width.value="";

		}
    document.getElementById('s1').innerHTML = "Width (mm)";
    document.getElementById('s2').innerHTML = "Drop (mm)";
    hideElement('size');
    showElement('drop');
    hideElement('type');
    showElement('width');
    
    if (document.search.cat.value == 'curtains') update_curtains_rm_dt(temp.value);
    else reset_width_drop();
    if (document.search.cat.value == 'curtains') Element.observe(temp, 'change', function(zvent){update_curtains_rm_dt(zvent.target.value);} );

	}

}
function reset_width_drop()
{
  if ($('width')) var temp_w = $('width');
  else var temp_w = document.search.width;
  if ($('drop')) var temp_d = $('drop');
  else var temp_d = document.search.drop;
  Element.stopObserving(temp_w, 'change');
  old_w = new Element('input', { type: 'text', style: 'display: block;', 'class': 'fields', name: 'width', id: 'width', size: '9', maxlength: '128' });
  old_d = new Element('input', { type: 'text', style: 'display: block;', 'class': 'fields', name: 'drop', id: 'drop', size: '9', maxlength: '128' });
  dd = get_params();
  if (dd.drop) old_d.value = dd.drop;
  if (dd.width) old_w.value = dd.width;
  Element.replace(temp_w, old_w);
  Element.replace(temp_d, old_d);
  return true;
}
function update_curtains_rm_dt(curtains_type)
{
  if ($('width')) temp_w = $('width');
  else temp_w = document.search.width;
  Element.stopObserving(temp_w, 'change');
  dd = get_params();
  
  custom_width_select = new Element('select', { 'class': 'fields', name: 'width', id: 'width' });
  if (dd.cat == 'curtains' && dd.width && dd.width == 1168) custom_width_select_option = new Element('option', { 'value': '1168', 'selected': 'selected' }).insert("1168 mm (46'')");
  else custom_width_select_option = new Element('option', { 'value': '1168' }).insert("1168 mm (46'')");
  custom_width_select.insert(custom_width_select_option);
  if (dd.cat == 'curtains' && dd.width && dd.width == 1676)  custom_width_select_option = new Element('option', { 'value': '1676', 'selected': 'selected' }).insert("1676 mm (66'')");
  else custom_width_select_option = new Element('option', { 'value': '1676' }).insert("1676 mm (66'')");
  custom_width_select.insert(custom_width_select_option);
  if (dd.cat == 'curtains' && dd.width && dd.width == 2286)  custom_width_select_option = new Element('option', { 'value': '2286', 'selected': 'selected' }).insert("2286 mm (90'')");
  else custom_width_select_option = new Element('option', { 'value': '2286' }).insert("2286 mm (90'')");
  custom_width_select.insert(custom_width_select_option);
  Element.replace(temp_w, custom_width_select);
  if (curtains_type == 'rm')
  {
    update_curtains_rm_d(1168);
    if ($('width')) temp_w = $('width');
    else temp_w = document.search.width;
    Element.observe(temp_w, 'change', function(zvent){update_curtains_rm_d(zvent.target.value);} );
  }
  else
  {
    if ($('drop')) temp_d = $('drop');
    else temp_d = document.search.drop;
    if (dd.cat == 'curtains' && dd.slat == 'dt' && dd.drop) old_d = new Element('input', { value: dd.drop, type: 'text', style: 'display: block;', 'class': 'fields', name: 'drop', id: 'drop', size: '9', maxlength: '128' });
    else old_d = new Element('input', { type: 'text', style: 'display: block;', 'class': 'fields', name: 'drop', id: 'drop', size: '9', maxlength: '128' });
    if (dd.drop) old_d.value = dd.drop;
    Element.replace(temp_d, old_d);
  }
}
function update_curtains_rm_d(current_width)
{
  if ($('drop')) temp_d = $('drop');
  else temp_d = document.search.drop;
  
  dd = get_params();
  
  custom_drop_select = new Element('select', { 'class': 'fields', name: 'drop', id: 'drop' });
  if (dd.cat == 'curtains' && dd.slat == 'rm' && dd.drop && dd.drop == 1372) custom_drop_select_option = new Element('option', { 'value': '1372', 'selected':'selected' }).insert("1372 mm (54'')");
  else custom_drop_select_option = new Element('option', { 'value': '1372' }).insert("1372 mm (54'')");
  custom_drop_select.insert(custom_drop_select_option);
  if (dd.cat == 'curtains' && dd.slat == 'rm' && dd.drop && dd.drop == 1829) custom_drop_select_option = new Element('option', { 'value': '1829', 'selected':'selected' }).insert("1829 mm (72'')");
  else custom_drop_select_option = new Element('option', { 'value': '1829' }).insert("1829 mm (72'')");
  custom_drop_select.insert(custom_drop_select_option);
  if (dd.cat == 'curtains' && dd.slat == 'rm' && dd.drop && dd.drop == 2286) custom_drop_select_option = new Element('option', { 'value': '2286', 'selected':'selected' }).insert("2286 mm (90'')");
  else custom_drop_select_option = new Element('option', { 'value': '2286' }).insert("2286 mm (90'')");
  custom_drop_select.insert(custom_drop_select_option);
  if (current_width != 1168)
  {
    if (dd.cat == 'curtains' && dd.slat == 'rm' && dd.drop && dd.drop == 2743) custom_drop_select_option = new Element('option', { 'value': '2743', 'selected':'selected' }).insert("2743 mm (108'')");
    else custom_drop_select_option = new Element('option', { 'value': '2743' }).insert("2743 mm (108'')");
    custom_drop_select.insert(custom_drop_select_option);
  }
  Element.replace(temp_d, custom_drop_select);
  if ($('drop')) temp_d = $('drop');
  else temp_d = document.search.drop;
}

/* populate size list according to the selected slat */
function change_sizes (slat) {
	//alert(slat);	
	if(slat == 2) // Awning
		populateSelect('size',Array('1','2','3','4','5','6','7','8','102','104','206','304','306','308','410','606','804','808','C02','C04','F06','M04','M06','M08','P10','S06','U04','U08'), 0);
	else
		populateSelect('size',Array('1','2','3','4','5','6','7','8','9','102','104','206','304','306','308','410','606','804','808','C01','C02','C04','F06','M04','M06','M08','P04','P10','S06','U04','U08'), 0);
	//populateSelect('size',Array('C02','C04','F06','M04','M06','M08','P10','S06','U04','U08'), 0);
}


function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}
function verifyWidthDrop()
{
	var width=parseInt(document.search.width.value);
	var drop=parseInt(document.search.drop.value);
	var cat=document.search.cat.value;
	var slat=parseInt(document.search.slat.value);

	if (cat=="woven")
	{
		min_width=400;
		max_width=2000;
		min_drop=400;
		max_drop=2200;
		if (slat == 1 && drop==1600)
		{
			min_width=300;
			max_width=2000;
		}
		else if (slat == 1 && drop==2200)
		{
			min_width=300;
			max_width=2000;
			max_drop=2200;
		}
		else if (slat == 2 && drop==2200)
		{
			min_width=300;
			max_width=1950;
			max_drop=2200;
		}
		/*else if(1400<width)
		{
			max_drop=1500;
		}*/
		if((min_width>width)||(max_width<width)||(isNaN(width)))
		{
			alert("Please enter width between "+min_width+"mm (min) and "+max_width+"mm (max) ");
			return false;
		}
		if((min_drop>drop)||(max_drop<drop)||(isNaN(drop)))
		{
			alert("Please enter drop between "+min_drop+"mm (min) and "+max_drop+"mm (max)");
			return false;
		}
	}
	if (cat=="shades")
	{
		min_width=610;
		max_width=2400;
		min_drop=300;
		max_drop=3000;
		if((slat=="1") || (slat=="9") || (slat=="14"))
		{
			min_width=610;
			max_width=2437;
			min_drop=300;
			max_drop=2437;
		}
		if((min_width>width)||(max_width<width)||(isNaN(width)))
		{
			alert("Please enter width between "+min_width+"mm (min) and "+max_width+"mm (max) ");
			return false;
		}
		if((min_drop>drop)||(max_drop<drop)||(isNaN(drop)))
		{
			alert("Please enter drop between "+min_drop+"mm (min) and "+max_drop+"mm (max)");
			return false;
		}
	}
	if (cat=="pleated")
	{
		if((200>width)||(1750<width)||(isNaN(width)))
		{
			alert("Please enter width between 200mm (min) and 1750mm (max) ");
			return false;
		}
		if((200>drop)||(3000<drop)||(isNaN(drop)))
		{
			alert("Please enter drop between 200mm (min) and 3000mm (max)");
			return false;
		}
	}
	if (cat=="roman")
	{
		if((slat=="8") || (slat=="15"))
		{
			min_width=300;
			max_width=2437;
			min_drop=300;
			max_drop=2743;
		}
		if((slat=="7") || (slat=="1") || (slat=="13") || (slat=="3"))
		{
			min_width=300;
			max_width=2437;
			min_drop=300;
			max_drop=2437;
		}
		if((slat=="9") || (slat=="2"))
		{
			min_width=300;
			max_width=2082;
			min_drop=300;
			max_drop=2082;
		}
		if((min_width>width)||(max_width<width)||(isNaN(width)))
		{
			alert("Please enter width between "+min_width+"mm (min) and "+max_width+"mm (max) ");
			return false;
		}
		if((min_drop>drop)||(max_drop<drop)||(isNaN(drop)))
		{
			alert("Please enter drop between "+min_drop+"mm (min) and "+max_drop+"mm (max)");
			return false;
		}
	}
	if (cat=="roller")
	{
		if(slat=="0")
		{
			min_width=300;
			max_width=3000;
			min_drop=300;
			max_drop=3000;
		}
		if((slat=="12") || (slat=="2") || (slat=="1") || (slat=="14") || (slat=="9") || (slat=="7") || (slat=="3") || (slat=="8") || (slat=="5") || (slat=="16") || (slat=="6") || (slat=="10"))
		{
			min_width=300;
			max_width=3000;
			min_drop=0;
			max_drop=3000;
		}
		if((min_width>width)||(max_width<width)||(isNaN(width)))
		{
			alert("Please enter width between "+min_width+"mm (min) and "+max_width+"mm (max) ");
			return false;
		}
		if((min_drop>drop)||(max_drop<drop)||(isNaN(drop)))
		{
			alert("Please enter drop between "+min_drop+"mm (min) and "+max_drop+"mm (max)");
			return false;
		}
	}
	if (cat=="vertical")
	{
		min_width=205;
		max_width=5030;
		min_drop=300;
		max_drop=3600;
		if (slat=="8")
		{
			min_width=610;
			max_width=3046;
			min_drop=300;
			max_drop=3046;
		}
		if (slat=="17")
		{
			min_width=300;
			max_width=2743;
			min_drop=300;
			max_drop=2749;
		}
		if (slat=="18")
		{
			min_width=300;
			max_width=3046;
			min_drop=300;
			max_drop=3046;
		}
		if ((slat=="1") || (slat=="14") || (slat=="7") || (slat=="6") || (slat=="10") || (slat=="9"))
		{
			min_width=458;
			max_width=5030;
			min_drop=300;
			max_drop=3600;
		}
		if (slat=="2")
		{
			min_width=300;
			max_width=5030;
			min_drop=300;
			max_drop=3600;
		}
		if((min_width>width)||(max_width<width)||(isNaN(width)))
		{
			alert("Please enter width between "+min_width+"mm (min) and "+max_width+"mm (max) ");
			return false;
		}
		if((min_drop>drop)||(max_drop<drop)||(isNaN(drop)))
		{
			alert("Please enter drop between "+min_drop+"mm (min) and "+max_drop+"mm (max)");
			return false;
		}
	}
	if (cat=="venetian")
	{
		//min_width=300;
		//max_width=2850;
		//min_drop=300;
		//max_drop=2400;

		min_width=250; // arena
		max_width=4000; // arena
		min_drop=200; // arena
		max_drop=4000; // arena

		if((slat=="1") || (slat=="9") || (slat=="4") || (slat=="2"))
		{
			max_width=3000;
		}
		if((min_width>width)||(max_width<width)||(isNaN(width)))
		{
			alert("Please enter width between "+min_width+"mm (min) and "+max_width+"mm (max) ");
			return false;
		}
		if((min_drop>drop)||(max_drop<drop)||(isNaN(drop)))
		{
			alert("Please enter drop between "+min_drop+"mm (min) and "+max_drop+"mm (max)");
			return false;
		}
	}
	if (cat=="wood")
	{
		min_width=300;
		max_width=2400;
		min_drop=300;
		max_drop=3000;
		if(slat == "50")
			max_drop = 3500;
		
		if((min_width>width)||(max_width<width)||(isNaN(width)))
		{
			alert("Please enter width between "+min_width+"mm (min) and "+max_width+"mm (max) ");
			return false;
		}
		if((min_drop>drop)||(max_drop<drop)||(isNaN(drop)))
		{
			alert("Please enter drop between "+min_drop+"mm (min) and "+max_drop+"mm (max)");
			return false;
		}
	}
	
	if (cat=="cellular")
	{
		min_width=250;
		max_width=1800;
		min_drop=300;
		max_drop=2100;
		
		if((min_width>width)||(max_width<width)||(isNaN(width)))
		{
			alert("Please enter width between "+min_width+"mm (min) and "+max_width+"mm (max) ");
			return false;
		}
		if((min_drop>drop)||(max_drop<drop)||(isNaN(drop)))
		{
			alert("Please enter drop between "+min_drop+"mm (min) and "+max_drop+"mm (max)");
			return false;
		}
	}
	if (cat=="privacy")
	{
		min_width = 400;
		max_width = 2400;
		min_drop  = 400;
		max_drop  = 2400;
		
		if((min_width>width)||(max_width<width)||(isNaN(width)))
		{
			alert("Please enter width between "+min_width+"mm (min) and "+max_width+"mm (max) ");
			return false;
		}
		if((min_drop>drop)||(max_drop<drop)||(isNaN(drop)))
		{
			alert("Please enter drop between "+min_drop+"mm (min) and "+max_drop+"mm (max)");
			return false;
		}
	}

	if (cat == "curtains"){
		min_width = 400;
		max_width = 4000;
		min_drop = 600;
		max_drop = 2743;
		if((min_width > width) || (max_width < width) || (isNaN(width))){
			alert("Please enter width between "+min_width+"mm (min) and "+max_width+"mm (max) ");
			return false;
		}
		if((min_drop > drop)||(max_drop < drop)||(isNaN(drop))){
			alert("Please enter drop between "+min_drop+"mm (min) and "+max_drop+"mm (max)");
			return false;
		}
	}

	if (cat=="child_safe")
	{
		min_width = 340;
		max_width = 2000;
		min_drop  = 200;
		max_drop  = 3000;
		
		if((min_width>width)||(max_width<width)||(isNaN(width)))
		{
			alert("Please enter width between "+min_width+"mm (min) and "+max_width+"mm (max) ");
			return false;
		}
		if((min_drop>drop)||(max_drop<drop)||(isNaN(drop)))
		{
			alert("Please enter drop between "+min_drop+"mm (min) and "+max_drop+"mm (max)");
			return false;
		}
	}


}

function hideElement(element)
{
	/*if($(element).style.display == '' || $(element).style.display == 'block')
	{*/
				$(element).style.display = 'none';
				$(element).disabled=true;
	//}
}

function showElement(element)
{
	
	$(element).disabled=false;
	$(element).style.display = 'block';
		
}

function populateSelect(idselect,array, putValue){
	var sel = $(idselect);
	for(i = sel.options.length; i >= 0; i --){
			sel.options[i] = null;
	}
	
	if(putValue == 0){
		for(i = 0; i < array.length; i ++){
				sel.options[i] = new Option(array[i], array[i]);
		}
	}
	else{
		for(i = 0; i < array.length; i ++){
				sel.options[i] = new Option(array[i], i + 1);
		}
	}
}
  function get_params()
  {
    if (!window.location.search) return new Object();
    return window.location.search.toQueryParams();
  }
