NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
NS6 = (document.getElementById) ? 1 : 0;


// Browser detection
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = (userAgent.indexOf('opera') != -1);
var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf('msie 4.') != -1));
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_mac    = (userAgent.indexOf('mac') != -1);

var hidden_selects = new Array();



function zoomimage(thelink) {
	
	$('zoomimage_image').src = thelink.href;
	
	var thetop = getObjectPosTop($('mainimage'));
	var theleft = getObjectPosLeft($('mainimage'));
	jQuery('#zoomimage_container').css('left', theleft+'px');
	jQuery('#zoomimage_container').css('top', thetop+'px');
	jQuery('#zoomimage_container').show();
	
}

function close_zoomimage() {
	jQuery('#zoomimage_container').hide();
}


/* get cookie */
function fetch_cookie(name) {
	return jQuery.cookie(name);
}


/* function to set a cookie */
function set_cookie(name, value, expires) {
	jQuery.cookie(name, value, { path: '/' });
}

function numeric_input(el) { 
  var val = el.value.replace(/[^\d]/g, '');
  
  if (val.length > 5) val = val.substring(0,5);
  
  el.value = val; 
}  

var pdetail_info = '';
function show_pdetail_info(thecol) {
	
	pdetail_info = thecol;
	
	var td_image = $('image_' + pdetail_info);
	
	$('detail_icon_' + pdetail_info).style.display = '';

	$('detail_icon_' + pdetail_info).style.left = (getObjectPosLeft(td_image) + 60 - 9) + 'px';
	$('detail_icon_' + pdetail_info).style.top = (getObjectPosTop(td_image) + 45 - 9) + 'px';

	//alert(getObjectPosLeft(td_image));
	//alert(getObjectPosTop(td_image));
	
}

function hide_pdetail_info() {
	
	$('detail_icon_' + pdetail_info).style.display = 'none';
	
	pdetail_info = '';
	
}


var curptimer;
var curpouttimer;
var curpcol;
var curpdiv;
var curptable;
var curpover = false;
var prevpcol = '';
var curpid;
var rewrite;
var curp_left;
var curp_top;

function debug_js(thetext) {
	
	return false;
	
	$('debug_js').innerHTML = thetext;
	
}

var pimage_loaded;

function replacepdetailimage(pid, pimage) {
	
	if (pimage_loaded == false) return false;
	
	pimage_loaded = false;
	
	var preimage = new Image();
	preimage.src = pimage;

	$('detail_theimage_' + curpcol).src = pimage;
	
	pimage_loaded = true;
}

function start_pdetail_timer(theobj, thepid, thecol, startnow, do_rewrite) {
	
	pimage_loaded = false;
	
	//debug_js('Start: ' + thecol);
	
	if (do_rewrite == 1) {
		rewrite = 1;
		curpcol = '';
	}
	else {
		rewrite = 0;
	}
	
	if (curpcol == thecol) {
		clearTimeout(curpouttimer);
		return false;
	}
	else {
		clearTimeout(curptimer);
		clearTimeout(curpouttimer);
		if (rewrite == 0) {
			hide_pdetail();
			curpover = false;
		}
	}
	
	if (curptimer) clearTimeout(curptimer);
	
	curpcol = thecol;
	curpid = thepid;
	
	$('detail_icon_' + curpcol).style.display = 'none';
	$('detail_wait_icon_' + curpcol).style.display = '';

	var td_image = $('image_' + curpcol);
	$('detail_wait_icon_' + curpcol).style.left = (getObjectPosLeft(td_image) + 60 - 9) + 'px';
	$('detail_wait_icon_' + curpcol).style.top = (getObjectPosTop(td_image) + 45 - 9) + 'px';
	
	if (startnow == 1) show_pdetail();
	else {
		curptimer = window.setTimeout('show_pdetail()',1500);
	}

}

