
<!--
//Default status message
defaultStatus="seraphine.com";
// Google toolbar auto fill fix 
if(window.attachEvent)
	window.attachEvent("onload",setListeners);

function setListeners(){
	inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
    	inputList[i].attachEvent("onpropertychange",restoreStyles);
      	inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
    	selectList[i].attachEvent("onpropertychange",restoreStyles);
      	selectList[i].style.backgroundColor = "";
    }
}

function restoreStyles(){
	if(event.srcElement.style.backgroundColor != "")
    event.srcElement.style.backgroundColor = "";
}
// End google bar fix  
// Matrix submit function
function MXSub(intFieldsToSubmit, strSizeFieldID, intSizeID, strColourFieldID, intColourID){
	//alert('size field is ' + strSizeFieldID + '.size id is=' + intSizeID + '\r colour field is : ' + strColourFieldID + ' colour id is : ' + intColourID );
	//alert(intFieldsToSubmit);
	// get handles on the fields we want to manipulate
	var sizeField = document.getElementById(strSizeFieldID);
	var colourField = document.getElementById(strColourFieldID);
	// only attempt to update fields we know exist
	if(intFieldsToSubmit == 1){
		sizeField.value = intSizeID;
	} else if(intFieldsToSubmit == 2){
		colourField.value = intColourID;
	}else{
		sizeField.value = intSizeID;
		colourField.value = intColourID;
	}

	document.forms['additem'].submit();
}
function MXSubV02(intFieldsToSubmit, strSizeFieldID, intSizeID, strColourFieldID, intColourID, dblPromoPrice){
	//alert('size field is ' + strSizeFieldID + '.size id is=' + intSizeID + '\r colour field is : ' + strColourFieldID + ' colour id is : ' + intColourID );
	//alert(intFieldsToSubmit);
	// get handles on the fields we want to manipulate
	var sizeField = document.getElementById(strSizeFieldID);
	var colourField = document.getElementById(strColourFieldID);
	var promoPriceField = document.getElementById('PromoPrice');
	// only attempt to update fields we know exist
	if(intFieldsToSubmit == 1){
		sizeField.value = intSizeID;
	} else if(intFieldsToSubmit == 2){
		colourField.value = intColourID;
	}else{
		sizeField.value = intSizeID;
		colourField.value = intColourID;
	}
	promoPriceField.value = dblPromoPrice;
	
	document.forms['additem'].submit();
}
//Field Functions
//Gets the selected value from a select field
function getSelected( theField )
{
 var aSelection = null
 for (var i = 0; i < theField.length; i++)
   {
    if (theField.options[i].selected)
     {
     if ( theField.selectedIndex > 0 )
       {
       aSelection = theField.options[i].text
       }
       else
       {
       aSelection = null
     }
   }
 }
 return (aSelection) ;
}
//Changes a vields content to uppercase
function makeUppercase (theField)
{
 var capString = theField.value.toUpperCase() ;
 theField.value = capString;
 return (true) ;
}
//Gets the selected value of a select box field
function getSelectedText( theField )
{
 var aSelection = null
 for (var i = 0; i < theField.length; i++)
   {
    if (theField.options[i].selected)
     {
     if ( theField.selectedIndex > 0 )
       {
       aSelection = theField.options[i].text ;
       }
       else
       {
       aSelection = "" ;
       }
     }
    }
 return aSelection ;
}
//Gets the selected value of a radio button field
function getRadioValue ( theField )
{
 var aSelection = null ;
 for (var i = 0; i < theField.length; i++)
 {
    if (theField[i].checked)
   {
      aSelection = theField[i].value
    }
   }
  return aSelection ;
 }
//String functions
//Finds the middle of a string when passed a start and end search point
function Middle(fullString, startString, endString) 
{
  var startPosition = fullString.indexOf(startString) ;
  var startLen = startString.length ;
  if(startPosition > -1 && startString != "")
  { 
    var temp = fullString.substring(startPosition + startLen, fullString.length) ; 
    endPosition = temp.indexOf(endString) + startPosition + startLen; 
    startPosition + startLen ; 
 
    if(endPosition> -1 && temp.indexOf(endString) > -1 ) 
    { 
      return(fullString.substring(startPosition + startLen , endPosition )) 
    }
    else
    {
      return(fullString.substring ( startPosition + startLen, fullString.length ))
    }
  }
  else
  {
    return(" ") ;
  }
}
//Change spaces to underscores
function uScoreSpaces( freetext )
{
 freetextList = freetext.split(" ") ;
 var freetextuScore = ""
 if( freetextList.length > 1)
 {
 freetextuScore = freetextList[0]
 for (var i = 1; i < freetextList.length; i++)
   {
   freetextuScore += "+" + freetextList[i]
   }
  }
  else
  {
    freetextuScore = freetext
   }
   return(freetextuScore)
}
// remove leading/trailing spaces
function trim(aStr)
{
  return aStr.replace(/^\s{1,}/, "").replace(/\s{1,}$/, "")
}
//replace one or more spaces with plus signs
function plusSpaces( aStr )
{
  trim(aStr) ;
  return (aStr.replace(/\s{1,}/g, "+"));
}
//Removes spaces from the string passed
function removeSpaces(str)
{
  return (aStr.replace(/\s{1,}/g, ""));
}
//Puts the joiner on the end of the string passed
function addJoiner( searchString )
{
 if( searchString == "" )
   {
   joiner = ""
   }
 else
   {
   joiner = "+and+"
   }
 return( joiner ) ;
}
//**********The utility functions
//Reloads the page on Nav4 resize
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//Bookmark functions
//Makes the page a favorite but for ie only
function makeFavorite(Title)
{
  if (window.external)
  {
    external.AddFavorite(location.href, Title)
  }
  else
  {
    alert("Sorry, your browser doesn't support this feature.\n" +
    "If you are using Netscape Navigator, click Bookmarks\n" +
    "and then Add Bookmark to add this site to your favorites\n" +
    "or press CTRL-D.");
  }
}
//Make this your homepage function ie only
function makeHP()
{
  alert('start');
  this.style.behavior='url(#default#homepage)';
  this.setHomePage('http://www.seraphine.com');
}
//Cookie handling functions
//Gets a cookies value - ued internally - use get cookie !
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
//Used to get the actual data
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}
//Used to set the cookie data
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
//**********Image functions
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//Used to display status messages to the status bar i.e. only
function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

/**
 * Update counter widget with number of characters remaining
 * @param string counter id of counter element
 * @param string text_elem id of textarea or input element
 * @param int    max_len maximum allowed character length
 * @return void
 */
function update_counter(counter, text_elem, max_len)
{
    var counterElem = document.getElementById(counter);
    var textElem = document.getElementById(text_elem);
    var len = textElem.value.length;
    var val = max_len - textElem.value.length;
    counterElem.innerHTML = val; 
}

/**
 * Verify that elem_id doesn't contain more than max_len characters
 * @param string elem_id id of elem to count characters in
 * @param int    max_len maxmimum input string (including spaces and returns)
 * @return boolean
 */
function check_content_length(elem_id, max_len)
{
    var elem = document.getElementById(elem_id);
    if(elem.value.length > max_len) {
        return false;
    }
    return true;
}
// -->
