function getid(id) {
	if ( document.getElementById ) {
		value = document.getElementById(id);
		}
	else if ( document.all ) {
		value = document.all[id];
		}
	else if ( document.layers ) {
		value = document.layers[id];
		}
	return value;
	}

function view(id) {
	if ( document.getElementById ) {
		document.getElementById(id).style.display = ( document.getElementById(id).style.display == "block" ) ? "none" : "block";
		}
	else if ( document.all ) {
		document.all[id].style.display = ( document.all[id].style.display == "block" ) ? "none" : "block";
		}
	else if ( document.layers ) {
		document.layers[id].display = ( document.layers[id].display == "block" ) ? "none" : "block";
		}
	}

function onlyhide(id) {
	if ( document.getElementById ) {
		document.getElementById(id).style.display = "none";
		}
	else if ( document.all ) {
		document.all[id].style.display = "none";
		}
	else if ( document.layers ) {
		document.layers[id].display = "none";
		}
	}

function onlyshow(id) {
	if ( document.getElementById ) {
		document.getElementById(id).style.display = "block";
		}
	else if ( document.all ) {
		document.all[id].style.display = "block";
		}
	else if ( document.layers ) {
		document.layers[id].display = "block";
		}
	}

function changeimage(id, value) {
	var div = getid(id);
	div.src = value;
	}

function showhome(id, max) {
	for ( i=1; i<=max; i++ ) {
		onlyhide('link'+i);
		onlyhide('desc'+i);
		onlyhide('img'+i);
		onlyhide('price'+i);
		}
	onlyshow('link'+id);
	onlyshow('desc'+id);
	onlyshow('img'+id);
	onlyshow('price'+id);
	}

function showhomephotos(id) {
	onlyhide('descphotos1');
	onlyhide('descphotos2');
	onlyhide('descphotos3');
	onlyhide('descphotos4');
	onlyhide('descphotos5');
	onlyshow('descphotos'+id);
	}

function getvalue(id) {
	var div = getid(id);
	return div.value;
	}

function changevalue(id, value) {
	var div = getid(id);
	div.value = value;
	}

function getinnerhtml(id) {
	var div = getid(id);
	return div.innerHTML;
	}

function changeinnerhtml(id, value) {
	var div = getid(id);
	div.innerHTML = value;
	}

function changeheight(id1, id2) {
	var div1 = getid(id1);
	var div2 = getid(id2);
	alert(div1);
	alert(div2);
	div1.style.height = div2.style.height+"px";
	}

function defilnews(nb, t) {
	nt = ( t == -35*nb-1 ) ? 0 : t-1;
	div = getid("defilnews");
	if ( t==0 || t==-36 || t==-71 || t==-106 || t==-142 ) {
		window.setTimeout("defilnews("+nb+", "+nt+")", 3000);
		}
	else {
		window.setTimeout("defilnews("+nb+", "+nt+")", 20);
		}
	div.style.top = t+"px";
	}

function connexion() {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		return true;
		}
	xhr_object.open("POST", "/connexion.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	form = getinnerhtml("textlogin");
	formlogin = getvalue("formlogin");
	formpassword = getvalue("formpassword");
	var vars = "ajax=ajax&login="+formlogin+"&password="+formpassword;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			if ( xhr_object.responseText == 1 ) {
				window.location.replace(window.location);
				}
			else {
				changeinnerhtml("textlogin", xhr_object.responseText);
				window.setTimeout("changeinnerhtml('textlogin', form)", 2000);
				}
			}
		}
	return false;
	}

function connexion2() {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		return true;
		}
	xhr_object.open("POST", "/connexion.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	form = getinnerhtml("textlogin2");
	formlogin = getvalue("formlogin2");
	formpassword = getvalue("formpassword2");
	var vars = "ajax=ajax2&login="+formlogin+"&password="+formpassword;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			if ( xhr_object.responseText == 1 ) {
				window.location.replace(window.location);
				}
			else {
				changeinnerhtml("textlogin2", xhr_object.responseText);
				window.setTimeout("changeinnerhtml('textlogin2', form)", 2000);
				}
			}
		}
	return false;
	}

