var search_timer = false;
//var images = new Array('full_kit.jpg', 'buckle_detail.jpg', 'hinge_detail.jpg', 'label_angle.jpg', 'single_kit_inside.jpg', 'tube_detail.jpg');

window.onload = function () {
	var ranImg = new Array("icons/ajax-loader.gif", "icons/ajax-loader2.gif");
	var dummyRanArr1 = new Array();
	//var dummyRanArr2 = new Array();
	
	for (var i=0; i < ranImg.length; i++) {
		dummyRanArr1[i] = new Image();
		dummyRanArr1[i].src = "/assets/images/" + ranImg[i];
	}

/*	for (var i = 0; i < images.length; i++) {
		dummyRanArr2[i] = new Image();
		dummyRanArr2[i].src = '/assets/images/home/' + images[i];
	}*/
}

function view_report(url) {
	var new_window = window.open(url,'name','height=800,width=770,resizable=0,scrollbars=1,toolbar=0,status=0');
	if (window.focus) { new_window.focus(); }
}

function check_active(hidden_q, dep_q, answers) {
	if (hidden_q == dep_q) {
		jQuery(".q_" + hidden_q).show();
	} else {
		jQuery(".q_" + hidden_q).hide();
		var ans_array = answers.split(',');
		for (var i = 0; i < ans_array.length - 1; i++) {
			jQuery("#ans_" + ans_array[i]).attr('checked', false);
		}
	}
}

