function bookmark()
{
    var title = 'Hardrock - ' + document.title;
    var url = location.href;

    if (window.sidebar)
		window.sidebar.addPanel(title, url,"");
    else if ( window.opera && window.print )
    {
		var mbm = document.createElement('a');
		mbm.setAttribute('rel','sidebar');
		mbm.setAttribute('href',url);
		mbm.setAttribute('title',title);
		mbm.click();
    }
    else if (document.all)
		window.external.AddFavorite( url, title);

}

function emailtofriendForm(theForm) {
  allCorrect=true ;
  
  if (theForm.FriendName.value=="" || 
      theForm.FriendEmail.value=="" ||
	  theForm.Name.value=="" ||
	  theForm.Email.value=="" ) {
    allCorrect=false ;
  }
  if (allCorrect==false)
  {
    alert("Please fill in all fields marked *") ;
	return false ;
  } 
}
/***************************************
	Required Functions For Images
***************************************/
function modalDialogShow_IEC(url,width,height) //IE
	{
	return window.showModalDialog(url,window,
		"dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:Yes;help:No;Resizable:Yes;Maximize:Yes");
	}
function modalDialogShow_MozC(url,width,height) //Moz
	{
	var left = screen.availWidth/2 - width/2;
	var top = screen.availHeight/2 - height/2;
	activeModalWin = window.open(url, "", "width="+width+"px,height="+height+",left="+left+",top="+top);
	window.onfocus = function(){if (activeModalWin.closed == false){activeModalWin.focus();};};
	}
var sActiveAssetInputC;
function setAssetValueC(v) //required by the asset manager
	{
		if (v != '') {
			v = v.replace('/shop/img/shop/', '');
			v = v.replace('/shop/pdf/', '');
			document.getElementById(sActiveAssetInputC).value = v;
		}
	}
function openAssetC(s)
	{
	sActiveAssetInputC = s
	if(navigator.appName.indexOf('Microsoft')!=-1) {
		v = modalDialogShow_IEC("/wysiwyg/assetmanager/assetmanagerI.asp",740,565); //IE
		if (v != '')
			document.getElementById(sActiveAssetInputC).value=v;
	}
	else
		modalDialogShow_MozC("/wysiwyg/assetmanager/assetmanagerI.asp",740,565); //Moz	
	}
/*****************************************/

function FlashControl(ClsId,Url,Width,Height,AutoStart)
{
	document.write('<object classid="' + ClsId + '" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + Width + '" height="' + Height + '">')
	document.write('<param name="movie" value="' + Url + '">')							  
	document.write('<param name="wmode" value="Transparent">')
	document.write('<param name="quality" value="high">')
	document.write('<embed src="' + Url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + Width + '" height="' + Height + '" wmode="Transparent"></embed>')
	document.write('</object>')
}

function showHelp(OptionId,Type) {
	mywindow=open('/inc/admin_help.asp?HelpType='+Type+'&OptionId='+OptionId,'helpWindow','scrollbars=yes,resizable=yes,width=800,height=350');
	mywindow.location.href = '/inc/admin_help.asp?HelpType='+Type+'&OptionId='+OptionId;
	if (mywindow.opener == null) {
		mywindow.opener = self;
	}
	mywindow.focus();
}

/* Check filename function*/
function checkFilename(theField) {
  blnPass = true;
  strValue = theField.value;
  for(i=0; i<theField.value.length; i++){
	if ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_".indexOf(theField.value.charAt(i),0) == -1) {
		//alert(theField.value.charAt(i));
	 	if(theField.value.charAt(i) == ' ')
			strValue = strValue.replace(theField.value.charAt(i),'_');
		else
			strValue = strValue.replace(theField.value.charAt(i),'');
		blnPass = false;
	}
  }
  theField.value = strValue;
  if (!blnPass) {
	alert("A file must be only alpha or numeric characters. \nThe file has been automatically updated.") ;
	return false ;
  }
  return true ;
}

function showW(theId){
	document.getElementById(theId).style.display = '';
}

function hideW(theId){
	document.getElementById(theId).style.display = 'none';
}

function toggle(showthis,hidethis){
	document.getElementById(showthis).style.display = '';
	document.getElementById(hidethis).style.display = 'none';
}

function toggleClass(thison,thisoff){
	document.getElementById(thison).className = 'on';
	document.getElementById(thisoff).className = 'off';
}

function showHide(theElement){
	if (document.getElementById(theElement).style.display == '')
		document.getElementById(theElement).style.display = 'none';
	else
		document.getElementById(theElement).style.display = '';
}

