﻿// JScript File
with(milonic=new menuname("search")){		
style=menuStyle;
/*aI("text=`<form method='post' action='/includes/email_friend.asp' name='email' ID='email'><table width=150><tr><td class=email>Email this Page to a Friend:</td></tr><tr><td class=email>Your eMail Address:<br><input type='text' name='EMVAR6' size=24 class=textb><br>Friends eMail Address:<br><input type='text' name='EMTO' size='24' class=textb><input type=hidden name='MM_insert' value='email'></td></tr><tr><td><input type=submit value='Send' class=btn></td></tr></table></form>`;type=form;align=center;onbgcolor=;onborder=;");*/
aI("text=`<div><table width=150><tr><td class=email>Email this Page to a Friend:</td></tr><tr><td class=email>Your eMail Address:<br><input type='text' id='EMVAR6' name='EMVAR6' size='24' class='textb' onkeypress='checkEnter(event)'><br>Friends eMail Address:<br><input type='text' id='EMTO' name='EMTO' size='24' class='textb' onkeypress='checkEnter(event)'></td></tr><tr><td><input type=button value='Send' id='btnSendEmailFriend' class=btn onclick='emailFriend();'></td></tr></table></div>`;type=form;align=center;onbgcolor=;onborder=;");
}

function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}


function checkEnter(e){ //e is event object passed from function invocation
    var characterCode //literal character code will be stored in this variable

    if(e && e.which){ //if which property of event object is supported (NN4)
        e = e;
        characterCode = e.which; //character code is contained in NN4's which property
    } else {
        e = event;
        characterCode = e.keyCode; //character code is contained in IE's keyCode property
    }

    if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
        emailFriend(); //submit the form
        return false ;
    } else {
        return true ;
    }
    
}


function emailFriend() {
  var EMVAR6 = document.getElementById('EMVAR6');
  var EMTO = document.getElementById('EMTO');
  var MM_insert = 'email';
  var EMREF = window.location.href;
  window.location.href='/includes/email_friend.asp?EMTO=' + EMTO.value + '&EMVAR6=' + EMVAR6.value + '&MM_insert=email&EMREF=' + URLEncode(EMREF);
}