var ajax_images = 0;
jQuery(document).ready(function() {
	jQuery("a.cbFeedback").colorbox({onComplete: function(){
    	submitFeedback();
	}});

	// Swap images
	jQuery("img.alternate").hover(
		function () {
			var swap = swapImg(jQuery(this).attr("src"));
			if (swap[1] == 0) {	jQuery(this).attr("src",swap[0]); }
		},
		function(){
			var swap = swapImg(jQuery(this).attr("src"));
			if (swap[1] == 1) {	jQuery(this).attr("src",swap[0]); }
		}
	);
	
	// Control the individual search items from AJAX
	jQuery('input.quick_select').keyup( function() {
		var subjectObj = jQuery(this);
		var inputContent = jQuery.trim(subjectObj.val());
		// Set the search type. (From ID - Each id is, e.g. parameter_select)
		var type = subjectObj.attr('id');
		search_type = type.substring(0, type.length - 6);
		// Set the target divs for content
		var targetDropdown = subjectObj.parent().parent().children('div.auto-suggest');
		var targetSelected = subjectObj.parent().parent().children('div.selected');
		var sendString = 'search_term=' + inputContent;		
		// If there is currently a search timer running, stop it
		if (search_timer) { clearTimeout(search_timer); }
		jQuery.ajax({
			type: "POST",
			url: "/ajax_processes/" + search_type + "_search",
			data: sendString,
			success: function(html) {
				if (html == 'remove') {
					targetDropdown.hide();
				} else {
					if (targetDropdown.is(':hidden')) targetDropdown.fadeIn(); // If hidden unhide
					targetDropdown.html(html); // Set the content to output from AJAX
					if (targetDropdown.text() != 'No Suggestions') { targetDropdown.highlight(inputContent) } // Highlight words searched
					targetDropdown.find('a').click( function(e) {
						e.preventDefault();
						if (jQuery(this).text() != 'No Suggestions') { // If item is clicked then add to selected div (if not 'no suggestions')
							if (targetSelected.is(':hidden')) targetSelected.fadeIn();
							if (targetSelected.children('ul').is(':hidden')) { targetSelected.children('ul').fadeIn(); }
							targetSelected.children('ul').children('li').each( function() { jQuery(this).removeClass('end'); } );
							targetSelected.children('ul').append('<li class="end"><a href="" class="' + jQuery(this).attr('class') + '" title="Remove Search Item" onclick="remove_selected(this); return false;">' + jQuery(this).text() + '</a><a href="" class="' + jQuery(this).attr('class') + ' fltRight" title="Remove Search Item" onclick="remove_selected(this); return false;">X</a></li>');
							search_delay();
						}
						// Reset input, blur and fade dropdown out
						subjectObj.val('');
						subjectObj.blur();
						targetDropdown.fadeOut();
					});
				}
			}
		});
	});
	
	jQuery('input.quick_select').blur( function() {
		var id = jQuery(this).attr('id');
		if (id == 'category_quick') {
			jQuery('#parameter_quick').show();
			jQuery('#param_input_default').hide();
			jQuery('#brand_quick').show();
			jQuery('#brand_input_default').hide();
		} else if (id == 'parameter_quick') {
			jQuery('#brand_quick').show();
			jQuery('#brand_input_default').hide();
			jQuery('#sup_code_quick').show();
			jQuery('#sup_code_input_default').hide();
		} else if (id == 'brand_quick') {
			jQuery('#sup_code_quick').show();
			jQuery('#sup_code_input_default').hide();
		}
		// Set the target divs for content
		var targetDropdown = jQuery(this).parent().parent().children('div.auto-suggest');
		jQuery(this).val('');
		this.blur();
		targetDropdown.fadeOut();
	});
	
	jQuery('input.quick_select').focus( function() {
		var id = jQuery(this).attr('id');
		if (id == 'category_quick') {
			jQuery('#parameter_quick').hide();
			jQuery('#param_input_default').show();
			jQuery('#brand_quick').hide();
			jQuery('#brand_input_default').show();
		} else if (id == 'parameter_quick') {
			jQuery('#brand_quick').hide();
			jQuery('#brand_input_default').show();
			jQuery('#sup_code_quick').hide();
			jQuery('#sup_code_input_default').show();
		} else if (id == 'brand_quick') {
			jQuery('#sup_code_quick').hide();
			jQuery('#sup_code_input_default').show();
		}
	});
	
	// Control input boxes
	jQuery('input.jquery_ctrl').each( function() {
		var cur_text = jQuery(this).val();		
		jQuery(this).focus(function() {
			jQuery(this).addClass('inp_selected');
			if (jQuery(this).val() == cur_text) {
				jQuery(this).val('');
			}
			
		});
		jQuery(this).blur(function() {
			jQuery(this).removeClass('inp_selected');
			if (jQuery(this).val() == '') {
				jQuery(this).val(cur_text);
				jQuery(this).removeClass('inp_user');
			} else {
				jQuery(this).addClass('inp_user');
			}
		});
	});
	
	// Control the menu items
	jQuery('div.headerMenu-ContDiv').hover(
		function () {
			jQuery(this).children('div').show();
		},
		function(){
			jQuery(this).children('div').hide();
		}
	);	
	// Control the submenu items
	jQuery('div.headerMenu-subMenuDiv').hover(
		function () {
			jQuery(this).parent().children('a').addClass('menu_on');
		},
		function(){
			jQuery(this).parent().children('a').removeClass('menu_on');
		}
	);	
	
	// Start the rating system for the products (only relevant on product detail page)
	//enable_rating();
	// Control the changing of pages for the product detail tabs
	jQuery('div.tabs.p-detail ul li a').click(function(e) {
		e.preventDefault();
		var cur_item = jQuery(this).attr('href'); // Link to the page
		var page = jQuery(this).attr('class');
		var cur_obj = jQuery(this);
		var data = 'ajax_switch=yes&tab_page=' + page + '&cur_item=' + cur_item;
		jQuery.ajax({
			type: "POST",
			url: "/products/details/" + cur_item,
			data: data,
			success: function(html) {
				jQuery('.tab_item').hide();
				jQuery('#' + page).show();
				jQuery('#' + page).html(html);
				jQuery(cur_obj).parent().parent().children().each(function() {
					jQuery(this).attr('id', '');
				});
				jQuery(cur_obj).parent().attr('id', 'current');
				if (page == 'images') {
					jQuery('#product_images a').lightBox({
						fixedNavigation: true,
						imageLoading: '/assets/scripts/lightbox/images/lightbox-ico-loading.gif',
						imageBtnClose: '/assets/scripts/lightbox/images/lightbox-btn-close.gif',
						imageBtnPrev: '/assets/scripts/lightbox/images/lightbox-btn-prev.gif',
						imageBtnNext: '/assets/scripts/lightbox/images/lightbox-btn-next.gif'
				   });
				} else if (page == 'description') {
					enable_rating();
				}
				
			}
		});
	});
	
	// Control the changing of tabs for the main product search tabs
	jQuery('div.tabs.p-search ul li a').click(function(e) {
		e.preventDefault();
		var cur_item = jQuery(this).attr('href');
		var search_cat = jQuery(this).attr('class');
		jQuery('div.body.p-search .tab_item').hide();
		jQuery('#' + search_cat).show();
		jQuery(this).parent().parent().children().each(function() {
			jQuery(this).attr('id', '');
		});
		jQuery(this).parent().attr('id', 'current');
	});
	
	// Control the changing of pages for the reference detail tabs
	jQuery('div.reference-detail ul li a').click(function(e) {
		e.preventDefault();
		var cur_item = jQuery(this).attr('href'); // url-key, e.g. aluminium-fact-sheet
		var page = jQuery(this).attr('class'); // description/related_parameters/related_products
		var cur_obj = jQuery(this);
		var data = 'ajax_switch=yes&tab_page=' + page + '&cur_item=' + cur_item;
		jQuery.ajax({
			type: "POST",
			url: "/references/details/" + cur_item,
			data: data,
			success: function(html) {
				jQuery('div.reference-detail .tab_item').hide();
				jQuery('#' + page).show();
				jQuery('#' + page).html(html);
				cur_obj.parent().parent().children().each(function() {
					jQuery(this).attr('id', '');
				});
				cur_obj.parent().attr('id', 'current');				
			}
		});
	});
	
	// Control the changing of pages for the parameter detail tabs
	jQuery('div.tabs.param-detail ul li a').click(function(e) {
		e.preventDefault();
		var cur_item = jQuery(this).attr('href'); // Link to the page
		var page = jQuery(this).attr('class');
		var cur_obj = jQuery(this);
		var data = 'ajax_switch=yes&tab_page=' + page + '&cur_item=' + cur_item;
		jQuery.ajax({
			type: "POST",
			url: "/parameters/details/" + cur_item,
			data: data,
			success: function(html) {
				jQuery('.tab_item').hide();
				jQuery('#' + page).show();
				jQuery('#' + page).html(html);
				jQuery(cur_obj).parent().parent().children().each(function() {
					jQuery(this).attr('id', '');
				});
				jQuery(cur_obj).parent().attr('id', 'current');				
			}
		});
	});
	
	// Control the changing of pages for the news detail tabs
	jQuery('div.tabs.n-detail ul li a').click(function(e) {
		e.preventDefault();
		var cur_item = jQuery(this).attr('href'); // Link to the page
		var page = jQuery(this).attr('class');
		var cur_obj = jQuery(this);
		var data = 'ajax_switch=yes&tab_page=' + page + '&cur_item=' + cur_item;
		jQuery.ajax({
			type: "POST",
			url: "/news/articles/" + cur_item,
			data: data,
			error: function(objXml) {
				//alert(objXml);
			},			
			success: function(html) {
				//alert(html);
				jQuery('.tab_item').hide();
				jQuery('#' + page).show();
				jQuery('#' + page).html(html);
				jQuery(cur_obj).parent().parent().children().each(function() {
					jQuery(this).attr('id', '');
				});
				jQuery(cur_obj).parent().attr('id', 'current');	
			}
		});
	});
	
	// Add search items to the search box
	jQuery('.search_item_link').click(function(e) {
		e.preventDefault();
		jQuery(this).css('color', '#090');
		var search_items_status = jQuery('div.body.p-results div.search_status');
		var search_items_btn = jQuery('div.body.p-results div.search_button');
		var search_items_form = jQuery('div.body.p-results div.search_form');
		var search_items_cat = jQuery('div.body.p-results div.s-input-type.category');
		var search_items_param = jQuery('div.body.p-results div.s-input-type.parameter');
		var search_items_brand = jQuery('div.body.p-results div.s-input-type.brand');
		// Set the status for the search box
		if (search_items_cat.is(':hidden') && search_items_cat.is(':hidden') && search_items_cat.is(':hidden')) {
			search_items_status.html('<h2>I\'m looking for</h2>');
			search_items_btn.show();
		}
		
		if (jQuery(this).hasClass('category') && jQuery("input[value='" + jQuery(this).attr('id') + "']").length == 0) {
			search_items_cat.show();
			search_items_cat.append('<div class="selected"><span>' + jQuery(this).attr('id') + '</span><a href="Remove" onclick="rem_select_item(this); return false;">' + jQuery(this).text() + '</a></div>');
			search_items_form.children('form').append('<input type="hidden" name="category[]" value="' + jQuery(this).attr('id') + '" />');
			
		} else if (jQuery(this).hasClass('parameter') && jQuery("input[value='" + jQuery(this).attr('id') + "']").length == 0) {
			search_items_param.show();
			search_items_param.append('<div class="selected"><span>' + jQuery(this).attr('id') + '</span><a href="Remove" onclick="rem_select_item(this); return false;">' + jQuery(this).text() + '</a></div>');
			search_items_form.children('form').append('<input type="hidden" name="parameter[]" value="' + jQuery(this).attr('id') + '" />');
			
		} else if (jQuery(this).hasClass('brand') && jQuery("input[value='" + jQuery(this).text() + "']").length == 0) {
			search_items_brand.show();
			search_items_brand.append('<div class="selected"><span>' + jQuery(this).text() + '</span><a href="Remove" onclick="rem_select_item(this); return false;">' + jQuery(this).text() + '</a></div>');
			search_items_form.children('form').append('<input type="hidden" name="brand[]" value="' + jQuery(this).text() + '" />');
		}
	});
	
	// The code which removes items before they have been searched for

	// The code which removes items once they have been searched for
	jQuery('.searchUnit').click(function(e) {
		e.preventDefault();
		var item_id = jQuery(this).siblings('div').attr("class");
		
		if (jQuery("input[value='" + item_id + "']").length == 1) {
			jQuery("input[value='" + item_id + "']").remove();
			jQuery(this).parent().parent().fadeOut('400', function() {
				setTimeout(do_form_search, '500');
			});
		}
	});
	
	if (jQuery('#uim').length) {
		var remove_error = setTimeout("jQuery('#uim').fadeOut(1000)", 10000);
	}
	
	set_click_classes();
	
	if (jQuery('#product_images').length) {
		jQuery('#product_images a').lightBox({
			fixedNavigation: true,
			imageLoading: '/assets/scripts/lightbox/images/lightbox-ico-loading.gif',
			imageBtnClose: '/assets/scripts/lightbox/images/lightbox-btn-close.gif',
			imageBtnPrev: '/assets/scripts/lightbox/images/lightbox-btn-prev.gif',
			imageBtnNext: '/assets/scripts/lightbox/images/lightbox-btn-next.gif'
	   });
	}
	
	jQuery('#home_page #images div').hover(
		function () {
			jQuery(this).find('img').fadeIn('slow');
			jQuery('#captions #' + jQuery(this).attr('class')).fadeIn();
		},
		function(){
			jQuery(this).find('img').fadeOut('slow');
			jQuery('#captions #' + jQuery(this).attr('class')).fadeOut();
		}
	);
	
});
jQuery(function(){
  jQuery('.cbox-form').colorbox({maxWidth: '75%', onComplete: function(){
    cbox_submit();
  }});
});