function show_pdetail() {
	
	debug_js('Anzeige: ' + curpcol);
	
	if (prevpcol != '') {
		if ($('detail_' + prevpcol)) {
			$('detail_' + prevpcol).style.display = 'none';
			curpover = false;
		}
	}
	
	curpdiv = $('detail_' + curpcol);
	curptable = $('table_' + curpcol);
	
	if (1 == 1) {
		
		var leftpos = getObjectPosLeft(curptable);
		var toppos = getObjectPosTop(curptable);
		var boxwidth = curptable.offsetWidth;
		
		var pagewidth = screen.availWidth;
		var pageheight = screen.availHeight;
		var obwidth = 314;
		
		var middle = (leftpos + (boxwidth / 2));
		
		leftpos = (middle - (obwidth / 2));
		
		toppos = (toppos - 100);
		
		var rightpos = leftpos + obwidth;
	
		if (rightpos > pagewidth) {
			leftpos = pagewidth - obwidth - 30;
		}

		if (leftpos <= 0) {
			leftpos = 5;
		}
		
		curp_left = leftpos;
		curp_top = toppos;
		curpdiv.style.left = leftpos + 'px';
		curpdiv.style.top = toppos + 'px';
		
	}
	
	set_curpover_active();
	
	prevpcol = curpcol;

	curpdiv.style.display = 'none';

	params = 'action=getProductAddData&products_id='+curpid + '&col_rand=' + curpcol;
	
	new Ajax.Request('ajax_products.php' , {method:"get", parameters:params, onComplete: show_pdetail_sizes});

	
	/*
	cursizediv = $('detail_sizes_' + curpcol);
	if (cursizediv.innerHTML == '') {
		
	}
	*/

}

function show_pdetail_sizes(originalRequest) {
	
	$('detail_' + curpcol).innerHTML = originalRequest.responseText;

	//var moreimages = $('moreimages_cnt_' + curpcol).value;
	
	pimage_loaded = true;
	
	curimgdiv = $('detail_image_' + curpcol);

	if (curimgdiv.innerHTML == '') {
		var tmpimg = $('detail_image_path_' + curpcol).value;

		var preimage = new Image();
		preimage.src = tmpimg;
		preimage.id = 'detail_theimage_' + curpcol;
		preimage.style.border = 0;
		
		curimgdiv.appendChild(preimage);
		
	}
	
	/*
	if (moreimages > 0) {
		for(var i = 0; i < moreimages; i++) {
			var preimage = new Image(250);
			preimage.src = $('moreimages_'+i+'_' + curpcol).value;
		}
	}
	*/
	
	curpdiv = $('detail_' + curpcol);
	
	curpdiv.style.display = '';
	
	rewrite = 0;
}

function stop_pdetail_timer() {
	
	debug_js('Stop: ' + curpcol);
	
	clearTimeout(curptimer);
	curpouttimer = window.setTimeout('hide_pdetail()',300);
}

function hide_pdetail() {
	
	if (rewrite == 1) return true;
	
	debug_js('Hide: ' + curpcol);
	
	if (curpdiv) {
		curpdiv.style.display = 'none';
	}
	
	clearTimeout(curptimer);
	clearTimeout(curpouttimer);

	if (curpcol && curpcol != '' && curpcol != 'undefined') {
		$('detail_wait_icon_' + curpcol).style.display = 'none';
	}
		
	curpover = false;
	curpcol = '';
	curpdiv = '';
		
	debug_js('Hidden: ' + curpcol);
		
}

function set_curpover_active() {
	curpover = true;
	clearTimeout(curpouttimer);
}

function set_curpover_inactive() {
	curpover = false;
	stop_pdetail_timer();
}


var cur_open_faq = 0;
function open_faq(faq_id)	{
	
	if (faq_id == cur_open_faq) {
		$('faq_' + faq_id).style.display = 'none';      
		cur_open_faq = 0;
		return false;
	}
	
	if (cur_open_faq > 0) $('faq_' + cur_open_faq).style.display = 'none';
	$('faq_' + faq_id).style.display = '';
	cur_open_faq = faq_id;
	
	return false;
	
}

var product_info_selected_tab = '';
function product_info_select_tab(tab) {
	
	if (product_info_selected_tab != '') {
		
		$('product_info_tab_' + product_info_selected_tab).className = 'product_info_tab_td product_info_tab';
		$('product_info_tab_' + tab).className = 'product_info_tab_td product_info_tab product_info_tab_active';

		$('product_info_tab_content_' + product_info_selected_tab).style.display = 'none';
		$('product_info_tab_content_' + tab).style.display = '';
		
		product_info_selected_tab = tab;
	}
	
	return true;
}


// Bilder anzeigen mit "Zoom"-Funktion
var zoom_count = 50;
var zoom_count_height = 0;
var zoom_count_width = 0;