/* Validation function for purchase form mainly used for options */
function ValidateBuyForm(theForm) {
	var radioChecked, strClass, radioValue;
	for(i=0; i<theForm.elements.length; i++) {
		strId = theForm.elements[i].id.substring(0, 8);
		if (strId == 'Required') {
			if (theForm.elements[i].type == 'radio' || theForm.elements[i].type == 'checkbox') {
				radioObject = theForm.elements[i];
				radioChecked = false;
				for(r=0;r<radioObject.length; r++){
					if (radioObject[r].checked)
						radioChecked = true;
				}
				if (!radioChecked) {
					alert('Please check an option for ' + theForm.elements[i].id.substring(8) + '.');
					theForm.elements[i].className = 'FlashBG';
					return false;
				}
			}
			else if (theForm.elements[i].type == 'select-one') {
				if (theForm.elements[i].selectedIndex == 0) {
					alert('Please select a value for ' + theForm.elements[i].id.substring(8) + '.');
					return false;
				}
			}
			else {
				if (theForm.elements[i].value == '') {
					alert('Please fill in a value for ' + theForm.elements[i].id.substring(8) + '.');
					return false;
				}
			}
		}
	}
}
/* Generic check checkbox function*/
function selectCheckbox(strID) {
	document.getElementById(strID).checked = true;
}

/* Generic check email function*/
function checkEmail(emailAddy) {
  if (emailAddy.value.length==0)
  {
    return true ;
  }
  if (emailAddy.value.indexOf("@",0) < 1 || emailAddy.value.indexOf(".",0) < 1)
  {
    alert("Please check the field:\n The email address appears incorrectly formed") ;
    emailAddy.focus() ;
	return false ;
  }
  return true ;
}

function nospam(user,domain,suffix) {
	document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
}

/* Function to check if year is valid ie. Initial value of "Year" or otherwise it must be a   numeric. Don't worry if the person believes they are a few centuries old! */
function checkYear(numberField) {
  allNumeric=true ;
  if (numberField.value.length==0 || numberField.value=="Year")
  {
    return true ;
  }

  for (i=0 ; i<numberField.value.length ; i++)  {    checkChar=numberField.value.charAt(i) ;
    if (checkChar<'0' || checkChar>'9')
	{
	  allNumeric=false ;
	}  
  }
  
  if (allNumeric==false)
  {
    alert("Please check the field:\n Only numbers permitted");
	numberField.focus() ;
	return false ;
  }
  
  return true ;
}

/* generic check for currency(ie 0-9 and .) */
function checkCurrency(currencyField) {
  allNumeric=true ;
  if (currencyField.value.length==0)
  {
	currencyField.value = '0.00';
	return true ;
  }
  for (i=0 ; i<currencyField.value.length ; i++)  {
	checkChar=currencyField.value.charAt(i) ;
    if (checkChar < '0' || checkChar > '9') {
		if (checkChar!='.')
			allNumeric=false ;
	}
  }
  if (allNumeric==false)
  {
    alert("Please check the field:\n Only a currency value is permitted");
	currencyField.value = '0.00';
	currencyField.focus();
	return false ;
  }
  return true ;
}

/* generic check for number(ie 0-9) */
function checkNumber(numberField) {
  allNumeric=true ;
  if (numberField.value.length==0)
  {
    return true ;
  }

  for (i=0 ; i<numberField.value.length ; i++)  {    checkChar=numberField.value.charAt(i) ;
    if ((checkChar<'0' || checkChar>'9') && checkChar!='.')
	{
	  allNumeric=false ;
	}  
  }
  
  if (allNumeric==false)
  {
    alert("Please check the field:\n Only numbers permitted");
	numberField.value = "";
	numberField.focus(numberField);
	return false ;
  }
  return true ;
}

/* generic phone number checker allowing brackets for prefix */
function checkPhone(phoneField) {
  allNumeric=true ;
  if (phoneField.value.length==0)
  {
    return true ;
  }
  
  for (i=0 ; i<phoneField.value.length ; i++)  {    checkChar=phoneField.value.charAt(i) ;
    if (checkChar!=' ' && checkChar!='\(' && checkChar!='\)'  && (checkChar<'0' || checkChar>'9') )
	{
	  allNumeric=false ;
	}  
  }
  
  if (allNumeric==false)
  {
    alert("Please check the field:\n Only numbers, spaces and \(\) permitted");
	phoneField.focus() ;
	return false ;
  }
  return true ;
}

//confirm delete message
function confirmDelete(theMessage,theDirect) {
  if( confirm(theMessage) ) {
    canClose = false;
 	document.location.replace(theDirect);
  }
}

