﻿/*js for MC*/
	var MC = {};
	(function(MC){
		_this = MC;
		_this.COLOR_ID		= 0;
		_this.SIZE_ID		= 0;
		_this.COLOR_ATTR	= 0;
		_this.SIZE_ATTR		= 0;
		_this.COLOR_NAME	= '';
		_this.SIZE_NAME		= '';
		_this.ISONE_SIZE	= false;
		_this.SIZE_ID_ONE	= 0;
		_this.ISNO_SIZE		= false;
		_this.ISONE_MSG		= false;
		_this.ISNO_MSG		= false;
		_this.ISTU_SIZE		= false;
		_this.ISONE_COLOR	= false;
		_this.URL			= location.href.split('?')[1];
		if(_this.URL != undefined){
		_this.URL			= _this.URL.split('{')[1];
		if(_this.URL != undefined){_this.URL = _this.URL.split('}')[0];}
		}		
		_this.topmenuStruct	= function(){
			var m_ul = $j("#nav li ul[class='level0 hide']");
			m_ul.each(function(iter){
				var m_ul_li = m_ul.eq(iter).children();
				var total = parseInt(m_ul_li.size());
				var col_num = parseInt(total/12);
				var col_width = 116;
				var tag_id = 'mc_menu_sty_'+iter+'_0';
				var isend = false;
				$j(m_ul[iter]).addClass("hide");
				if(total > 12){
					$j(m_ul[iter]).attr("style","border: 2px solid rgb(224, 42, 134); width: "+parseInt((col_num+1)*col_width)+"px; left: -"+parseInt(col_num*col_width+2)+"px; top: 27px; z-index:999;");
		
					m_ul_li.each(function(iterli){    
						if(iterli != 0 && iterli%12 == 0){
							$j("#nav li[tag_id=\""+tag_id+"\"]").wrapAll("<div style='float:left;' class='mc_menu_col_style_forie'></div>");
							tag_id = 'mc_menu_sty_'+iter+"_"+iterli;
						}
						if((total - iterli) < 12 && (total -iterli)%12 != 0){
							isend = true;
						}
						 $j(m_ul_li[iterli]).attr("tag_id",tag_id);
			
					});
					if(isend){
						$j("#nav li[tag_id=\""+tag_id+"\"]").wrapAll("<div style='float:left;' class='mc_menu_col_style_forie'></div>");
					}
					m_ul.eq(iter).prepend("<div style='width:114px; height:2px; overflow:hidden; background:#fff; float:right; position:relative; top:-12px;'></div>");
				}
			});
		}
		_this.makeProductViewClick =	function(p,c){
			if(p){
				$j("#view-size-info").click(function(){
					if($j("#view-html").attr("class") == "view-html"){
						$j("#view-html").addClass("hide");
						$j("#add-to-cart-hbox").removeClass("hide");
					}else{
						$j("#view-html").removeClass("hide");
						$j("#add-to-cart-hbox").addClass("hide");
					}
				});
			}else{
						$j("#view-html").addClass("hide");
						$j("#add-to-cart-hbox").removeClass("hide");			
			}
		}
		_this.makeCartClick	= function(iterid){
			$j("#cart-update-left-button-"+iterid).click(function(){
				$j("#cart-update-number-"+iterid).val(parseInt($j("#cart-update-number-"+iterid).val())-1);
				$j("#cart-update-submit").submit();
			});
			$j("#cart-update-right-button-"+iterid).click(function(){
				$j("#cart-update-number-"+iterid).val(parseInt($j("#cart-update-number-"+iterid).val())+1);
				$j("#cart-update-submit").submit();
			});
			$j("#cart-update-number-"+iterid).blur(function(){
				$j("#cart-update-submit").submit();
			});
		}
		_this.turnSecondImg	= function(el,id,over){
			if(over){
				this.second	= $j("#second-img-"+id).val();
				this.imgsrc	= $j(el).attr("src");
				$j(el).attr("src",this.second);
			}else{
				$j(el).attr("src",this.imgsrc);
			}
		}
		_this.checkForm	= function(){
			if(_this.ISONE_MSG || _this.ISNO_MSG){
				$j("#add-to-cart-hcon").removeClass("hide");
				_this.isAddCart();		
			}else{
				if((_this.SIZE_ID == 0 || $j("#attribute"+_this.SIZE_ATTR).val() == '')){
					$j("#msg-size").removeClass("hide");
				}else{
					$j("#add-to-cart-hcon").removeClass("hide");
					_this.isAddCart();
				}				
			}
		}
		_this.makeaddtype	= function(type){
			$j("#addtype").val(type);
			productAddToCartForm.submit();
		}
		_this.isAddCart	= function(){
			var isadd = $j("#addtype").val();
			if(isadd == 1){
				return true;
			}else{
				setTimeout("_this.isAddCart()", 1000);
			}
		}
		_this.isColorLoad	= function(){
			if($j("#attribute"+_this.COLOR_ATTR).val() > 0){
				$j("#attribute"+_this.SIZE_ATTR).val(_this.SIZE_ID_ONE);
				Event.fireEvent("attribute"+_this.SIZE_ATTR, 'change');
				$j("#msg-select-box").removeClass('hide');
				$j("#msg-select").text("\""+_this.COLOR_NAME+"\", \""+_this.SIZE_NAME+"\"");
				$j("#size"+_this.SIZE_ID_ONE).addClass("size-list-click");
				//alert($j("#attribute"+_this.SIZE_ATTR).val());						
			}else{
				//alert($j("#attribute"+_this.COLOR_ATTR).val());
				setTimeout(_this.isColorLoad(),1000);
			}
		}
		_this.showSelectInfo	= function(){
			$j(document).ready(function(){
				$j("#msg-select-box").removeClass('hide');
				if(_this.ISONE_COLOR){
					$j("#color-title").addClass("hide");
					$j("#mc_color_list").addClass("hide");				
				}
				if(_this.ISNO_SIZE || _this.ISTU_SIZE){
					$j("#size-title").addClass("hide");
					$j("#mc_size_list").addClass("hide");
					_this.ISONE_MSG = _this.ISONE_SIZE;
					_this.ISNO_MSG	= _this.ISNO_SIZE;
					_this.ISNO_SIZE = false;
					_this.ISTU_SIZE = false;
				}else{
					$j("#size-title").removeClass("hide");
					$j("#mc_size_list").removeClass("hide");					
				}				
				if(_this.ISONE_SIZE){
					_this.isColorLoad();
					_this.ISONE_MSG = _this.ISONE_SIZE;
					_this.ISONE_SIZE = false;
				}else{
					$j("#msg-select").text("\""+_this.COLOR_NAME+"\"");
				}
			});			
		}
		_this.Allpage = function(){
			
		}
		_this.Allpage.prototype.showMSG	=	function(){
			var msg = $j.cookie("allpage_msg_bycookie");
			//alert(msg);
			if(msg != null){
				eval("var msgobj = "+msg+";");
				var html = '';
				msgobj.msg.each(function(type){
					eval("var typeobj ="+type+";");
					html += '<ul class="messages">';
					html += '<li class="' + typeobj.type + '-msg">';
					html += '<ul>';
					//alert(typeobj.type);
					typeobj.data.each(function(code){
						html += '<li>';
						var re = /\+/g;
						html += code.replace(re," ");
						html += '</li>';
						//alert(code);
					});
					html += '</ul>';
					html += '</li>';
					html += '</ul>';
				});
				$j.cookie("allpage_msg_bycookie", '', {'expires':-1, 'path': '/', 'domain': 'www.misscoquines.com'});
				//Mage.Cookies.mc_clear("msg");			
				//alert(html);
				$j("#mc_allpage_msg_box").html(html);
			}
		}
		_this.Color	= function(colorinfo,colorid){
			this.cobj	= colorinfo;
			this.cdiv	= $j("#"+colorid);
			this.nowid	= 0;
			_this.color	= this;
			this.showList(this.getList());
			this.makeClick();
		}
		_this.Color.prototype.getList	= function(){
			var str = '<ul>';
			var step = 0;
			this.cobj.each(function(color){
				str += "<li id='color"+color.id+"'><img src='"+color.thumb+"' title='"+color.name+"' /></li>";
				step++;
				//if(parseInt(step)%8 == 0){ str += "<br><br>"; }
			});
			str += '</ul>';
			if(step == 1){ _this.ISONE_COLOR = true; }
			return str;
		}
		_this.Color.prototype.getOne	= function(id){
			_this.color.cobj.each(function(color){
				if(color.id == _this.COLOR_ID){
					var centerstr = '';
					color.img.each(function(img){
						if(img.disabled == 0){
						if(img.step == id){
							if(img.dd){
								centerstr += "<object "
								centerstr += "classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' "
								centerstr += "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' "
								centerstr += "width='300' height='383'>";
								centerstr += "<param name='movie' value=\'"+img.flash+"\'>";
								centerstr += "<param name='quality' value='high'>";
								centerstr += "<embed "
								centerstr += "src=\'"+img.flash+"\' "
								centerstr += "quality='high' "
								centerstr += "pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' "
								centerstr += "type='application/x-shockwave-flash' width='300' height='383'>"
								centerstr += "</embed>";
								centerstr += "</object>";
							}else{
							centerstr += '<div class=\"jqzoom\">';
							var stylestr = 'style=\"z-index: 1000; display: block;\"';
							centerstr += "<img height=\"383px\" width=\"300px\" jqimg=\""+img.big+"\" src=\""+img.center+"\" id=\"image"+img.step+"\" "+stylestr+"/>";
							centerstr += '</div>';
							}
						}
						}
					});
					$j("#image").empty();
					$j("#image").html(centerstr);
					myZoom();
				}
			});			
		}
		_this.Color.prototype.showList	= function(htmlstr){
			this.cdiv.html(htmlstr);
		}
		_this.Color.prototype.makeClick= function(){
			this.cobj.each(function(color){
				if(color.id == color.defaultid){
					if(_this.URL == undefined){
						_this.COLOR_ID = color.defaultid;
						_this.COLOR_NAME = _this.color.getName(_this.COLOR_ID);
						//_this.color.changeImages('normal');
						_this.showSelectInfo();
					}else{
						_this.COLOR_ID = _this.URL;
						_this.COLOR_NAME = _this.color.getName(_this.COLOR_ID);
						_this.color.changeImages('default');
					}
					$j("#color"+_this.COLOR_ID).addClass("border1px");
				}
				$j("#color"+color.id).click(function(){
					$j("#color"+_this.COLOR_ID).removeClass("border1px");
					_this.COLOR_ID = $j(this).attr("id").replace(/[a-z]*/, '');
					_this.COLOR_NAME = _this.color.getName(_this.COLOR_ID);					
					$j(this).addClass("border1px");
					_this.color.changeImages('normal');
					_this.showSelectInfo();
					$j("#msg-size").addClass("hide");
				});
			});
		}
		_this.Color.prototype.getName = function(colorid){
			var str = '';
			this.cobj.each(function(color){
				if(color.id == colorid){
					str += color.name;
				}
			});
			return str;
		}
		_this.Color.prototype.changeImages = function(type){
			_this.color.cobj.each(function(color){
				if(color.id == _this.COLOR_ID){
					var smallstr = '<ul>';
					var centerstr = '';
					color.img.each(function(img){
						if(img.disabled == 0){
						//centerstr += '<div class=\"jqzoom\">';
						if(img.dd){
							smallstr += "<li><a onclick=\"MC.color.getOne('"+img.step+"'); return false;\" href='#'><img src='"+img.dd+"'/></a></li>";
						}else{
							smallstr += "<li><a onclick=\"MC.color.getOne('"+img.step+"'); return false;\" href='#'><img src='"+img.small+"'/></a></li>";
						}
						if(img.step == 0){
							var stylestr = 'style=\"z-index: 1000; display: block;\"';
							if(img.dd){
								centerstr += "<object "
								centerstr += "classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' "
								centerstr += "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' "
								centerstr += "width='300' height='383'>";
								centerstr += "<param name='movie' value=\'"+img.flash+"\'>";
								centerstr += "<param name='quality' value='high'>";
								centerstr += "<embed "
								centerstr += "src=\'"+img.flash+"\' "
								centerstr += "quality='high' "
								centerstr += "pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' "
								centerstr += "type='application/x-shockwave-flash' width='300' height='383'>"
								centerstr += "</embed>";
								centerstr += "</object>";							
							}else{
							centerstr += '<div class=\"jqzoom\">';
							centerstr += "<img height=\"383px\" width=\"300px\" jqimg=\""+img.big+"\" src=\""+img.center+"\" id=\"image"+img.step+"\" "+stylestr+"/>";
							centerstr += '</div>';
							}
							
						}else{
							var stylestr = 'style=\"z-index: -1; display: none;\"';
						}
						//centerstr += "<img height=\"383px\" width=\"300px\" jqimg=\""+img.big+"\" src=\""+img.center+"\" id=\"image"+img.step+"\" "+stylestr+"/>";
						//centerstr += '</div>';
						}
					});
					smallstr += '</ul>';
					$j("#more-views").empty();
					$j("#more-views").html(smallstr);
					$j("#image").empty();
					$j("#image").html(centerstr);
					myZoom();
					if(type != 'default'){
						_this.size.showList(_this.size.getList(_this.COLOR_ID));
						_this.size.makeClick(_this.COLOR_ID);
						$j("#attribute"+_this.COLOR_ATTR).val(_this.COLOR_ID);
						Event.fireEvent("attribute"+_this.COLOR_ATTR, 'change');
						//spConfig.configureElement($("attribute"+_this.COLOR_ATTR));//调用原有Prototype库方法
					}
				}
			});			
		}
		_this.Size	= function(sizeinfo,attribules,sizeid){
			this.sobj			= sizeinfo;
			this.sdiv			= $j("#"+sizeid);
			this.hidecate		= [24,25,26,40,37,35,28,29,33,36,38,41,42,39];
			this.currcate		= attribules.currcate;
			this.iseqcurrcate	= false; 
			_this.size			= this;
			_this.COLOR_ATTR	= attributes.color_attributeid;
			_this.SIZE_ATTR		= attributes.size_attributeid;
			this.showList(this.getList(_this.COLOR_ID));
			this.makeClick(_this.COLOR_ID);
			$j("#attribute"+_this.COLOR_ATTR).val(_this.COLOR_ID);
			Event.fireEvent("attribute"+_this.COLOR_ATTR, 'change');
			//spConfig.configureElement($("attribute"+_this.COLOR_ATTR));//调用原有Prototype库方法
		}
		_this.Size.prototype.getList	= function(colorid){
			var str = '<ul>';
			var step = 0;
			this.hidecate.each(function(cate){
				if(_this.size.currcate == cate){
					_this.size.iseqcurrcate = true;
				}
			});
			this.sobj.each(function(color){
				if(color.cid == colorid){					
					_this.size.sort(color.size);
					color.size.each(function(size){
						str += "<li id='size"+size.id+"' class='size-list' title='"+size.label+"' >"+size.label+"</li>";
						step++;
						_this.SIZE_ID_ONE = size.id;
						if(size.label.toUpperCase() == "TU" && _this.size.iseqcurrcate){
							_this.ISTU_SIZE = true;
						}
						//if(parseInt(step)%8 == 0){ str += "<br><br>"; }
					});
				}
			});
			str += '</ul>';
			if(step == 1){_this.ISONE_SIZE	= true;}
			if(step == 0){_this.ISNO_SIZE	= true;}
			return str;
		}
		_this.Size.prototype.sort		= 	function(arr) { 
			var st = new Date();
			var temp;
			var exchange;
			for(var i=0; i<arr.length; i++) {
				exchange = false;
				for(var j=arr.length-2; j>=i; j--) {
					if((arr[j+1].sortid) < (arr[j].sortid)) {
					 temp = arr[j+1];
					 arr[j+1] = arr[j];
					 arr[j] = temp;
					 exchange = true;
					}
				}
				if(!exchange) break;
			}
			status = (new Date() - st) + ' ms';
			return arr;
		}
		_this.Size.prototype.showList	= function(htmlstr){
			this.sdiv.html(htmlstr);
		}
		_this.Size.prototype.getName	= function(colorid){
			var str = '';
			this.sobj.each(function(color){
				if(color.cid == colorid){
					color.size.each(function(size){
						str += size.label;
					});
				}
			});
			return str;
		}		
		_this.Size.prototype.makeClick	= function(colorid){
			this.sobj.each(function(color){
				if(color.cid == colorid){
					color.size.each(function(size){
						if(_this.ISONE_SIZE){
							_this.SIZE_NAME = _this.size.getName(_this.COLOR_ID);
							$j(document).ready(function(){
								_this.isColorLoad();
							});
						}
						$j("#size"+size.id).click(function(){
							$j("#size"+_this.SIZE_ID). removeClass("size-list-click");
							_this.SIZE_ID = $j(this).attr("id").replace(/[a-z]*/, '');
							_this.SIZE_NAME = size.label;
							$j(this).addClass("size-list-click");
							$j("#attribute"+_this.SIZE_ATTR).val(_this.SIZE_ID);
							Event.fireEvent("attribute"+_this.SIZE_ATTR, 'change');
							$j("#msg-select-box").removeClass('hide');
							$j("#msg-select").text("\""+_this.COLOR_NAME+"\", \""+_this.SIZE_NAME+"\"");
						});
					});				
				}
			});
		}
		/*商店搜索*/
		_this.Shop	= function(data){
			this.data	= data;
			this.list	= [];
			this.total	= 0;
			this.now	= 0;
			this.stype	= '';
			this.all_city_country	= 0;
			this.all_city_city		= 0;
			_this.shop	= this;
		}
		_this.showDefaultCity	= function(){
			$j(document).ready(function(){
				if($j("#city").val() != null){
					_this.Shop.prototype.showAddressList('one-city');
				}else{
					setTimeout(_this.showDefaultCity(),1000);
				}
			});
		}
		_this.Shop.prototype.init	= function(city,type){
			this.list				= [];
			var step				= 0;
			var one_city_step		= 0;
			var all_city_step		= 0;
			var all_city_country	= 0;
			var all_city_city		= 0;
			var str					= '';
			var total				= _this.shop.data.size() - 1;
			str += '<span class="list-button-left" id="list-button-left"></span>';
			str += '<span class="list-button-right" id="list-button-right"></span>';
			this.data.each(function(d){
				all_city_country++;									
				if(type == 'all-city'){
					str += '<div class="content">';
					str += '<div class="bghead"></div>';
					str += '<div class="form-box">';
					str += '<h4>'+d.name+'</h4>';
					str += '<div class="labelsty">';
					//str += '<li><label>Pays</label></li>';
					//str += '<li><label>Ville</label></li>';
					str += '<li id="adresse-label-'+all_city_step+'"><label>adres</label></li>';
					str += '<li><label style="display:block;  height:16px;"></label></li>';
					str += '<li><label class="tel">Tel</label></li>';
					str += '</div>';
					str += '<div class="spansty"></div>';
					//str += '<li><span>'+d.country+'</span></li>';
					//str += '<li><span>'+d.city+'</span></li>';
					str += '<li id="adresse-content-'+all_city_step+'"><span>'+d.address+'</span></li>';
					str += '<li><span>'+d.post+' '+d.city+'</span></li>';
					str += '<li><span>'+d.phone+'</span></li>';
					str += '</div>';
					str += '<div class="bgfoot"></div>';
					str += '</div>';
					step++;
					if(step%6 == 0){
						var lp	= {};
						lp.data = str;
						_this.shop.list.push(lp.data);
						str = '';
						str += '<span class="list-button-left" id="list-button-left"></span>';
						str += '<span class="list-button-right" id="list-button-right"></span>';						
					}
					all_city_step++;
					if(all_city_step == 6){ all_city_step = 0; }
				}else if(d.city == city){
					all_city_city++;
					str += '<div class="content">';
					str += '<div class="bghead"></div>';
					str += '<div class="form-box">';
					str += '<h4>'+d.name+'</h4>';
					str += '<div class="labelsty">';
					//str += '<li><label>Pays</label></li>';
					//str += '<li><label>Ville</label></li>';
					str += '<li id="adresse-label-'+one_city_step+'"><label>adres</label></li>';
					str += '<li><label style="display:block; height:16px;"></label></li>';
					str += '<li><label class="tel">Tel</label></li>';
					str += '</div>';
					str += '<div class="spansty"></div>';
					//str += '<li><span>'+d.country+'</span></li>';
					//str += '<li><span>'+d.city+'</span></li>';
					str += '<li id="adresse-content-'+one_city_step+'"><span>'+d.address+'</span></li>';
					str += '<li><span>'+d.post+' '+d.city+'</span></li>';
					str += '<li><span>'+d.phone+'</span></li>';
					str += '</div>';
					str += '<div class="bgfoot"></div>';
					str += '</div>';
					step++;
					if(step%6 == 0){
						var lp	= {};
						lp.data = str;
						_this.shop.list.push(lp.data);
						str = '';
						str += '<span class="list-button-left" id="list-button-left"></span>';
						str += '<span class="list-button-right" id="list-button-right"></span>';						
					}
					one_city_step++;
					if(one_city_step == 6){ one_city_step = 0; }					
				}
			});
					if(step%6 != 0){
						var lp	= {};
						lp.data = str;
						_this.shop.list.push(lp.data);
						str = '';
						str += '<span class="list-button-left" id="list-button-left"></span>';
						str += '<span class="list-button-right" id="list-button-right"></span>';						
					}
			this.total = parseInt((step - 1)/6);
			//alert(this.total);
			_this.shop.all_city_country = all_city_country;
			_this.shop.all_city_city	= all_city_city;
		}
		_this.Shop.prototype.showAddressList	= function(searchtype){
			var city	= $j("#city").val();
			var result	= $j("#shop-result");
			var title_iter = $j("#title-iter");
			var title_alliter = $j("#title-alliter");
			_this.shop.stype = searchtype != '' ? _this.shop.stype = searchtype : _this.shop.stype = _this.shop.stype;

			_this.shop.init(city,searchtype);
			
			//alert(_this.shop.all_city_country);
			if(_this.shop.all_city_city == 0){
				title_iter.text('');
			}else if(_this.shop.all_city_city == 1){
				title_iter.text('Une vestigingen in '+city);
			}else{
				title_iter.text(_this.shop.all_city_city+' vestigingen in '+city);
			}
			//title_alliter.html('<a>Affiche les '+_this.shop.all_city_country+' boutiques Miss Coquines</a>');//显示数量
			title_alliter.html('<a>bekijk alle Miss Coquines vestigingen</a>');
			result.html(_this.shop.list[_this.shop.now]);
			if($j("#shop-result div[class='content']").size() != 6){
				$j("#list-button-left").addClass("list-button-left-oneline");
				$j("#list-button-right").addClass("list-button-right-oneline");
			}else{
				$j("#list-button-left").removeClass("list-button-left-oneline");
				$j("#list-button-right").removeClass("list-button-right-oneline");			
			}
			if(_this.shop.list[_this.shop.now - 1] == undefined){
				$j("#list-button-left").addClass("hide");
			}else if(_this.shop.list[_this.shop.now + 1] == undefined){
				$j("#list-button-right").addClass("hide");				
			}
			if(_this.shop.list[_this.shop.now - 1] == undefined && _this.shop.list[_this.shop.now + 1] == undefined && _this.shop.now == 0){
				$j("#list-button-left").addClass("hide");
				$j("#list-button-right").addClass("hide");
			}
			_this.shop.makeClick();
		}
		_this.Shop.prototype.makeClick	= function(){
			$j("#list-button-left").click(function(){
				_this.shop.now = _this.shop.now < 1 ? 0 : _this.shop.now - 1;
				_this.shop.showAddressList(_this.shop.stype);
			});
			$j("#list-button-right").click(function(){
				_this.shop.now = _this.shop.now > _this.shop.total ? _this.shop.total : _this.shop.now + 1;
				_this.shop.showAddressList(_this.shop.stype);
			});
			$j("#city").change(function(){
				_this.shop.now = 0;
			});
			var total = 6;
			for(var i = 0; i<total; i++){
				if($j("#adresse-content-"+i).height() >= 20){ $j("#adresse-label-"+i).height("36px"); }
			}
		}
		
		//购物流程
		_this.checkRule = function(fm,ftype){

			var billing_displayobj = $j("#billing-new-address-form");
			var shipping_displayobj = $j("#shipping-new-address-form");
			
			if((ftype == "billing" && billing_displayobj.attr("style") != "display: none;") ||
				(ftype == "shipping" && shipping_displayobj.attr("style") != "display: none;")){
			
			var frm = $j("#"+fm)[0];
			if(ftype == "billing"){
			var zipcode = frm.elements['billing[postcode]'] ? Utils.trim(frm.elements['billing[postcode]'].value) : '';
			var zipcodeobj = $j(frm.elements['billing[postcode]']);
			var telephone = frm.elements['billing[telephone]'] ? Utils.trim(frm.elements['billing[telephone]'].value) : '';
			var telephoneobj = $j(frm.elements['billing[telephone]']);
			}else if(ftype == "shipping"){
			var zipcode = frm.elements['shipping[postcode]'] ? Utils.trim(frm.elements['shipping[postcode]'].value) : '';
			var zipcodeobj = $j(frm.elements['shipping[postcode]']);
			var telephone = frm.elements['shipping[telephone]'] ? Utils.trim(frm.elements['shipping[telephone]'].value) : '';
			var telephoneobj = $j(frm.elements['shipping[telephone]']);			
			}
			
			var err = 0;
			
			if (zipcode.length == 5)
			{
				if(!Utils.isNumber(zipcode)){
					$j(zipcodeobj.nextAll()[0]).remove();
					zipcodeobj.addClass("validation-failed");
					zipcodeobj.after("<div class='validation-advice'>S'il vous plaît entrer les 5 chiffres.</div>");
					err++;
				}else{
					zipcodeobj.removeClass("validation-failed");
					$j(zipcodeobj.nextAll()[0]).remove();
				}
			}else{
					$j(zipcodeobj.nextAll()[0]).remove();
					zipcodeobj.addClass("validation-failed");
					zipcodeobj.after("<div class='validation-advice'>S'il vous plaît entrer les 5 chiffres.</div>");
					err++;
			}
			if (telephone.length == 10)
			{
				if(!Utils.isNumber(telephone)){
					$j(telephoneobj.nextAll()[0]).remove();
					telephoneobj.addClass("validation-failed");
					telephoneobj.after("<div class='validation-advice'>S'il vous plaît entrer les 10 chiffres.</div>");
					err++;
				}else{
					telephoneobj.removeClass("validation-failed");
					$j(telephoneobj.nextAll()[0]).remove();
				}
			}else{
					$j(telephoneobj.nextAll()[0]).remove();
					telephoneobj.addClass("validation-failed");
					telephoneobj.after("<div class='validation-advice'>S'il vous plaît entrer les 10 chiffres.</div>");	
					err++;
			}
			if(err == 0){
				return true;
			}else{
				return false;
			}
			}else{
				return true;
			}
		}
	})(MC);
