window.addEvent('domready', function () {
	$$('.fld').addEvent('click', function(){
		this.set('value', '');
	});

//	<!-- Advenced SELECT -->
//	var adv_select = new CustomSelect($('adv-select'));									  
	//////////var adv_select = new CustomSelect($('sel_box'));
//	
// BANNERS Counter 
	$$('a.ad-click').addEvent('click', function(e){
		var url = '/fr/advertisments/click?id=' + this.get('rel');
		new Request({ url: url, method: 'get', onSuccess: function () { } }).send();
	});
	
	
	// MAIN MENU 
	$$('#main-menu li').each(function(el){
		el.addEvent('mouseover', function(){
			el.getChildren('ul').removeClass('none');
		});
		el.addEvent('mouseout', function(){
			el.getChildren('ul').addClass('none');
		});
	});
	
});


function strtotime (str, now) {
    // http://kevin.vanzonneveld.net
    // +   original by: Caio Ariede (http://caioariede.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: David
    // +   improved by: Caio Ariede (http://caioariede.com)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Wagner B. Soares
    // %        note 1: Examples all have a fixed timestamp to prevent tests to fail because of variable time(zones)
    // *     example 1: strtotime('+1 day', 1129633200);
    // *     returns 1: 1129719600
    // *     example 2: strtotime('+1 week 2 days 4 hours 2 seconds', 1129633200);
    // *     returns 2: 1130425202
    // *     example 3: strtotime('last month', 1129633200);
    // *     returns 3: 1127041200
    // *     example 4: strtotime('2009-05-04 08:30:00');
    // *     returns 4: 1241418600
 
    var i, match, s, strTmp = '', parse = '';
 
    strTmp = str;
    strTmp = strTmp.replace('/\s{2,}|^\s|\s$/g', ' '); // unecessary spaces
    strTmp = strTmp.replace('/[\t\r\n]/g', ''); // unecessary chars
 
    if (strTmp == 'now') {
        return (new Date()).getTime()/1000; // Return seconds, not milli-seconds
    } else if (!isNaN(parse = Date.parse(strTmp))) {
        return (parse/1000);
    } else if (now) {
        now = new Date(now*1000); // Accept PHP-style seconds
    } else {
        now = new Date();
    }
 
    strTmp = strTmp.toLowerCase();
 
    var __is =
    {
        day:
        {
            'sun': 0,
            'mon': 1,
            'tue': 2,
            'wed': 3,
            'thu': 4,
            'fri': 5,
            'sat': 6
        },
        mon:
        {
            'jan': 0,
            'feb': 1,
            'mar': 2,
            'apr': 3,
            'may': 4,
            'jun': 5,
            'jul': 6,
            'aug': 7,
            'sep': 8,
            'oct': 9,
            'nov': 10,
            'dec': 11
        }
    };
 
    var process = function (m) {
        var ago = (m[2] && m[2] == 'ago');
        var num = (num = m[0] == 'last' ? -1 : 1) * (ago ? -1 : 1);
 
        switch (m[0]) {
            case 'last':
            case 'next':
                switch (m[1].substring(0, 3)) {
                    case 'yea':
                        now.setFullYear(now.getFullYear() + num);
                        break;
                    case 'mon':
                        now.setMonth(now.getMonth() + num);
                        break;
                    case 'wee':
                        now.setDate(now.getDate() + (num * 7));
                        break;
                    case 'day':
                        now.setDate(now.getDate() + num);
                        break;
                    case 'hou':
                        now.setHours(now.getHours() + num);
                        break;
                    case 'min':
                        now.setMinutes(now.getMinutes() + num);
                        break;
                    case 'sec':
                        now.setSeconds(now.getSeconds() + num);
                        break;
                    default:
                        var day;
                        if (typeof (day = __is.day[m[1].substring(0, 3)]) != 'undefined') {
                            var diff = day - now.getDay();
                            if (diff == 0) {
                                diff = 7 * num;
                            } else if (diff > 0) {
                                if (m[0] == 'last') {diff -= 7;}
                            } else {
                                if (m[0] == 'next') {diff += 7;}
                            }
                            now.setDate(now.getDate() + diff);
                        }
                }
                break;
 
            default:
                if ('/\d+/'.test(m[0])) {
                    num *= parseInt(m[0], 10);
 
                    switch (m[1].substring(0, 3)) {
                        case 'yea':
                            now.setFullYear(now.getFullYear() + num);
                            break;
                        case 'mon':
                            now.setMonth(now.getMonth() + num);
                            break;
                        case 'wee':
                            now.setDate(now.getDate() + (num * 7));
                            break;
                        case 'day':
                            now.setDate(now.getDate() + num);
                            break;
                        case 'hou':
                            now.setHours(now.getHours() + num);
                            break;
                        case 'min':
                            now.setMinutes(now.getMinutes() + num);
                            break;
                        case 'sec':
                            now.setSeconds(now.getSeconds() + num);
                            break;
                    }
                } else {
                    return false;
                }
                break;
        }
        return true;
    };
 
    match = strTmp.match('/^(\d{2,4}-\d{2}-\d{2})(?:\s(\d{1,2}:\d{2}(:\d{2})?)?(?:\.(\d+))?)?$/');
    if (match != null) {
        if (!match[2]) {
            match[2] = '00:00:00';
        } else if (!match[3]) {
            match[2] += ':00';
        }
 
        s = match[1].split(/-/g);
 
        for (i in __is.mon) {
            if (__is.mon[i] == s[1] - 1) {
                s[1] = i;
            }
        }
        s[0] = parseInt(s[0], 10);
 
        s[0] = (s[0] >= 0 && s[0] <= 69) ? '20'+(s[0] < 10 ? '0'+s[0] : s[0]+'') : (s[0] >= 70 && s[0] <= 99) ? '19'+s[0] : s[0]+'';
        return parseInt(this.strtotime(s[2] + ' ' + s[1] + ' ' + s[0] + ' ' + match[2])+(match[4] ? match[4]/1000 : ''), 10);
    }
 
    var regex = '([+-]?\\d+\\s'+
        '(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?'+
        '|sun\.?|sunday|mon\.?|monday|tue\.?|tuesday|wed\.?|wednesday'+
        '|thu\.?|thursday|fri\.?|friday|sat\.?|saturday)'+
        '|(last|next)\\s'+
        '(years?|months?|weeks?|days?|hours?|min|minutes?|sec|seconds?'+
        '|sun\.?|sunday|mon\.?|monday|tue\.?|tuesday|wed\.?|wednesday'+
        '|thu\.?|thursday|fri\.?|friday|sat\.?|saturday))'+
        '(\\sago)?';
 
    match = strTmp.match(new RegExp(regex, 'g'));
    if (match == null) {
        return false;
    }
 
    for (i in match) {
        if (!process(match[i].split(' '))) {
            return false;
        }
    }
 
    return (now.getTime()/1000);
}

