// JavaScript Document

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(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 MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


function clearMember() {
	document.xform.memEmail.value = "";
}

function showLayer(whichLayer) {
	if (document.getElementById) {var style2 = document.getElementById(whichLayer).style;}	// standards
	else if (document.all) {var style2 = document.all[whichLayer].style;}					// old msie versions
	else if (document.layers) {var style2 = document.layers[whichLayer].style;}				// nn4
	style2.display = "inline";
}
function hideLayer(whichLayer) {
	if (document.getElementById) {var style2 = document.getElementById(whichLayer).style;}	// standards
	else if (document.all) {var style2 = document.all[whichLayer].style;}					// old msie versions
	else if (document.layers) {var style2 = document.layers[whichLayer].style;}				// nn4
	style2.display = "none";
}

function changeBreeds() {
	var species_ID = document.getElementById('species').value;
	for (var i = 1; i <= 4; i++) {
		if (i == species_ID) {showLayer("breed_"+i);}
		else {hideLayer("breed_"+i);}
	}
}

function changeGroup(trigger, group) {
	if (document.getElementById(trigger).checked) {showLayer(group);}
	else {hideLayer(group);}
}
function changeChip() {changeGroup('chipTrigger', 'microchip_fields');}
function changePolice() {changeGroup('policeTrigger', 'police_fields');}
function changePassword() {changeGroup('changePass', 'password_fields');}
function addVaccination() {changeGroup('addVacc', 'new_vacc');}
function addMedicalCondition() {changeGroup('addMedCond', 'new_medCond');}

function changeKey() {
	var koogatag = document.getElementById('koogatag').value;
	window.location='pet.php?id='+koogatag;
}

function changeBirthday() {
	if (document.getElementById("birthday_unknown").checked) {
		 document.getElementById("birth_month").disabled = true;
		 document.getElementById("birth_day").disabled = true;
		 document.getElementById("birth_year").disabled = true;
	} else {
		 document.getElementById("birth_month").disabled = false;
		 document.getElementById("birth_day").disabled = false;
		 document.getElementById("birth_year").disabled = false;
	}
}

function changeHeartworm() {
	if (document.getElementById('heartwormTrigger').checked) {document.getElementById("heartworm_day").disabled = false;}
	else {document.getElementById("heartworm_day").disabled = true;}
}

function confirmRemovePhoto(filename, enc_filename) {
	if (confirm("Are you sure you would like to remove the photo of your pet?"))
		window.location = '../forms/pet_remove.php?filename='+enc_filename;
}
function confirmRemoveMedHist(reference, record_type, enc_record) {
	if (confirm("Are you sure you would like to remove "+reference+"?"))
		window.location = '../forms/medHist_remove.php?'+record_type+'='+enc_record;
}

// Copyright 1999 - 2002 by Ray Stott, Pop-up Windows Script ver 2.0
// OK to use if this copyright is included
// Script is available at http://www.crays.com/jsc          
var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"
function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
  var d_winLeft = 5  // default, pixels from screen left to window left
  var d_winTop = 5   // default, pixels from screen top to window top
  winName = "popWin" + winCount++ //unique name for each pop-up window
  closePopWin()           // close any previously opened pop-up window
  if (openPopWin.arguments.length >= 4)  // any additional features? 
    winFeatures = "," + winFeatures
  else 
    winFeatures = "" 
  if (openPopWin.arguments.length == 6)  // location specified
    winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
  else
    winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
  popWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + winFeatures)
}
function closePopWin(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popWin != null) if(!popWin.closed) popWin.close() 
}
function getLocation(winWidth, winHeight, winLeft, winTop){
  var winLocation = ""
  if (winLeft < 0)
    winLeft = screen.width - winWidth + winLeft
  if (winTop < 0)
    winTop = screen.height - winHeight + winTop
  if (winTop == "cen")
    winTop = (screen.height - winHeight)/2 - 20
  if (winLeft == "cen")
    winLeft = (screen.width - winWidth)/2
  if (winLeft>0 & winTop>0)
    winLocation =  ",screenX=" + winLeft + ",left=" + winLeft + ",screenY=" + winTop + ",top=" + winTop
  else
    winLocation = ""
  return winLocation
}
/*
function keyCheck() {
	var keyChk = document.register.koogatag.value;
	tkeyChk = keyChk.replace(/^\s+|\s+$/g, '');
		if(tkeyChk == ""){
			alert("Please Enter A KoogaTag ID");
		}else{
			document.register.submit();
		}
}
function printPoster() {
	div = document.getElementById("buttons");
	div.innerHTML = '';
	window.print();
	div.innerHTML = '<input type="button" name="cancel" value="Cancel" onclick="window.location=\'homepage.php\'" /> &nbsp; <input type="button" name="print" value="Print Poster" onclick="printPoster()" />';
}
*/