function zoom_image_open(width,height,img_id) {

 if (zoom_count_height == 0) {
 	ajax_show_more_colors_stop();
 	var link_obj = $('link_' + img_id);
 	var img_obj = $('upper_div_' + img_id);

	var preimages = new Image();
	preimages.src = link_obj.innerHTML;

 	$(img_id).src = link_obj.innerHTML;
 	
 	$('div_' + img_id).style.left = (getObjectPosLeft(img_obj) - 220)+'px';
 	$('div_' + img_id).style.top = (getObjectPosTop(img_obj) - 100)+'px';
}
 
 var zoom_steps = (width / 10);
 var zoom_add_width = 10;
 var zoom_add_height = (height / zoom_steps);
 
 if (zoom_count_width < width && zoom_count_height < height) {
  document.getElementById(img_id).style.display="inline";
  
  if (zoom_count_width < width) {
  	document.getElementById(img_id).style.width=zoom_count_width+"px";
  }
  if (zoom_count_height < height) {
  	document.getElementById(img_id).style.height=zoom_count_height+"px";
  }
  zoom_count += 10; 
  
  zoom_count_width += zoom_add_width;
  if (zoom_count_width > width) zoom_count_width = width;

  zoom_count_height += zoom_add_height;
  if (zoom_count_height > height) zoom_count_height = height;

  window.setTimeout("zoom_image_open("+width+","+height+",'"+img_id+"')",0);
 }
 else {

 }
}

function zoom_image_close(img_id) {
 document.getElementById(img_id).style.display="none";
 zoom_count = 50;
 zoom_count_height = 0;
 zoom_count_width = 0;
}



function changebackground(elementid, color) {
	
	$(elementid).style.background = color;
}

function changeborder(elementid, width, color) {
	
	$(elementid).style.border = width+'px';
	$(elementid).style.borderColor = color;
	$(elementid).style.borderStyle = 'solid';
}

function changefont(elementid, newcolor, decoration){
	if (newcolor) $(elementid).style.color = newcolor;
	if (decoration) $(elementid).style.textDecoration = decoration;
}

function change_search_operator(language_id, img_path) {
	
	var new_value = '';
	var new_title = '';
	if ($('force_advanced_search_default_operator_value').value == 'and') {
		new_value = 'or';
		new_title = JS_TEXT_SEARCH_OPERATOR_OR;
	}
	else {
		new_value = 'and';
		new_title = JS_TEXT_SEARCH_OPERATOR_AND;
	}
	
	$('force_advanced_search_default_operator_value').value = new_value;
	
	$('force_advanced_search_default_operator_image').src = img_path + 'search_operator_' + new_value + '_' + language_id + '.png';
	
	$('force_advanced_search_default_operator_image').title = new_title;
	
	
	
	return false;	
}


function change_search_operator_text() {
	
	var new_value = '';
	var new_text = '';
	var new_title = '';
	if ($('force_advanced_search_default_operator_value').value == 'and') {
		new_value = 'or';
		new_text = 'O';
		new_title = JS_TEXT_SEARCH_OPERATOR_OR;
	}
	else {
		new_value = 'and';
		new_text = 'U';
		new_title = JS_TEXT_SEARCH_OPERATOR_AND;
	}
	
	$('force_advanced_search_default_operator_value').value = new_value;
	
	$('force_advanced_search_default_operator_text').innerHTML = new_text;
	
	return false;	
}


function ajaxGetPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function ajaxGetWishlistBox() {
	
	params = 'action=getWishlistBox';
	
	//new Ajax.Request('ajax_products.php' , {method:"get", parameters:params, onComplete: ajaxGetWishlistBox_show});
	new Ajax.Updater('wishlist_left', 'ajax_products.php' , {method:"get", parameters:params});
	
}

function ajaxGetWishlistBox_show(originalRequest) {
	
	//$('wishlist_left').innerHTML = '';
	$('wishlist_left').innerHTML = originalRequest.responseText;

}

ajax_show_more_colors_active_num = 0;
function ajax_show_more_colors_change() {
	
	var products_id = ajax_show_more_colors_active_products_id;
	var iconid = ajax_show_more_colors_active;
	
	/*
	if ($('div_' + iconid).style.display == 'none') {
		clearInterval(colors_interval);
		return false;
	}
	*/

	//alert(ajax_show_more_colors_active_num);

	if (ajax_show_more_colors_active_num >= colors_array[products_id].length) {
		ajax_show_more_colors_active_num = 0;
	}
	
	//alert(colors_array[products_id].length);
	
	$('url_' + iconid).href = colors_array[products_id][ajax_show_more_colors_active_num]['product_url'];	
	$('image_' + iconid).src = colors_array[products_id][ajax_show_more_colors_active_num]['product_image'];
	
	/*
	output = '<a href="'+colors_array[products_id][ajax_show_more_colors_active_num]['product_url']+'">' + colors_array[products_id][ajax_show_more_colors_active_num]['product_image'] + '</a>';
	$('div_' + iconid).innerHTML = output;
	*/
	
	ajax_show_more_colors_active_num = ajax_show_more_colors_active_num + 1;
	
	return false;
}

