	/*
		K-Kart E-Commerce Solution, v1.0
		http://www.kirsir.com
		
		Release Date: 02/25/05
		Terms of Use: K-Kart is owned by Kirsir Web Development and cannot be used without written consent
		              or purchase.  The code contained within K-Kart cannot be reproduced and used on 
					  another site or sold as one's own.
		
		Copyright (c) 2005 Kirsir Web Development
	*/

function showHideLayers() { 

  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  { 
		if ((obj=MM_findObj(args[i]))!=null) 
		{ 
			v=args[i+2];
			if (obj.style) 
			{ 
				obj=obj.style; 
				v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
			}
			obj.visibility=v; 
		} 
	}
}

function hideAllOtherLayers(showThis)
{
	//this function shows the layer passed into the function while hiding all other nav dd's and determines whether to show the closer layer (for drop downs yes, otherwise close all)
	var ddIDs = new Array('dd_1', 'dd_2', 'dd_3', 'dd_4', 'dd_5');

	for(var x=0; x<ddIDs.length; x++)
	{
		
		if(ddIDs[x] == showThis)
			showHideLayers(ddIDs[x],'','show');
		else
			showHideLayers(ddIDs[x],'','hide');
	}
	
	if(showThis != "") //if not empty, we want to show a drop down layer so show the closer!
		showHideLayers('closer','','show');
	else
		showHideLayers('closer','','hide'); //if '' was passed in, we want to close everything
}


function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}

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 checkOldBrowser()
{
	//check if the user's browser is new.  If not, we present them with a alert message indicating that they aren't seeing the site the way it was intended
	if (!document.getElementById)
	{
		//Old Browser!  Check if old Opera, IE, or NN.
		var browserMsg = "The browser you are using is outdated.  Although you will still be able to read our information, your browser prevents you from viewing the site the way it is intended.\n\nWould you like to download the latest version of your browser (in a new window)?";
		
		if (navigator.userAgent.indexOf("Opera") > 0)
		{
			if(confirm(browserMsg))
				window.open("http://www.opera.com");
		}
		else if (navigator.appName == "Microsoft Internet Explorer")
		{
			if(confirm(browserMsg))
				window.open("http://www.microsoft.com/windows/ie/downloads/critical/ie6sp1/default.asp");
		}
		else if (navigator.appName == "Netscape")
		{
			if(confirm(browserMsg))
				window.open("http://channels.netscape.com/ns/browsers/download.jsp");
		}
	}
}


function setStatus(text) 
{ 
  window.status = text;
  return true;
}

function openPopup(thePage, theWidth, theHeight, theWindowName, intScroll)
{
	//This function accepts the page to be loaded, the width and height of the popup, and the name of the window so that
	//new popups open in their own window and not in other ones
	//Also accepts intScroll indicating if scrollbars should be included (0=no, 1=yes)
	
	//POPUP PROPERTIES CODE
	var popWin, theProperties, popWidth, popHeight, leftPos, topPos;
	
	popWidth = theWidth;
	popHeight = theHeight;
	
	//open in center
	leftPos = (screen.width-popWidth)/2;
	topPos = (screen.height-popHeight)/2;
	
	//popup only has scrollbars
	theProperties = "menubar=0,toolbar=0,resizable=yes,scrollbars=" + intScroll + ",width=" + popWidth + ",height=" + popHeight + ",left=" + leftPos + ",top=" + topPos;
	
	//Open a popup window
	popWin = window.open(thePage, theWindowName, theProperties);
	popWin.focus();
	
	return false;
}



function SetFocus(TargetFormName) {
  var target = 0;
  if (TargetFormName != "") {
    for (i=0; i<document.forms.length; i++) {
      if (document.forms[i].name == TargetFormName) {
        target = i;
        break;
      }
    }
  }

  var TargetForm = document.forms[target];
    
  for (i=0; i<TargetForm.length; i++) {
    if ( (TargetForm.elements[i].type != "image") && (TargetForm.elements[i].type != "hidden") && (TargetForm.elements[i].type != "reset") && (TargetForm.elements[i].type != "submit") ) {
      TargetForm.elements[i].focus();

      if ( (TargetForm.elements[i].type == "text") || (TargetForm.elements[i].type == "password") ) {
        TargetForm.elements[i].select();
      }

      break;
    }
  }
}

function RemoveFormatString(TargetElement, FormatString) {
  if (TargetElement.value == FormatString) {
    TargetElement.value = "";
  }

  TargetElement.select();
}

function CheckDateRange(from, to) {
  if (Date.parse(from.value) <= Date.parse(to.value)) {
    return true;
  } else {
    return false;
  }
}

function IsValidDate(DateToCheck, FormatString) {
  var strDateToCheck;
  var strDateToCheckArray;
  var strFormatArray;
  var strFormatString;
  var strDay;
  var strMonth;
  var strYear;
  var intday;
  var intMonth;
  var intYear;
  var intDateSeparatorIdx = -1;
  var intFormatSeparatorIdx = -1;
  var strSeparatorArray = new Array("-"," ","/",".");
  var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  strDateToCheck = DateToCheck.toLowerCase();
  strFormatString = FormatString.toLowerCase();
  
  if (strDateToCheck.length != strFormatString.length) {
    return false;
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
      intFormatSeparatorIdx = i;
      break;
    }
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
      intDateSeparatorIdx = i;
      break;
    }
  }

  if (intDateSeparatorIdx != intFormatSeparatorIdx) {
    return false;
  }

  if (intDateSeparatorIdx != -1) {
    strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
    if (strFormatArray.length != 3) {
      return false;
    }

    strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
    if (strDateToCheckArray.length != 3) {
      return false;
    }

    for (i=0; i<strFormatArray.length; i++) {
      if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm') {
        strMonth = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'dd') {
        strDay = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'yyyy') {
        strYear = strDateToCheckArray[i];
      }
    }
  } else {
    if (FormatString.length > 7) {
      if (strFormatString.indexOf('mmm') == -1) {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mm'), 2);
      } else {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mmm'), 3);
      }

      strDay = strDateToCheck.substring(strFormatString.indexOf('dd'), 2);
      strYear = strDateToCheck.substring(strFormatString.indexOf('yyyy'), 2);
    } else {
      return false;
    }
  }

  if (strYear.length != 4) {
    return false;
  }

  intday = parseInt(strDay, 10);
  if (isNaN(intday)) {
    return false;
  }
  if (intday < 1) {
    return false;
  }

  intMonth = parseInt(strMonth, 10);
  if (isNaN(intMonth)) {
    for (i=0; i<strMonthArray.length; i++) {
      if (strMonth == strMonthArray[i]) {
        intMonth = i+1;
        break;
      }
    }
    if (isNaN(intMonth)) {
      return false;
    }
  }
  if (intMonth > 12 || intMonth < 1) {
    return false;
  }

  intYear = parseInt(strYear, 10);
  if (isNaN(intYear)) {
    return false;
  }
  if (IsLeapYear(intYear) == true) {
    intDaysArray[1] = 29;
  }

  if (intday > intDaysArray[intMonth - 1]) {
    return false;
  }
  
  return true;
}

function IsLeapYear(intYear) {
  if (intYear % 100 == 0) {
    if (intYear % 400 == 0) {
      return true;
    }
  } else {
    if ((intYear % 4) == 0) {
      return true;
    }
  }

  return false;
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}