//submit ajax form continually if needed
function submitFeedback()
{
  jQuery("#formFeedback").submit(function(){
    jQuery.post(
      jQuery(this).attr('action'),
      jQuery(this).serialize(),
      function(data){
        jQuery().colorbox({html: data, onComplete: function(){
          submitFeedback();
        }});
      }
    );
    return false;
  });
}// cbox_submit

function remove_selected(searchLink) {
	var list = jQuery(searchLink).parent().parent();
	if (search_timer) { clearTimeout(search_timer); }
	
	jQuery(searchLink).parent().fadeOut("400", function() {
		jQuery(this).remove();
		if (list.children().length == 0) { list.hide(); }
		if (jQuery('#category_selected ul li').length > 0 || jQuery('#parameter_selected ul li').length > 0 || jQuery('#brand_selected ul li').length > 0 || jQuery('#sup_code_selected ul li').length > 0) {
			search_delay();
		} else { 
			jQuery('#quick_select div.Ajax-Search-Status').html('');
		};
		
	});
}

function rem_select_item(obj)
{
	var item_id = jQuery(obj).parent().children('span').text();
	
	if (jQuery("input[value='" + item_id + "']").length == 1) {
		jQuery("input[value='" + item_id + "']").remove();
		if (jQuery(obj).parent().parent().hasClass('brand')) {
			jQuery(".search_item_link:contains('" + item_id + "')").css('color', '#014E9E');
		} else {
			jQuery('#' + item_id).css('color', '#014E9E');
		}
		jQuery(obj).parent().fadeOut('400', function() { jQuery(obj).parent().remove(); });
	}
}