ajax_show_more_colors_active = false;
ajax_show_more_colors_interval = false;
ajax_show_more_colors_active_products_id = 0;

ajax_show_more_colors_active_onmouseover = false;
ajax_show_more_colors_active_onmouseout = false;

function ajax_show_more_colors_stop() {
	
	if (ajax_show_more_colors_active) {
		
		if (ajax_show_more_colors_interval) clearInterval(colors_interval);
		ajax_show_more_colors_active = false;
		//ajax_show_more_colors_active_products_id = 0;
		
	}
	
}

function ajax_show_more_colors(products_id, iconid) {
	
	if (ajax_show_more_colors_active == iconid) {
		
		var org_prod = colors_array[ajax_show_more_colors_active_products_id].length - 1;
		if (ajax_show_more_colors_interval) clearInterval(colors_interval);
		
		$('url_' + ajax_show_more_colors_active).href = colors_array[ajax_show_more_colors_active_products_id][org_prod]['product_url'];	
		$('image_' + ajax_show_more_colors_active).src = colors_array[ajax_show_more_colors_active_products_id][org_prod]['product_image'];

		$('image_' + ajax_show_more_colors_active).onmouseover = ajax_show_more_colors_active_onmouseover;
		$('image_' + ajax_show_more_colors_active).onmouseout = ajax_show_more_colors_active_onmouseout;

		ajax_show_more_colors_active = false;
		ajax_show_more_colors_active_products_id = 0;
		
		return false;
	}
	
	if (ajax_show_more_colors_active != false && ajax_show_more_colors_active != iconid) {
		if (ajax_show_more_colors_interval) clearInterval(colors_interval);
		
		var org_prod = colors_array[ajax_show_more_colors_active_products_id].length - 1;
		
		$('url_' + ajax_show_more_colors_active).href = colors_array[ajax_show_more_colors_active_products_id][org_prod]['product_url'];	
		$('image_' + ajax_show_more_colors_active).src = colors_array[ajax_show_more_colors_active_products_id][org_prod]['product_image'];
		
		$('image_' + ajax_show_more_colors_active).onmouseover = ajax_show_more_colors_active_onmouseover;
		$('image_' + ajax_show_more_colors_active).onmouseout = ajax_show_more_colors_active_onmouseout;
		
		ajax_show_more_colors_active = false;
		ajax_show_more_colors_active_products_id = 0;
	}
	
	ajax_show_more_colors_active = iconid;
	ajax_show_more_colors_active_products_id = products_id;
	ajax_show_more_colors_active_num = 1;
	
	//alert($('image_' + ajax_show_more_colors_active).onmouseover);
	
	ajax_show_more_colors_active_onmouseover = $('image_' + ajax_show_more_colors_active).onmouseover;
	ajax_show_more_colors_active_onmouseout = $('image_' + ajax_show_more_colors_active).onmouseout;
	
	$('image_' + ajax_show_more_colors_active).onmouseover = null;
	$('image_' + ajax_show_more_colors_active).onmouseout = null;
	
	
	if (colors_array) {
		if (colors_array[products_id]) {

			if (colors_array[products_id].length > 0) {
				
				for (var ca = 0; ca < colors_array[products_id].length; ca++) {
					var preimages = new Image();
					preimages.src = colors_array[products_id][ca]['product_image'];
				}
				
				var output = '';
				
				//output += '<a href="'+colors_array[products_id][ajax_show_more_colors_active_num]['product_url']+'">' + colors_array[products_id][0]['product_image'] + '</a>';
				output += '<a href="'+colors_array[products_id][0]['product_url']+'">' + colors_array[products_id][0]['product_image'] + '</a>';

				/* AN 071023 */
				$('url_' + iconid).href = colors_array[products_id][0]['product_url'];	
				$('image_' + iconid).src = colors_array[products_id][0]['product_image'];

				//$('div_' + iconid).style.width = '300px';
				$('div_' + iconid).style.textalign = 'left';
				$('div_' + iconid).innerHTML = output;

				$('div_' + iconid).style.position = 'absolute';
				
				var o_left = getObjectPosLeft($(iconid));
				var o_top = getObjectPosTop($(iconid));
				var o_bottom = o_top + $(iconid).offsetHeight;
				o_bottom = o_bottom - 25;
				
				$('div_' + iconid).style.left = o_left - 36;
				$('div_' + iconid).style.top = o_bottom;

				//$('div_' + iconid).style.display = '';
				
				if (colors_array[products_id].length > 1) {
					colors_interval = setInterval('ajax_show_more_colors_change()', 1500);
					ajax_show_more_colors_interval = true;
				}
				else {
					
					ajax_show_more_colors_interval = false;
					
				}
				
			}
			
		}
	}
	
}


