var currentShow;

function ShowCopy(FieldName, selectRightClass, backupFieldName1,backupFieldName2)
{
	var showElement = document.getElementById(FieldName);
	
	// if the first field name has no content then default to the first backup
	if (showElement.innerHTML == ""){
		FieldName = backupFieldName1;
		showElement = document.getElementById(FieldName);
	}	
	// if the second field name has no content then default to the second backup
	if (showElement.innerHTML == ""){
		FieldName = backupFieldName2;
		showElement = document.getElementById(FieldName);
	}
	
	if(showElement.style.display=="none")
	{
		showElement.style.display="inline";
		document.getElementById(FieldName + "_Link").style.fontWeight="bold";
		if ((FieldName != currentShow) && (currentShow != undefined)){
			document.getElementById(currentShow).style.display="none";
			document.getElementById(currentShow + "_Link").style.fontWeight="normal";
		}
		if((selectRightClass != "") && (selectRightClass != undefined))
			document.getElementById("selectalookright").className = selectRightClass;
		else
			document.getElementById("selectalookright").className = "";
	}
	currentShow = FieldName;
}

function HideCopy(FieldName){
	var arrList = new Array("Style", "Cut", "Color");
	
	for(var i = 0;i<arrList.length;i++)
	{
		// find the first valid item on th page and show
		if(isObject(document.getElementById(arrList[i])))
		{
			currentShow = arrList[i];
			document.getElementById(arrList[i] + "_Link").style.fontWeight="bold";
			document.getElementById(arrList[i]).style.display="inline";
			break;
		}
	}
}

function isObject(a) {
    return a && typeof a == 'object';
}

function openPopup(url, name, popupWidth, popupHeight) {
	var winl = (screen.width - popupWidth) / 2;
	var wint = (screen.height - popupHeight) / 2;
	var name2 = name.replace(' ','');
	name2=name2.replace('-','');
		
	newWindow = open(url, name2, ("toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,top=" + wint + ",left=" + winl + ",width=" + popupWidth + ",height=" + popupHeight + "\""));
	newWindow.focus();
}

// Insère un élément flash dans la page selon les paramètres reçus
// Évite d'avoir à cliquer sur l'élément flash pour pouvoir l'utiliser dans Internet Explorer
function insertFlash(movie, quality, width, height, bgcolor, menu, version, title)
	{
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+version+",0,0,0' width='"+width+"' height='"+height+"' title='"+title+"'>");
	document.write("<param name='movie' value='"+movie+"' />");
	document.write("<param name='quality' value='"+quality+"' />");
	document.write("<param name='menu' value='"+menu+"' />");
	document.write("<param name='bgcolor' value='#"+bgcolor+"' />");;
	document.write("<param name='wmode' value='opaque'>");

	document.write("<embed src='"+movie+"' wmode='opaque' quality='"+quality+"' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' menu='"+menu+"' bgcolor='#"+bgcolor+"' width='"+width+"' height='"+height+"'></embed>");
	document.write("</object>");
	}

var SalonURL="";
function AddWebSiteURL(url,className,urlName){
	SalonURL = "<a href='" + url + "' target='_blank' class='" + className + "'>" + urlName + "</a>";  
}

function validateDate()
{
	var mf = GetMainFormName();
	var monthTextboxName = GetElementName("birthmonth", mf);
	var dayTextboxName = GetElementName("birthday", mf);
	var yearTextboxName = GetElementName("birthyear", mf);
	
	/*PJ:Check if the object exists before manipulating the values */
	if(monthTextboxName != null && dayTextboxName != null && yearTextboxName != null)
	{	var monthTextbox =  document.forms[mf].elements[monthTextboxName];
		var dayTextbox	=  document.forms[mf].elements[dayTextboxName];
		var yearTextbox =  document.forms[mf].elements[yearTextboxName];
		
		/*PJ:Check if the object exists before manipulating the values */
		if(monthTextbox != null && dayTextbox != null && yearTextbox != null)
		{
			if (monthTextbox.value =='MM' && dayTextbox.value =='DD' && yearTextbox.value=='YYYY')
			{
				monthTextbox.value ='';
				dayTextbox.value ='';
				yearTextbox.value ='';
			}
		}
	}
}		