
// Open Window - No Self Close



function newWindow(file,width,height,window,toolbar,resize,scroll,status){

var wintopval = (height/2) + 50;
var winleftval = (width/2) + 10;
	
var winTop = (screen.height / 2) - wintopval;
var winLeft = (screen.width / 2) - winleftval;

windowFeatures = "width= " + width + ", height= " + height + ",";
windowFeatures = windowFeatures + "left=" + winLeft + ",";
windowFeatures = windowFeatures + "top=" + winTop + ",";

windowFeatures = windowFeatures + "toolbar= " + toolbar + ", location=no, resizable= " + resize + ", scrollbars= " + scroll + ", status= " + status;

	 msgWindow=open(file, window, windowFeatures);
    if (msgWindow.opener == null) msgWindow.opener = self;
	}


//--------------------------------------------------------------------------------


// Validate Email Address


function validateEmail(formName,inputName) {
	
// Validate email address

	var inputObject = document.forms[formName].elements[inputName];
	var atSign = inputObject.value.indexOf('@');
	var dot = inputObject.value.lastIndexOf('.');
	var space = inputObject.value.indexOf(' ');
	var emailLength = inputObject.value.length - 1;

	if ((atSign < 1) || (space != -1) || (dot <= atSign + 1) || (dot == emailLength)) { 
 		alert('Please enter a valid email address');
		inputObject.focus();
		return false;
	}
	return true;
}


//------------------------------------------------------------------------------------------------------


// Validate Password to Submit


function validatepassword(formName,password,passwordconfirm) {

	var inputObject = document.forms[formName].elements[password];
	var first = document.forms[formName].elements[password].value;
	var second = document.forms[formName].elements[passwordconfirm].value;	

	if (first != second) { 
 		alert('Your password did not confirm, please try again');
		document.forms[formName].elements[password].value = "";
		document.forms[formName].elements[passwordconfirm].value = "";
		inputObject.focus();
		return false;
	}
	return true;
}


//------------------------------------------------------------------------------------------------------

// Swap Image



function swapimage(name,image){
		
	document[name].src = image;
}


//------------------------------------------------------------------------------------------------------


// Disclaimer Window


function disclaimer() {
var winTop = (screen.height / 2) - 250;
var winLeft = (screen.width / 2) - 250;
windowFeatures = "width=500, height=300,";
windowFeatures = windowFeatures + "left=" + winLeft + ",";
windowFeatures = windowFeatures + "top=" + winTop + ",";
windowFeatures = windowFeatures + "toolbar=no, location=no, resizable=no, scrollbars=no, status=no";


     window.open('disclaimer.cfm', 'window2',windowFeatures);
}


//------------------------------------------------------------------------------------------------------


// Merchandise Search Enlarge


function enlarge(pic) {

var url = "enlarge.cfm?picture=" + pic;

var winTop = (screen.height / 2) - 350;
var winLeft = (screen.width / 2) - 190;
windowFeatures = "width=487, height=366,";
windowFeatures = windowFeatures + "left=" + winLeft + ",";
windowFeatures = windowFeatures + "top=" + winTop + ",";
windowFeatures = windowFeatures + "toolbar=no, location=no, resizable=no, scrollbars=no, status=no";


     window.open(url,'window2',windowFeatures);
}


//------------------------------------------------------------------------------------------------------


// Account Login


function login() {

var url = "login.cfm";

var winTop = (screen.height / 2) - 400;
var winLeft = (screen.width / 2) - 500;
windowFeatures = "width=350, height=200,";
windowFeatures = windowFeatures + "left=" + winLeft + ",";
windowFeatures = windowFeatures + "top=" + winTop + ",";
windowFeatures = windowFeatures + "toolbar=no, location=no, resizable=no, scrollbars=no, status=no";


     window.open(url,'window2',windowFeatures);
}


//------------------------------------------------------------------------------------------------------


// Admin Window


function openadmin() {
var winTop = (screen.height / 2) - 400;
var winLeft = (screen.width / 2) - 350;
windowFeatures = "width=700, height=500,";
windowFeatures = windowFeatures + "left=" + winLeft + ",";
windowFeatures = windowFeatures + "top=" + winTop + ",";
windowFeatures = windowFeatures + "toolbar=yes, location=no, resizable=no, scrollbars=yes, status=yes";


     window.open('admin/index.cfm','admin',windowFeatures);
}


