
	var _ccom_ui_NEXTPAGE = 0;
	var _ccom_ui_PREVPAGE = 1;	


	function ccom_ui_checkLeapyear(year)
	{
		year = parseInt(year);

		if(year % 4 == 0)
		{
			if(year % 100 != 0)
			{
				return true;
			}
			else
			{
				if(year % 400 == 0)
					return true;
				else
					return false;
			}
		}
	  return false;
	}

	function ccom_ui_toolTipTextGet(field_id)
	{
		var info;
		var country_id = document.getElementById('country').value;

		var key = field_id + '_' + country_id;
		if(form_params[key] != undefined)
			info = form_params[key]['info'];
		else
			info = form_params[field_id]['info'];
		return info;
	}


	var ccom_ui_loggedInImage = 'images/page_elements/mainmenu_logged_in.gif';
	var ccom_ui_loggedOutImage = 'images/page_elements/mainmenu_logged_out.gif';
	var ccom_ui_loggedInMap = '#map_mainmenu_loggedin';
	var ccom_ui_loggedOutMap = '#map_mainmenu_loggedout';
	

	var ccom_ui_mainMenuLoggedInCode = '<img name="topmenu" src="' + ccom_ui_loggedInImage + '" border="0" usemap="' + ccom_ui_loggedInMap + '">';
	var ccom_ui_mainMenuLoggedOutCode = '<img name="topmenu" src="' + ccom_ui_loggedOutImage + '" border="0" usemap="' + ccom_ui_loggedOutMap + '">';
		
	function ccom_ui_mainMenuSet(menu)
	{
		switch(menu)
		{
			case 'logged_in':
				document.getElementById('mainmenu').innerHTML = ccom_ui_mainMenuLoggedInCode;
				break;
			
			case 'logged_out':
				document.getElementById('mainmenu').innerHTML = ccom_ui_mainMenuLoggedOutCode;
				break;
		}
	}

	function ccom_ui_imageToHolderLoad(holderId, filePath, fadeDuration)
	{
	  if(document.all)
	  {
	    document.getElementById(holderId).style.filter="blendTrans(duration=" + fadeDuration + ")";
	    document.getElementById(holderId).filters.blendTrans.Apply();
	  }
	  
	  document.getElementById(holderId).src = filePath;
	  
	  if(document.all)
	    document.getElementById(holderId).filters.blendTrans.Play();
	}

	
	function ccom_ui_controlButtonsFormat(basename, firstindex, lastindex, selectedindex)
	{
		var cname, i;
		
		for(i =  firstindex; i <= lastindex; i++)
		{
			if(i == selectedindex)
				cname = 'slideshow-controlbutton-selected';
			else
				cname = 'slideshow-controlbutton';
					
			document.getElementById(basename + i).className = cname;
		}		
	}
	
	
	function ccom_ui_controlButtonMouseOver(buttonid)
	{
		if(document.getElementById(buttonid).className != 'slideshow-controlbutton-selected')
			document.getElementById(buttonid).style.textDecoration = 'underline';	
	}
	
	function ccom_ui_controlButtonMouseOut(buttonid)
	{
		document.getElementById(buttonid).style.textDecoration = 'none';	
	}
	
	function ccom_ui_prevArrowButtonMouseClick(holderId, basename, separator, firstindex, lastindex, fadeDuration)
	{
		var new_imgfilepath;
		var selectedindex = _ccom_ui_newImgFileIndexGet(holderId, separator, firstindex, lastindex, _ccom_ui_PREVPAGE);
		new_imgfilepath = _ccom_ui_newImgFilePathGet(holderId, separator, selectedindex);
		ccom_ui_controlButtonsFormat(basename, firstindex, lastindex, selectedindex);
		ccom_ui_imageToHolderLoad(holderId, new_imgfilepath, fadeDuration);
	}
	
	function ccom_ui_nextArrowButtonMouseClick(holderId, basename, separator, firstindex, lastindex, fadeDuration)
	{
		var new_imgfilepath;
		var selectedindex = _ccom_ui_newImgFileIndexGet(holderId, separator, firstindex, lastindex, _ccom_ui_NEXTPAGE);
		new_imgfilepath = _ccom_ui_newImgFilePathGet(holderId, separator, selectedindex);
		
		ccom_ui_controlButtonsFormat(basename, firstindex, lastindex, selectedindex);
		ccom_ui_imageToHolderLoad(holderId, new_imgfilepath, fadeDuration);
	}

	
	function _ccom_ui_newImgFileIndexGet(holderId, separator, firstindex, lastindex, direction)
	{
		var imgno;
		var imgfilepath = document.getElementById(holderId).src;
		var imgno_startpos = imgfilepath.indexOf(separator);
			
		if(imgno_startpos == -1)
			imgno = 0;
		else
			imgno = parseInt(imgfilepath.substr(imgno_startpos + 1, 2));
				
		switch(direction)
		{
			case _ccom_ui_NEXTPAGE:
					if(imgno == lastindex)
						imgno = firstindex;
					else
						imgno += 1;
					break;		
		
			case _ccom_ui_PREVPAGE:
				if(imgno == firstindex)
					imgno = lastindex;
				else
					imgno -= 1;
				break;	
		}
		
		return imgno;
	}
	
	function _ccom_ui_newImgFilePathGet(holderId, separator, imgno)
	{
		var imgno_string;
		var imgfilepath = document.getElementById(holderId).src;
		var imgno_startpos = imgfilepath.indexOf(separator);
	
		if(imgno < 10)
			imgno_string = '0' + imgno;
		else
			imgno_string = '' + imgno;
	
		return imgfilepath.substr(0, imgno_startpos + 1) + imgno_string + '.gif';
	}
	
	function _ccom_ui_buynowbuttonDisplay(id, state)
	{
		newstate = state ? 'block' : 'none';
		document.getElementById(id).style.display = newstate;
	}
	
	function ccom_ui_discountCodeCheck()
	{
		code = document.getElementById('discount_code').value.replace(/^\s+|\s+$/g, '');
		if(code != '')
			alert(code);
			
	}
	
	function ccom_ui_sorttypeselect()
	{		
		var target = document.productwidgets.sortwidget.selectedIndex;	 
     	window.location.href = document.productwidgets.sortwidget.options[target].value;
	}
	
	
	function ccom_ui_filterselect()
	{		
		var target = document.productwidgets.filterwidget.selectedIndex; 
     	window.location.href = document.productwidgets.filterwidget.options[target].value;
	}
	
  	function ccom_ui_formatselect()
	{		
		var len = document.productwidgets.formatwidget.length;
		for(i = 0; i < len; i++)
		{
			if(document.productwidgets.formatwidget[i].checked)
			{
//				alert(document.productwidgets.formatwidget[i].value);
				window.location.href = document.productwidgets.formatwidget[i].value;
			}
			
		}		
		
		
	
     	
	}