function ajax_check_wishlist_product(products_id, iconid) {
	
	if (wishlist_products) {
		
		if (wishlist_products[products_id]) {
			
			if (wishlist_products[products_id] == 1) {
				
				$(iconid).src = 'images/'+STYLE_DIR+'/wishlist_undo.png';
				$(iconid).title = JS_TEXT_DELETE_FROM_WISHLIST;
				$(iconid).style.display = '';
				return true;
				
			}
			
		}
		
	}
	
	$(iconid).src = 'images/'+STYLE_DIR+'/wishlist_do.png';
	$(iconid).title = JS_TEXT_ADD_TO_WISHLIST;
	$(iconid).style.display = '';
	return true;
	
}

var active_wishlist_product_id = '';
function ajax_set_wishlist_product(products_id, iconid) {
	
	active_wishlist_product_id = iconid;
	
	if ($(active_wishlist_product_id)) {
		// alles gut
	}
	else {
		active_wishlist_product_id = '';
	}
	
	params = 'action=setWishListProduct&products_id='+products_id;
	
	new Ajax.Request('ajax_products.php' , {method:"get", parameters:params, onComplete: ajax_set_wishlist_product_changed});
}

function ajax_set_wishlist_product_changed(originalRequest) {
	
	var splitted = originalRequest.responseText.split(':');
	
	var theimage = splitted[0];
	var thecnt = splitted[1];
	
	if (thecnt == '0') thecnt = '';
	
	if (active_wishlist_product_id != '') {
		$(active_wishlist_product_id).src = 'images/'+STYLE_DIR+'/'+theimage+'.png';
		
		if (theimage == 'wishlist_undo') {
			$(active_wishlist_product_id).title = JS_TEXT_DELETE_FROM_WISHLIST;
		}
		else {
			$(active_wishlist_product_id).title = JS_TEXT_ADD_TO_WISHLIST;
		}
		
	}
	
	$('wishlist_count').innerHTML = thecnt;
	
	if (thecnt > 0) {
		$('wishlist_header_image').src = 'images/icons/header_wishlist_active.png';
	}
	else {
		$('wishlist_header_image').src = 'images/icons/header_wishlist.png';
	}
	
	wishlist_header_image
	
	//ajaxGetWishlistBox();
	
}


var active_new_products_cat = 0;
function ajax_new_products_cats(catid, ajax_page, mandantid) {
	active_new_products_cat = catid;
	
	params = 'action=getNewProductsCats&ajax_catid='+catid+'&ajax_page='+ajax_page;
	
	if (mandantid > 0) params += '&mandantid='+mandantid;
	
	new Ajax.Request('ajax_products.php' , {method:"get", parameters:params, onComplete: ajax_new_products_cats_show});
}


function ajax_new_products_cats_show(originalRequest) {
	
	if (originalRequest.responseText != '') {

		if (active_new_products_cat > 0) {
			$('products_cats_' + active_new_products_cat).innerHTML = originalRequest.responseText;
		}
	}
}




var cart_visible = false;

function ajax_show_cart(theobj) {
	
	if (ajax_use_shopping_cart && ajax_use_shopping_cart == true) {
		
		if (!$('shopping_cart_div')) return false;
		
		var cart_top = getObjectPosTop(theobj) + theobj.offsetHeight + 15;
		var cart_left = getObjectPosLeft(theobj) - 20;
			
		$('shopping_cart_div').style.top = cart_top + 'px';
		$('shopping_cart_div').style.left = cart_left + 'px';
			
		//Effect.BlindDown('shopping_cart_div');
		
		$('shopping_cart_div').style.display = '';
	}
	
}

function ajax_hide_cart() {
	
	$('shopping_cart_div').style.display = 'none';
	cart_visible = false;
	
}