function update_letter(type, letter)
{
	if (type == 'ajax') {
		jQuery("input[name='letter']").val(letter);
		var page = jQuery("input[name='cur_page']").val();
		do_ajax_search('reload');
	} else if (type == 'reload') {
		jQuery("input[name='letter']").val(letter);
		jQuery("input[name='cur_page']").val(0);
		do_form_search();
	}
}

function update_page(type, page)
{
	if (type == 'ajax') {
		jQuery("input[name='cur_page']").val(page);
		var letter = jQuery("input[name='letter']").val();
		do_ajax_search('reload');
	} else if (type == 'reload') {
		jQuery("input[name='cur_page']").val(page);
		do_form_search();
	}
}

function update_pagecount(type)
{
	if (type == 'ajax') {
		do_ajax_search('reload');
	} else if (type == 'form') {
		do_form_search();
	}
}

function update_sortby(type)
{
	if (type == 'ajax') {
		do_ajax_search('reload');
	} else if (type == 'form') {
		do_form_search();
	}
}

function update_sortorder(type)
{
	if (type == 'ajax') {
		do_ajax_search('reload');
	} else if (type == 'form') {
		do_form_search();
	}
}

function update_section(type)
{
	if (type == 'ajax') {
		do_ajax_search('reload');
	} else if (type == 'form') {
		do_form_search();
	}
}
function search_delay()
{
	if (search_timer) {
		clearTimeout(search_timer);
	}
	search_timer = setTimeout(do_ajax_search, 3000);
	jQuery('div.Ajax-Search-Status').fadeIn();
	jQuery('div.Ajax-Search-Status').html('Waiting for more search terms...');
}