function myfunc()
{
	document.location.href=document.fmSearch.strSearchType.options[document.fmSearch.strSearchType.selectedIndex].value + "?strKeyword=" + document.fmSearch.strKeyword.value;
	return false;
}

function activate(showthis, iconshow, iconhide){
		if (document.getElementById(showthis).style.display == '')
			document.getElementById(showthis).style.display = 'none';
		else
			document.getElementById(showthis).style.display = '';
			
		if (iconshow != null){
			document.getElementById(iconshow).style.display = '';
			document.getElementById(iconhide).style.display = 'none';
		}
	}
	function initialise(hidethis, display){
		if (display == 'hide'){
			//alert(hidethis);
			document.getElementById(hidethis).style.display = 'none';
		}
		if (display == 'show'){
			//alert(hidethis);
			document.getElementById(hidethis).style.display = '';
		}
	}

//function used for currency change
function menudirect(curchange){
var URL = document.curchange.currencyid.options[document.curchange.currencyid.selectedIndex].value;
window.location.href = URL;
}

function killAutofill(){
  is = document.getElementsByTagName("INPUT");
  for(i=0;i<is.length;i++)
    is[i].style.backgroundColor = "";
  ss = document.getElementsByTagName("SELECT");
  for(i=0;i<ss.length;i++)
    ss[i].style.backgroundColor = "";
}

//Newsletter subscribe form
function focusName(element) {
  if (element.value == " name...") {
    element.value = "";
  }
}

function blurName(element) {
  if (element.value == "") {
    element.value = " name...";
  }
}

function focusEmail(element) {
  if (element.value == " email...") {
    element.value = "";
  }
}

function blurEmail(element) {
  if (element.value == "") {
    element.value = " email...";
  }
}

function checkName(str)
{
        var vname = str
		if (vname == " name...")
             return false;
        if (vname == "")
             return false;
        return true;
}
function checkEmailF(str)
{
        var apos = str.indexOf("@");
        var dpos = str.indexOf(".");
        var epos = str.indexOf("]");
        var fpos = str.indexOf("[");     
        if (apos<=0 || dpos<=0 || epos>0 || fpos>0 )
             return false;
        if (dpos+1>=str.length)
             return false;
        return true;
}
function ValidateForm()
{
        if (!checkName(document.theForm.name.value)){
                alert("Please enter your first name.");
                return false;
        }
		if (!checkEmailF(document.theForm.email.value)){
                alert("Please enter a valid email address.");
                return false;
        }
	return true;
}

//netscape css fix

function WM_netscapeCssFix() {
   if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function WM_netscapeCssFixCheckIn() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn()

//popup windows for references

function popupWindow(referenceHTML, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	windowProperties = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,resizable'
	reference = window.open(referenceHTML, 'refName', windowProperties)
	if (parseInt(navigator.appVersion) >= 4) { reference.window.focus(); }
}

function overture()
{
  var OpenWindow=window.open('http://inventory.overture.com/d/searchinventory/suggestion/', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=320, height=480');
}  
  
function google()
{
  var OpenWindow=window.open('https://adwords.google.com/select/KeywordToolExternal', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=600');
}


function contactForm(theForm) {
  allCorrect=true ;
  
  if (theForm.Name.value=="" || 
	  theForm.Name.value=="name..." || 
	  theForm.Phone.value=="" ||
	  theForm.Phone.value=="telephone..." ||
	  theForm.Email.value=="" ||
	  theForm.Email.value=="email...") {
    allCorrect=false ;
  }
  if (allCorrect==false)
  {
    alert("Please fill in all fields.") ;
	return false ;
  } 
    return true ;
}

function focusF(element,value) {
  if (element.value == value) {
    element.value = "";
  }
}

function blurF(element,value) {
  if (element.value == "") {
    element.value = value;
  }
}

function swapImage(imageName, destId) {
	if (imageName != '') {
		document.getElementById(destId).src = imageName;
	}
}

function OpenNewWindow(bigurl, width, height)
{
    var newWindow = window.open("", "pictureViewer", 
        "location=no, directories=no, fullscreen=no, menubar=no, status=no, toolbar=no, width=" + width + ", height=" + height + ", scrollbars=no");
    newWindow.document.writeln("<html>");
    newWindow.document.writeln("<body style='margin: 0 0 0 0;'>");
    newWindow.document.writeln("<a href='javascript:window.close();'>");
    newWindow.document.writeln("<img src='" + bigurl + "' alt='Click to close' border='0' id='bigImage'/>");
    newWindow.document.writeln("</a>");
    newWindow.document.writeln("</body></html>");
    newWindow.document.close();
}