var ajax_productcolor_active = false;
var ajax_productcolor_active_id = 0;
var oleft = 0;
function ajax_productcolor(products_id, theobj) {
	
	if (!products_id > 0) return false;
	
	oleft = getObjectPosLeft(theobj);
	//var otop = getObjectPosTop(theobj);
	
	//$('products_color_selection').style.left = getObjectPosLeft(theobj);
	$('products_color_selection').style.top = getObjectPosTop(theobj) + theobj.offsetHeight;

	if (ajax_productcolor_active == true) {
		$('products_color_selection').style.display = 'none';
		//ajax_productcolor_active_id = 0;
		ajax_productcolor_active = false;
		return false;
	}
	
	if (ajax_productcolor_active_id == products_id) {
		$('products_color_selection').style.display = '';
		$('products_color_selection').style.left = oleft - $('productsColorTable').offsetWidth;
		ajax_productcolor_active = true;
		return false;
	}
	
	ajax_productcolor_active_id = products_id;
	params = 'action=getProductsColor&products_id='+products_id;
	
	new Ajax.Request('ajax_products.php' , {method:"get", parameters:params, onComplete: ajax_productcolor_show});
	
}

function ajax_productcolor_show(originalRequest) {
	
	if (originalRequest.responseText != '') {
		$('products_color_selection').innerHTML = originalRequest.responseText;
		$('products_color_selection').style.display = '';
		$('products_color_selection').style.position = 'absolute';
		$('products_color_selection').style.zIndex = 20000;
		$('products_color_selection').style.width = $('productsColorTable').offsetWidth;
		
		$('products_color_selection').style.left = oleft - $('productsColorTable').offsetWidth;
		
		ajax_productcolor_active = true;

	}
	else {
		ajax_productcolor_active = false;
		$('products_color_selection').style.display = '';
	}
	
	return false;
}

function showLoadingImage() {
	
	var theimage = 'images/loading.gif';
	
	$('personal_searchindex_content').style.display = 'none';
	
	//$('loadingImageContainer').innerHTML = '<img src="'+theimage+'" alt="" border="0" />';
	$('loadingImageContainer').style.display = '';
	$('loadingImageContainer').style.position = 'absolute';
	$('loadingImageContainer').style.zIndex = 200;
	
	//$('loadingImageContainer').style.width = 100;
	//$('loadingImageContainer').style.height = 100;
	
	$('loadingImageContainer').style.left = ((screen.availWidth / 2) - ($('loadingImageContainer').offsetWidth / 2));
	$('loadingImageContainer').style.top = ((screen.availHeight/ 2) - ($('loadingImageContainer').offsetHeight));
	
	//alert($('loadingImageContainer').innerHTML);
	
	return false;
}

function absLeft(el) {
   return (el.offsetParent)? 
   el.offsetLeft+absLeft(el.offsetParent) : el.offsetLeft;
}

function absTop(el) {
   return (el.offsetParent)? 
   el.offsetTop+absTop(el.offsetParent) : el.offsetTop;
}

// get left position of element
function getObjectPosLeft(element) {
	var left = element.offsetLeft;
	while((element = element.offsetParent) != null)	{
		left += element.offsetLeft;
	}
	return left;
}

// get top position of element
function getObjectPosTop(element) {
	var top = element.offsetTop;
	while((element = element.offsetParent) != null)	{
		top += element.offsetTop;
	}
	return top;
}

/* return next array element */
function array_pop(thisarray) {
	if (typeof thisarray != 'object' || !thisarray.length) return null;
	else {
		var arrayvalue = thisarray[thisarray.length - 1];
		thisarray.length--;
		return arrayvalue;
	}
}

/* add array element */
function array_push(thisarray, value) {
	thisarray[thisarray.length] = value;
	return thisarray.length;
}

personal_searchindex_active = false;


function personal_searchindex_option(curoption) {
	
	//WebFXTabPane.prototype.setSelectedIndex( curoption );
	
	//alert($('personal_searchindex_content').innerHTML);
	
	//alert(WebFXTabPane);
	
	//WebFXTabPane.prototype.setSelectedIndex( curoption );
	return false;
}