function addcart(form) {
	var p = form.product.value;
	var s = form.size.value;
	var c = form.color.value;
	var q = form.qte.value;
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		return true;
		}
	xhr_object.open("POST", "/cart.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "action=add&product="+p+"&size="+s+"&color="+c+"&qte="+q;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			if ( xhr_object.responseText != 0 ) {
				var response = xhr_object.responseText.split("|");
				changeinnerhtml("cart_nb", response[0]);
				changeinnerhtml("cart_total", response[1]);
				alert("Produit ajouté au panier");
				}
			}
		}
	return false;
	}

function submithis(form) {
	var str = form.q.value;
	if (str != "") {
		if ( form.w.value == "google" ) {
			str = "google-"+str;
			}
		var str = str.toLowerCase();
		var str = cleanString(str);
		newLocation = "/recherche/"+str+".html";
		document.location = newLocation;
		}
	return false;
	}

function replaceAll(str, search, repl) {
	while ( str.indexOf(search) != -1 ) {
		str = str.replace(search, repl);
		}
	return str;
	}

function vote(id) {
	for ( i=1; i<6; i++ ) {
		changeimage("vote"+i, "img/vote-off.gif");
		}
	for ( i=1; i<id+1; i++ ) {
		changeimage("vote"+i, "img/vote-on.gif");
		}
	}

function sendvote(note, page, id) {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre système de vote...");
		return;
		}
	xhr_object.open("POST", "/"+page, true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "note="+note;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			changeinnerhtml(id, xhr_object.responseText);
			}
		}
	}

function getchrono(concours, user) {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre système de vote...");
		return;
		}
	xhr_object.open("POST", "/concours/"+concours+"/validation.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "getchrono=1&user="+user;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			changeinnerhtml("concours_validation", xhr_object.responseText);
			}
		}
	}

function setchrono(concours, user, valide) {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre système de vote...");
		return;
		}
	var voiture = getvalue('voiture');
	var message = getvalue('message');
	var time_minutes = getvalue('minutes');
	var time_secondes = getvalue('secondes');
	var time_centiemes = getvalue('centiemes');
	xhr_object.open("POST", "/concours/"+concours+"/validation.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = ( valide == 1 ) ? "setchrono=1&user="+user+"&voiture="+voiture+"&minutes="+time_minutes+"&secondes="+time_secondes+"&centiemes="+time_centiemes : "setchrono=1&user="+user+"&message="+message+"&delete=1";
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			changeinnerhtml("concours_validation", "");
			updatepage("/concours/"+concours+"/validation.html", "scroll_classement_content");
			getchrono(concours, xhr_object.responseText);
			initScrollLayers(1);
			}
		}
	}

function updatepage(url, div) {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre système de vote...");
		return;
		}
	xhr_object.open("POST", url, true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "update=1";
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			changeinnerhtml(div, xhr_object.responseText);
			}
		}
	}

function sendallopass(id, site, doc, code, page) {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec cette option...");
		return;
		}
	changeinnerhtml(id, "<p class=\"confirm\">Envoi des données...</p>");
	xhr_object.open("POST", page, true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "SITE_ID="+site+"&DOC_ID="+doc+"&RECALL=1&CODE0="+code;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			changeinnerhtml(id, xhr_object.responseText);
			}
		}
	}

function showchat() {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre chat...");
		return;
		}
	xhr_object.open("POST", "/chat.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "chat=show";
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			if ( xhr_object.responseText == 1 ) {
				onlyview("chat");
				view2("showchat");
				view2("hidechat");
				getid("chat_connexion").style.left = "562px";
				getid("chat_connexion").style.width = "413px";
				updatechat();
				}
			else {
				onlyview("chat_error");
				}
			}
		}
	}