function do_form_search()
{
	document.refresh_search_form.submit();
}

function do_ajax_search(type)
{
	jQuery('div.Ajax-Search-Status').html('<img src="/assets/images/icons/ajax-loader2.gif" width="32px" height="32px"/><span>Finding Results</span>');
	
	var categories = '';
	jQuery('#category_selected').find('ul li').each(function() {
		categories = categories + ', ' + jQuery(this).children('a').attr('class')
	});
	var parameters = '';
	jQuery('#parameter_selected').find('ul li').each(function() {
		parameters = parameters + ', ' + jQuery(this).children('a').attr('class')
	});
	var brands = '';
	jQuery('#brand_selected').find('ul li').each(function() {
		brands = brands + ', ' + jQuery(this).children('a').html();
	});	
	var sup_code = '';
	jQuery('#sup_code_selected').find('ul li').each(function() {
		sup_code = sup_code + ', ' + jQuery(this).children('a').html();
	});	
	
	if (type == 'reload') {
		var cat = categories;//jQuery("input[name='category']").val();
		var param = parameters;//jQuery("input[name='parameter']").val();
		var brand = brands;//jQuery("input[name='brand']").val();
		var letter = jQuery("input[name='letter']").val();
		var page = jQuery("input[name='cur_page']").val();
		var per_page = jQuery("select[name='per_page']").val();
		var sort_by = jQuery("select[name='sort_by']").val();
		var order_by = jQuery("select[name='order_by']").val();
		var section = jQuery("select[name='section_type']").val();
		var data = 'category=' + cat + '&parameter=' + param + '&brand=' + brand + '&sup_code=' + sup_code + '&letter=' + letter + '&cur_page=' + page + '&per_page=' + per_page + '&sort_by=' + sort_by + '&order_by=' + order_by +'&section_type=' + section;
		//alert(data);
	} else {
		var cat = categories;//jQuery('#category_quick').val();
		var param = parameters;//jQuery('#parameter_quick').val();
		var brand = brands;//jQuery('#brand_quick').val();
		var data = 'category=' + cat + '&parameter=' + param + '&brand=' + brand + '&sup_code=' + sup_code;
	}
	jQuery.ajax({
		type: "POST",
		url: "/products/search/ajax",
		data: data,
		timeout: 15000,
		success: function(html) {
			jQuery('div.Ajax-Search-Status').fadeOut();
			if (html == '') {
				jQuery('#sC-Right-Body #sC-Right-Ajax-Results').hide();
				jQuery('#sC-Right-Body #sC-Right-Page-Body').show();
			} else {
				jQuery('#sC-Right-Body #sC-Right-Page-Body').hide();
				jQuery('#sC-Right-Body #sC-Right-Ajax-Results').show();
				jQuery('#sC-Right-Body #sC-Right-Ajax-Results').html(html);
			}
			
		},
		error: function( objAJAXRequest, strError ) {
			jQuery("div.Ajax-Search-Status").html("Could Not Get Results");
		}
	});
}