//------------------------------------------------------------------------------------------------------


// Login - Forgot Password


function forgotpass() {
var winTop = (screen.height / 2) - 250;
var winLeft = (screen.width / 2) - 175;
windowFeatures = "width=350, height=200,";
windowFeatures = windowFeatures + "left=" + winLeft + ",";
windowFeatures = windowFeatures + "top=" + winTop + ",";
windowFeatures = windowFeatures + "toolbar=no, location=no, resizable=no, scrollbars=no, status=no";


     window.open('forgotpass.cfm', 'window3',windowFeatures);
}


//------------------------------------------------------------------------------------------------------

// DIV for contact info window



		function contactpop() {

			if (document.all.contactpop.style.visibility == "hidden")
			{
			document.all.contactpop.style.visibility= "visible";
			}
			else
			{
			document.all.contactpop.style.visibility= "hidden";
			}
			
		}

		function searchpophide() {

			document.all.contactpop.style.visibility= "hidden";

		}

//------------------------------------------------------------------------------------------------------


// DIV Drag and Drop Functionality


   var NS = (navigator.appName=='Netscape'); // Stand pain-in-the-ass
   var offsetX=0;  // Holds LEFT offset to the point where we originally clicked down within an Object
   var offsetY=0;  // Holds TOP offset to the point where we originally clicked down within an Object
   var gSelectedDiv = null; // Global to currently selected DIV we've picked up and are dragging around

   
   // Determines what DIV we've clicked on ... this is done in place of IE's nice event.srcElement for NS6 
   function ElementUnderMouse(x,y,deltaX,deltaY) {
    var retval = null;
    theDIVPile = document.getElementsByTagName("DIV");
    for (i=0;i<theDIVPile.length;i++) {
     theStyle = theDIVPile[i].style;

     DIV_top    = parseInt(theStyle.top);  
     DIV_left   = parseInt(theStyle.left);
     DIV_right  = DIV_left + parseInt(theStyle.width);
     DIV_bottom = DIV_top + parseInt(theStyle.height);
     
   //  document.write("Checking (" + DIV_left + "," + DIV_top +") - (" + DIV_right + "," + DIV_bottom + ")<BR>");
     
     if ((x >= DIV_left) && (x <= DIV_right) && (y >= DIV_top) && (y <= DIV_bottom)) {
      // Since we're given an x,y offset relative to the object we've just clicked, we can compare that object's
      // "Real" X,Y coordinates to the Object we hope is the right one ... otherwise, move on
      if ( (DIV_left + deltaX == x) && (DIV_top + deltaY == y)) {
       retval=theDIVPile[i];
       break;
      }
     }
    } return retval;
   }

  function Handle_MouseDown(e) {
   var theEvent = (NS) ? e : event;
   x = (NS) ? e.pageX : event.x; 
   y = (NS) ? e.pageY : event.y;
   offsetX = (NS) ? theEvent.layerX : theEvent.offsetX+2;
   offsetY = (NS) ? theEvent.layerY : theEvent.offsetY+2;
   var theObject=ElementUnderMouse(x,y,offsetX,offsetY);
   if ((!NS) && (theEvent.srcElement.tagName=="TD")) { 
    // Code specific to this implementation ... if you had no <TABLE> Stuff inside the DIV, you wouldn't have to worry about this ... SN
    theObject = theEvent.srcElement.parentElement.parentElement.parentElement.parentElement;
   }
   
   if (theObject != null) {
    gSelectedDiv = theObject; 
   } return false;  // Prevents text highlighting ... SN
  }

  function Handle_MouseMove(e) {
   if (gSelectedDiv) {
    gSelectedDiv.style.top  = ((NS) ? e.pageY : event.y) - offsetY ;
    gSelectedDiv.style.left = ((NS) ? e.pageX : event.x) - offsetX;
   }
  }

  function Handle_MouseUp(e) {
   gSelectedDiv = null;
  }

  document.onmousedown = Handle_MouseDown;
  document.onmousemove = Handle_MouseMove;
  document.onmouseup = Handle_MouseUp;



//------------------------------------------------------------------------------------------------------