function hidechat() {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre chat...");
		return;
		}
	xhr_object.open("POST", "/chat.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "chat=hide";
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			view("chat");
			view2("showchat");
			view2("hidechat");
			getid("chat_connexion").style.left = "819px";
			getid("chat_connexion").style.width = "156px";
			}
		}
	}

function updatechat() {
	var time = 1000;
	var div = "chat_content";
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible avec notre chat...");
		return;
		}
	xhr_object.open("POST", "/chat.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "chat=update&div="+div;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			if ( xhr_object.responseText != 0 ) {
				if ( changeinnerhtml ) {
					changeinnerhtml(div, xhr_object.responseText);
					getid("chat_content").style.top = 135-getid("chat_content").offsetHeight+"px";
					}
				window.setTimeout("updatechat()", time);
				}
			}
		}
	}

function zoomlist(id, color, img) {
	var xhr_object = null;
	if ( window.XMLHttpRequest )
		xhr_object = new XMLHttpRequest();
	else if ( window.ActiveXObject )
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {
		alert("Votre navigateur n'est pas compatible...");
		return;
		}
	xhr_object.open("POST", "/zoomlist.html", true);
	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var vars = "id="+id+"&color="+color+"&img="+img;
	xhr_object.send(vars);
	xhr_object.onreadystatechange = function() {
		if ( xhr_object.readyState == 4 ) {
			result = xhr_object.responseText.split("#|#");
			changeinnerhtml("zoomlist", result[0]);
			zoom(result[1], result[2]);
			}
		}
	}

function cleanString(sStr) {
	var out = "";
	var spec = new Array("é", "è", "ê", "ë", "à", "â", "ä", "ù", "û", "ü", "ì", "î", "ï", "ò", "ô", "ö");
	var norm = new Array("e", "e", "e", "e", "a", "a", "a", "u", "u", "u", "i", "i", "i", "o", "o", "o");
	for ( var i=0; i<spec.length; i++ ) {
		sStr = replaceAll(sStr, spec[i], norm[i]);
		}
	for ( i=0; i<sStr.length; i++ ) {
		out += ( charcheck(sStr.charAt(i)) ) ? sStr.charAt(i) : "-";
		}
	out = escape(out);
	return out;
	}