function enable_rating()
{
	jQuery(".rate_star").each( function (i) {
		jQuery(this).bind("click", {index: i}, function(event) {
			var sNum = event.data.index + 1;			
			changeStarPics(sNum, "rate");
			jQuery('#rating_div #comment').html('<a href="Submit Rating" onclick="submit_rating(); return false;">Submit Rating</a>');
			jQuery("input[name=rate_rating]").val(sNum);
		});
	});	
}

function submit_rating()
{
	var rating = jQuery("input[name='rate_rating']").val();
	var p_id = jQuery('.cur_product_id').html();
	
	jQuery.ajax({
		type: "POST",
		url: "/ajax_processes/set_product_rating",
		data: "product_id=" + p_id + "&product_rating=" + rating,
		success: function(html) {
			jQuery('#rating_div #ratings').html(html);
			jQuery('#rating_div #comment').html('Thanks for rating!');
		}
	});
}

function changeStarPics(sNum, pref)
{
	for (var x = 1; x <= 10; x++) {
		if (x <= sNum) { jQuery("#" + pref + "_star" + x).attr("src", "/assets/images/icons/star2.png"); }
		else { jQuery("#" + pref + "_star" + x).attr("src", "/assets/images/icons/star0.png"); }
	}
	jQuery("#" + pref + "_rating").val(sNum);
}

// Use this function if the image is NOT on the local server.
function get_ajax_image(file_image, user_width, user_height, html_class_field, user_extra, final)
{
	jQuery.ajax({
		type: "POST",
		url: "/ajax_processes/set_new_img_size",
		data: "img_file=" + file_image + "&img_width=" + user_width + "&img_height=" + user_height,
		error: function(xml,err, errT) {
			//alert(xml.status);
		},
		success: function(html) {
			//alert('<img src="' + html + '" class="' + user_class + '" />');
			//alert(html);
			jQuery('div.p_image.img_' + html_class_field + ' img').remove()
			jQuery('div.p_image.img_' + html_class_field + ' a').html('<img src="' + file_image + '" ' + html + ' ' + user_extra + ' />');
		}
	});
	//alert('final');
	if (final == "loadLightbox") {
		if (jQuery('#newsDetailImages').length) {
			jQuery('#newsDetailImages a').lightBox({
				fixedNavigation: true,
				imageLoading: '/assets/scripts/lightbox/images/lightbox-ico-loading.gif',
				imageBtnClose: '/assets/scripts/lightbox/images/lightbox-btn-close.gif',
				imageBtnPrev: '/assets/scripts/lightbox/images/lightbox-btn-prev.gif',
				imageBtnNext: '/assets/scripts/lightbox/images/lightbox-btn-next.gif'
		   });
		}
	}
}

function set_click_classes()
{
	jQuery('.clickable_box').each( function() {
		jQuery(this).hover(
			function() {
				jQuery(this).removeClass('div_std');
				jQuery(this).addClass('div_std_hl');
			},
			function() {
				jQuery(this).removeClass('div_std_hl');
				jQuery(this).addClass('div_std');
			}
		)
		jQuery(this).click( function() {
			
		});
	});
}

function swapImg(src,newImg) {
	var pathArr = src.split("/"); 
    var imgInd = pathArr.length - 1;
	var newSrc = "";
	for (var i = 0; i < pathArr.length - 1; i++) { newSrc += pathArr[i] + "/"; }
    var nameArr = pathArr[imgInd].split("."); 
    var fileName = nameArr[0];
    var fileState = fileName.substr(fileName.length - 1);
	newSrc += fileName.substr(0,fileName.length - 1);
	if (!newImg) { newSrc += fileState=="0"?"1.":"0.";
	} else { newSrc += newImg + "."; }
	newSrc += nameArr[1];
	return [newSrc,fileState];
}

function change_url(url)
{
	window.location = '/' + url;	
}