function dateFromating(d)
{

	var day = (d.getDate() < 10 ? "0":"")+d.getDate();
	var month = ((d.getMonth()+1) < 10 ? "0":"")+(d.getMonth()+1);
	var Year = d.getFullYear();
	
	return day+"/"+month+"/"+Year;
	
}

function AddToBAsketCostum(e,tt)
{
	
			e.stop();
			
			
			var popup = new AjaxPopup({ width: 550 });
			popup.addEvent('ready', function (e) {
				addThisToBAsket();
				window.addEvent('click', function () {
					popup.close();
				});
				$$('.save-button').removeEvent('click');
				$$('.save-button').addEvent('click', function(){window.location.href='/fr/basket/'});

			/*	popup.addEvent('beforesubmit', function () {
					var id = $('add-to-basket').get('rel').toInt();
					var url = '/fr/basket/show?product_id='+id;
					var box = $$('.basket')[0];
					new Element('div', {
						'id': 'basket-loader',
						'class': 'small-loader',
						'styles': {
							'width': box.getStyle('width'),
							'height': box.getStyle('height'),
							'opacity': '0.75',
							'z-index': '50',
							'position': 'absolute',
							'top': '0'
						}
					}).inject(box);
					
					new Request({ url: url, method: 'post', 
						onSuccess: function (data) {
							if (Cookie.read('basket')) {
								$('prod-count').set('text', $('prod-count').get('text').toInt() + 1);
							} else {
								$('prod-count').set('text', 1);
							}
							
							
							$('basket-loader').destroy();
						}
					}).send();

					//popup.close();
				});*/
			});
			
			
			popup.addEvent('close', function (e) {
				if (!e.ok) return;
			});
			
			popup.open({ url: tt.get('href'), closeTitle:'', title: '&nbsp;' });
			
			popup.fireEvent('beforesubmit');
		
		
}
var addThisToBAsket =	 function () {
					var id = $('add-to-basket').get('rel').toInt();
					var url = '/fr/basket/show?product_id='+id;
					var box = $$('.basket')[0];
					new Element('div', {
						'id': 'basket-loader',
						'class': 'small-loader',
						'styles': {
							'width': box.getStyle('width'),
							'height': box.getStyle('height'),
							'opacity': '0.75',
							'z-index': '50',
							'position': 'absolute',
							'top': '0'
						}
					}).inject(box);
					
					new Request({ url: url, method: 'post', 
						onSuccess: function (data) {
							if (Cookie.read('basket')) {
								$('prod-count').set('text', $('prod-count').get('text').toInt() + 1);
							} else {
								$('prod-count').set('text', 1);
							}
							
							
							$('basket-loader').destroy();
						}
					}).send();

					//popup.close();
	 }
	 
	 
	 
	 
///////////////////////////////////////////////////////
//////////////////////////////////////////////////////
/*

CUSTOM FORM ELEMENTS

Created by Ryan Fait
www.ryanfait.com

The only thing you need to change in this file is the following
variables: checkboxHeight, radioHeight and selectWidth.

Replace the first two numbers with the height of the checkbox and
radio button. The actual height of both the checkbox and radio
images should be 4 times the height of these two variables. The
selectWidth value should be the width of your select list image.

You may need to adjust your images a bit if there is a slight
vertical movement during the different stages of the button
activation.

Visit http://ryanfait.com/ for more information.

*/