function charcheck(keychar) {
	ret = ( ("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1 ) ? true : false;
	return ret;
	}

function updatecheck(id, num, hide, value) {
	if ( num == 1 ) {
		document.getElementById(id+"1").style["background"] = "url('img/selected-on.gif') no-repeat 3px 1px";
		document.getElementById(id+"2").style["background"] = "url('img/selected-off.gif') no-repeat 3px 1px";
		}
	else {
		document.getElementById(id+"1").style["background"] = "url('img/selected-off.gif') no-repeat 3px 1px";
		document.getElementById(id+"2").style["background"] = "url('img/selected-on.gif') no-repeat 3px 1px";
		}
	changevalue(hide, value);
	}

function screenshots2(img, blank) {
	titre = 'Wearing';
	w = open("", "image", "width=400, height=400, toolbar=no, scrollbars=no, resizable=no");
	w.document.write("<html><head><title>"+titre+"</title>");
	w.document.write("<sc"+"ript type='text/javas"+"cript'>");
	w.document.write("	function checksize() {");
	w.document.write("		if ( document.images['img'].complete ) {");
	w.document.write("			var height = document.images[0].height+35;");
	w.document.write("			var width = document.images[0].width+5;");
	w.document.write("			if ( height>screen.height ) {");
	w.document.write("				var width = (width*(screen.height-35))/height;");
	w.document.write("				var height = screen.height-35;");
	w.document.write("				document.images[0].height = height;");
	w.document.write("				}");
	w.document.write("			if ( width>screen.width-5 ) {");
	w.document.write("				var height = (height*(screen.width-5))/width;");
	w.document.write("				var width = screen.width-5;");
	w.document.write("				document.images[0].width = width;");
	w.document.write("				}");
	w.document.write("			var top = (screen.height-height)/2;");
	w.document.write("			var left = (screen.width-width)/2;");
	w.document.write("			window.moveTo(left, top);");
	w.document.write("			window.resizeTo(width, height);");
	w.document.write("			window.focus();");
	w.document.write("			}");
	w.document.write("		else {");
	w.document.write("			setTimeout('checksize()', 250)");
	w.document.write("			}");
	w.document.write("		}");
	w.document.write("	</"+"script>");
	w.document.write("</head>");
	w.document.write("<body onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0 bgcolor='#111111'>");
	img = ( blank == 1 ) ? img : "/"+img;
	w.document.write("<a href='javascript:self.close()'><img src='"+img+"' border=0 name='img' alt='"+titre+"' title='"+titre+"' /></a>");
	w.document.write("");
	w.document.write("</body></html>");
	w.document.close();
	return false;
	}

function msn() {
	titre = 'Wearing support online';
	w = open("", "msn", "width=750, height=400, toolbar=no, scrollbars=no, resizable=no");
	w.document.write("<html><head><title>"+titre+"</title>");
	w.document.write("</head>");
	w.document.write("<body leftMargin=0 topMargin=0 marginwidth=0 marginheight=0 bgcolor='#fefefe' onunload=\"window.opener.document.getElementById('msn2').style.display='none'; window.opener.document.getElementById('msn1').style.display='block'; \">");
	w.document.write("<style type=\"text/css\">");
	w.document.write("* { margin: 0; border: 0; padding: 0; }");
	w.document.write("iframe { margin-top: -76px; height: 476px; width: 749px; }");
	w.document.write("</style>");
	w.document.write("<iframe src=\"/contact/online/url\"></iframe>");
	w.document.write("</body></html>");
	w.document.close();
	return false;
	}

function screenshots(img) {
	value = '<a href="javascript:void(0)" onclick="javascript:screenclose(); return false;" class="close">Fermer</a>';
	value += '<div id="zoom">';
	value += '<div id="zoomimg"></div>';
	value += '<div id="zoomlist"></div>';
	value += '</div>';
	changeinnerhtml("screenshot", value);
	t = img.split(".");
	t = t[0].split("-");
	id = t[1];
	c = t[2];
	onlyshow("screenshot");
	onlyshow("back");
	onlyhide("wrap");
	zoomlist(id, c, img);
	return false;
	}

function screenclose() {
	onlyhide("screenshot");
	onlyhide("back");
	onlyshow("wrap");
	}

function zoom(img,color) {
	value = '<object type="application/x-shockwave-flash" id="swfzoom" data="img/zoom.swf?photo='+img+'" width="720px" height="500px">';
	value += '<param name="movie" value="img/zoom.swf?photo='+img+'" />';
	value += '<param name="menu" value="false" />';
	value += '<param name="allowfullscreen" value="true" />';
	value += '<param name="wmode" value="opaque" />';
	value += '<param name="bgcolor" value="'+color+'" />';
	value += '</object>';
	changeinnerhtml("zoomimg", value);
	}

function findPosx(obj) {
    var curleft = obj.offsetLeft || 0;
    while (obj = obj.offsetParent) {
        curleft += obj.offsetLeft
   	}
    return curleft;
}

function findPosy(obj) {
    var curtop = obj.offsetTop || 0;
    while (obj = obj.offsetParent) {
        curtop += obj.offsetTop
    }
    return curtop;
}

var W3CDOM = (document.createElement && document.getElementsByTagName);

function initFileUploads() {
	if (!W3CDOM) return;
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.appendChild(document.createElement('input'));
	var image = document.createElement('img');
	image.src='img/bbcode-browse.gif';
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for ( var i=0;i<x.length;i++ ) {
		if ( x[i].type == 'file' ) {
			if ( x[i].parentNode.className != 'fileinputs' ) continue;
			x[i].className = 'file';
			var clone = fakeFileUpload.cloneNode(true);
			x[i].parentNode.appendChild(clone);
			x[i].relatedElement = clone.getElementsByTagName('input')[0];
			x[i].onchange = x[i].onmouseout = function () {
				this.relatedElement.value = this.value;
				}
			}
		}
	}

function SetFocus(TargetFormName) {
  var target = 0;
  if (TargetFormName != "") {
    for (i=0; i<document.forms.length; i++) {
      if (document.forms[i].name == TargetFormName) {
        target = i;
        break;
      }
    }
  }

  var TargetForm = document.forms[target];

  for (i=0; i<TargetForm.length; i++) {
    if ( (TargetForm.elements[i].type != "image") && (TargetForm.elements[i].type != "hidden") && (TargetForm.elements[i].type != "reset") && (TargetForm.elements[i].type != "submit") ) {
      TargetForm.elements[i].focus();

      if ( (TargetForm.elements[i].type == "text") || (TargetForm.elements[i].type == "password") ) {
        TargetForm.elements[i].select();
      }

      break;
    }
  }
}

function RemoveFormatString(TargetElement, FormatString) {
  if (TargetElement.value == FormatString) {
    TargetElement.value = "";
  }

  TargetElement.select();
}

function CheckDateRange(from, to) {
  if (Date.parse(from.value) <= Date.parse(to.value)) {
    return true;
  } else {
    return false;
  }
}

function IsValidDate(DateToCheck, FormatString) {
  var strDateToCheck;
  var strDateToCheckArray;
  var strFormatArray;
  var strFormatString;
  var strDay;
  var strMonth;
  var strYear;
  var intday;
  var intMonth;
  var intYear;
  var intDateSeparatorIdx = -1;
  var intFormatSeparatorIdx = -1;
  var strSeparatorArray = new Array("-"," ","/",".");
  var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  strDateToCheck = DateToCheck.toLowerCase();
  strFormatString = FormatString.toLowerCase();

  if (strDateToCheck.length != strFormatString.length) {
    return false;
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
      intFormatSeparatorIdx = i;
      break;
    }
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
      intDateSeparatorIdx = i;
      break;
    }
  }

  if (intDateSeparatorIdx != intFormatSeparatorIdx) {
    return false;
  }

  if (intDateSeparatorIdx != -1) {
    strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
    if (strFormatArray.length != 3) {
      return false;
    }

    strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
    if (strDateToCheckArray.length != 3) {
      return false;
    }

    for (i=0; i<strFormatArray.length; i++) {
      if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm') {
        strMonth = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'dd') {
        strDay = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'yyyy') {
        strYear = strDateToCheckArray[i];
      }
    }
  } else {
    if (FormatString.length > 7) {
      if (strFormatString.indexOf('mmm') == -1) {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mm'), 2);
      } else {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mmm'), 3);
      }

      strDay = strDateToCheck.substring(strFormatString.indexOf('dd'), 2);
      strYear = strDateToCheck.substring(strFormatString.indexOf('yyyy'), 2);
    } else {
      return false;
    }
  }

  if (strYear.length != 4) {
    return false;
  }

  intday = parseInt(strDay, 10);
  if (isNaN(intday)) {
    return false;
  }
  if (intday < 1) {
    return false;
  }

  intMonth = parseInt(strMonth, 10);
  if (isNaN(intMonth)) {
    for (i=0; i<strMonthArray.length; i++) {
      if (strMonth == strMonthArray[i]) {
        intMonth = i+1;
        break;
      }
    }
    if (isNaN(intMonth)) {
      return false;
    }
  }
  if (intMonth > 12 || intMonth < 1) {
    return false;
  }

  intYear = parseInt(strYear, 10);
  if (isNaN(intYear)) {
    return false;
  }
  if (IsLeapYear(intYear) == true) {
    intDaysArray[1] = 29;
  }

  if (intday > intDaysArray[intMonth - 1]) {
    return false;
  }

  return true;
}

function IsLeapYear(intYear) {
  if (intYear % 100 == 0) {
    if (intYear % 400 == 0) {
      return true;
    }
  } else {
    if ((intYear % 4) == 0) {
      return true;
    }
  }

  return false;
}