function personal_searchindex() {
	
	thebody = document.getElementsByTagName("body")[0];
	thebody.id = 'body';

	if (!personal_searchindex_active) personal_searchindex_active = true;
	else {
		personal_searchindex_active = false;
		$('personal_searchindex_content').style.display = 'none';
		$('mod_page_overlay').style.display = 'none';
		handle_overlaps(false);
		return false;
	}

	$('mod_page_overlay').style.background = '#000000';	
	$('mod_page_overlay').style.position = 'absolute';
	$('mod_page_overlay').style.top = 0;
	$('mod_page_overlay').style.left = 0;
	$('mod_page_overlay').style.height = $('centerpage_div').offsetHeight;

	// stretch overlay to fill page and fade in
	var arrayPageSize = ajaxGetPageSize();
	Element.setWidth('mod_page_overlay', arrayPageSize[0]);
	Element.setHeight('mod_page_overlay', arrayPageSize[1]);

	//new Effect.Appear('mod_page_overlay', {duration:0.2, from:0.0, to:0.8});
	new Effect.Appear('mod_page_overlay', { duration: overlayDuration, from: 0.0, to: 0.8 });

	$('personal_searchindex_content').style.position = 'absolute';
	$('personal_searchindex_content').style.width = '760px';
	$('personal_searchindex_content').style.display = '';

	$('personal_searchindex_content').style.left = ((screen.availWidth / 2) - ($('personal_searchindex_content').offsetWidth /2));
	$('personal_searchindex_content').style.top = '150';


	/* IE selects */
	var menuarea = new Array();
	menuarea = {
		'left' : $('personal_searchindex_content').style.left,
		'right' : $('personal_searchindex_content').style.left + $('personal_searchindex_content').offsetWidth,
		'top' : $('personal_searchindex_content').style.top,
		'bottom' : $('personal_searchindex_content').style.top + $('personal_searchindex_content').offsetHeight
	};

	handle_overlaps(true, menuarea);
	
}


function createaccount_check_customercard(countryids) {
	
	if (countryids == '') return false;
	
	var cur_countries = countryids.split(',');
	
	var cselect = document.getElementById('countryselect');
	var corder = document.getElementById('customercard_order');
	var cnews = document.getElementById('customercard_newsletter');
	
	for(var i = 0; i < cur_countries.length; i++) {
		
		if (cur_countries[i] == cselect.value) {
			corder.style.display = '';
			cnews.style.display = '';
			return false;
		}
	}

	corder.style.display = 'none';
	cnews.style.display = 'none';

	return false;
}

function imageshow(id, el, imwidth, imheight) {
	
	if (imwidth == 0 || imheight == 0) return false;
	
	var thisleft = absLeft(el) + el.offsetWidth + 160;
	var thistop = absTop(el) - 85;
	
	/*
	thistop = thistop  - (imheight / 2) + (el.offsetHeight / 2);
	*/
	
	var divel = document.getElementById(id);

	if (divel) {

		var thiswidth = divel.offsetWidth;
		
		divel.style.display = 'block';
		
		divel.style.zIndex = '10000';
		
		divel.style.left = thisleft + 'px';
		divel.style.top = thistop + 'px';		
		
	}
	return true;
}

function imagehide(id, el) {
	
	var divel = document.getElementById(id);
	if (divel) divel.style.display = 'none';
	return true;
}

var zoomLinkActive = 0;

function replacemainimage(divname, path2image, zoomImage, imgID) {
	
	zoom_link = $('zoom_link_' + imgID);
	
	if (zoom_link) {

		$('zoom_link_' + zoomLinkActive).style.display = 'none';

		zoomLinkActive = imgID;
		$('zoom_link_' + imgID).style.display = '';
	}
	
	if (currentImageDIV) {

		$(currentImageDIV).className = 'hilight';

		currentImageDIV = divname + '_image';
		
		$(currentImageDIV).className = 'hilight2';
		
	}

	var mainel = document.getElementById('baseImage');
	var mainzoomel = document.getElementById('productzoom');
	
	if (path2image) {
		mainel.src = path2image;		
	}
	else {
		//alert(divname);
		//var imgel = document.getElementById(divname + '_img');
		var imgel = document.getElementById(divname + '_big');
		
		//mainel.src = imgel.src;
		if (imgel) {
			mainel.src = imgel.innerHTML;
		}
		
		if (zoomImage && mainzoomel) {
			mainzoomel.href = zoomImage;
			//alert(mainzoomel.href);
		}
		
		else {
			var imgel = document.getElementById(divname + '_img');
			
			//mainel.src = imgel.src;
			if (imgel) {
				mainel.src = imgel.src;
			}
		}
			

	}
	
	if (zoomImage) {
		//loadMagnifier("mainimage", zoomImage, 1200, 900);
	}
	
	return true;
}