var checkboxHeight = "25";
var radioHeight = "25";
var selectWidth = "211";

/* No need to change anything after this */

document.write('<style type="text/css">input.inputselect { display: none; } select.inputselect { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; }</style>');

var Custom = {
	init: function() {
		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
		for(a = 0; a < inputs.length; a++) {
			if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
				span[a] = document.createElement("span");
				span[a].className = inputs[a].type;

				if(inputs[a].checked == true) {
					if(inputs[a].type == "checkbox") {
						position = "0 -" + (checkboxHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					} else {
						position = "0 -" + (radioHeight*2) + "px";
						span[a].style.backgroundPosition = position;
					}
				}
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.clear;
				span[a].onmousedown = Custom.pushed;
				span[a].onmouseup = Custom.check;
				document.onmouseup = Custom.clear;
			}
		}
		inputs = document.getElementsByTagName("select");
		for(a = 0; a < inputs.length; a++) {
			if(inputs[a].className == "inputselect") {
				option = inputs[a].getElementsByTagName("option");
				active = option[0].childNodes[0].nodeValue;
				textnode = document.createTextNode(active);
				for(b = 0; b < option.length; b++) {
					if(option[b].selected == true) {
						textnode = document.createTextNode(option[b].childNodes[0].nodeValue);
					}
				}
				span[a] = document.createElement("span");
				span[a].className = "select";
				span[a].id = "select" + inputs[a].name;
				span[a].appendChild(textnode);
				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
				inputs[a].onchange = Custom.choose;
			}
		}
	},
	pushed: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
		} else if(element.checked == true && element.type == "radio") {
			this.style.backgroundPosition = "0 -" + radioHeight*3 + "px";
		} else if(element.checked != true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
		} else {
			this.style.backgroundPosition = "0 -" + radioHeight + "px";
		}
	},
	check: function() {
		element = this.nextSibling;
		if(element.checked == true && element.type == "checkbox") {
			this.style.backgroundPosition = "0 0";
			element.checked = false;
		} else {
			if(element.type == "checkbox") {
				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else {
				this.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
				group = this.nextSibling.name;
				inputs = document.getElementsByTagName("input");
				for(a = 0; a < inputs.length; a++) {
					if(inputs[a].name == group && inputs[a] != this.nextSibling) {
						inputs[a].previousSibling.style.backgroundPosition = "0 0";
					}
				}
			}
			element.checked = true;
		}
	},
	clear: function() {
		inputs = document.getElementsByTagName("input");
		for(var b = 0; b < inputs.length; b++) {
			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
			} else if(inputs[b].type == "checkbox" && inputs[b].className == "inputselect") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			} else if(inputs[b].type == "radio" && inputs[b].checked == true && inputs[b].className == "inputselect") {
				inputs[b].previousSibling.style.backgroundPosition = "0 -" + radioHeight*2 + "px";
			} else if(inputs[b].type == "radio" && inputs[b].className == "inputselect") {
				inputs[b].previousSibling.style.backgroundPosition = "0 0";
			}
		}
	},
	choose: function() {
		option = this.getElementsByTagName("option");
		for(d = 0; d < option.length; d++) {
			if(option[d].selected == true) {
				document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;
			}
		}
	}
}

adultCat=function(message,accept,decline)
{
	var overlay = new Element('div', {
			'class': 'overlay',
			
			styles: {
				width: window.getScrollWidth(),
				height: window.getScrollHeight()
				
			}
		}).inject(document.body);	
				
	
			
	var confirm_box = new Element('div',{'class':'popup',styles: {
				width:Math.floor( window.getScrollWidth()/3),
				padding:"20px"
			}}).inject(overlay);
	 confirm_box.set('html',message)	;
	 
	 var panel = new Element('div', {
				'class': 'action-panel'
			}).inject(confirm_box);
	 
	 
	 var		acceptButton = new Element('input', {
				name: 'save',
				type: 'button',
				value: accept,
				'class': 'accept-button'
			}).inject(panel);
			
	 var		cancelButton = new Element('input', {
				name: 'save',
				type: 'button',
				value: decline,
				'class': 'decline-button'
			}).inject(panel);
			
	acceptButton.addEvent('click', function () {
		try{
		                                     overlay.destroy(); 
		                                     /*confirm_box.destroy(); 
		                                     panel.destroy(); 
		                                     acceptButton.destroy(); 
		                                     cancelButton.destroy(); */
		                                     writeCookie('adult_confirmet','YES',1/4);
		}catch(e){alert(e.message)}
											});
													
	cancelButton.addEvent('click', function (){window.location.href = "/fr";});				
	
};


function writeCookie(name, value, hours)

{

  var expire = "";

  if(hours != null)

  {

    expire = new Date((new Date()).getTime() + hours * 3600000);

    expire = "; expires=" + expire.toGMTString();

  }

  document.cookie = name + "=" + escape(value) + expire;

}

window.onload = Custom.init;