/***********************************************
* DHTML Ticker script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function domticker(content, divId, divClass, delay, fadeornot){
this.content=content
this.tickerid=divId //ID of master ticker div. Message is contained inside first child of ticker div
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is)
this.pointer=1
this.opacitystring=(typeof fadeornot!="undefined")? "width: 100%; filter:progid:DXImageTransform.Microsoft.alpha(opacity=100); -moz-opacity: 1" : ""
if (this.opacitystring!="") this.delay+=500 //add 1/2 sec to account for fade effect, if enabled
this.opacitysetting=0.2 //Opacity value when reset. Internal use.
document.write('<div id="'+divId+'" class="'+divClass+'"><div style="'+this.opacitystring+'">'+content[0]+'</div></div>')
var instanceOfTicker=this
setTimeout(function(){instanceOfTicker.initialize()}, delay)
}

domticker.prototype.initialize=function(){
var instanceOfTicker=this
this.contentdiv=document.getElementById(this.tickerid).firstChild //div of inner content that holds the messages
document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0}
this.rotatemsg()
}

domticker.prototype.rotatemsg=function(){
var instanceOfTicker=this
if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it)
setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
else{
this.fadetransition("reset") //FADE EFFECT- RESET OPACITY
this.contentdiv.innerHTML=this.content[this.pointer]
this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT
this.pointer=(this.pointer<this.content.length-1)? this.pointer+1 : 0
setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container
}
}

// -------------------------------------------------------------------
// fadetransition()- cross browser fade method for IE5.5+ and Mozilla/Firefox
// -------------------------------------------------------------------

domticker.prototype.fadetransition=function(fadetype, timerid){
var contentdiv=this.contentdiv
if (fadetype=="reset")
this.opacitysetting=0.2
if (contentdiv.filters && contentdiv.filters[0]){
if (typeof contentdiv.filters[0].opacity=="number") //IE6+
contentdiv.filters[0].opacity=this.opacitysetting*100
else //IE 5.5
contentdiv.style.filter="alpha(opacity="+this.opacitysetting*100+")"
}
else if (typeof contentdiv.style.MozOpacity!="undefined" && this.opacitystring!=""){
contentdiv.style.MozOpacity=this.opacitysetting
}
else
this.opacitysetting=1
if (fadetype=="up")
this.opacitysetting+=0.2
if (fadetype=="up" && this.opacitysetting>=1)
clearInterval(this[timerid])
}

/* domticker end */




//new domticker(name_of_message_array, CSS_ID, CSS_classname, pause_in_miliseconds, optionalfadeswitch)
/*
new domticker(tickercontent, "domticker", "someclass", 3000, "fadeit")
document.write("<br />")
new domticker(tickercontent2, "domticker2", "someclass", 3000)
*/


function searchindex_check_group(group) {
	
	if (!group.checked) {
		return false;
	}
	else {
		
		if (group.id != 'searchindex_group_m') document.getElementById('searchindex_group_m').checked = false;
		if (group.id != 'searchindex_group_f') document.getElementById('searchindex_group_f').checked = false;
		if (group.id != 'searchindex_group_k') document.getElementById('searchindex_group_k').checked = false;
		
	}

}

function fetch_tags(parentobject, tag) {
	if (typeof parentobject.getElementsByTagName != 'undefined') {
		return parentobject.getElementsByTagName(tag);
	}
	else if (parentobject.all && parentobject.all.tags) {
		return parentobject.all.tags(tag);
	}
	else {
		return null;
	}
}

function element_overlaps(obj, menuinfo) {
	var selectinfo = new Array();
	
	selectinfo['left'] = getObjectPosLeft(obj);
	selectinfo['top'] = getObjectPosTop(obj);
	selectinfo['right'] = selectinfo['left'] + obj.offsetWidth;
	selectinfo['bottom'] = selectinfo['top'] + obj.offsetHeight;

	if (selectinfo['left'] > menuinfo['right'] || selectinfo['right'] < menuinfo['left'] || selectinfo['top'] > menuinfo['bottom'] || selectinfo['bottom'] < menuinfo['top']) {
		return false;
	}
	else return true;
}

function handle_overlaps(dohide, menuarea) {
	
	if (!is_ie) return;

	if (is_ie) {
		var selects = fetch_tags(document, 'select');

		if (dohide) {

			for (var i = 0; i < selects.length; i++)
			{
				if (element_overlaps(selects[i], menuarea) && selects[i].id != 'menu_mod')
				{
					selects[i].style.display = 'none';
					array_push(hidden_selects, i);
				}
			}
		}
		else
		{
			while (true)
			{
				var i = array_pop(hidden_selects);
				if (typeof i == 'undefined' || i == null)
				{
					break;
				}
				else
				{
					selects[i].style.display = '';
				}
			}
		}
	}
}