/* * * * * * * * * * * * * * * * * * * * * * *
* Fonctions Javascript pour le site sco.wisc.edu  *
* * * * * * * * * * * * * * * * * * * * * * */

/** VARIABLES GLOBALES ***************************************************************************/

// Variables permettant de connaître le navigateur en cours
//var ns4  = document.layers ? true : false;
//var dom  = document.getElementById ? true : false;
//var ie4  = document.all ? true : false;
//var isNs = navigator.appName.indexOf("Netscape") != -1;

// Paramètres de l'animation du menu latéral
//var Interval         = null;
//var maxBottom        = 0;
//var isMenuLat        = false; // Indique s'il y a un menu latéral dans la page
//var AttenteAvantAnim = 200;   // nombre de millisecondes avant de l'ancer l'animation

//var Increment        = isNs ? 10 : 5; // nombre de pixels à chaque d'incrémentation
//var VitesseIncrement = 5;             // nombre de millisecondes entre chaque incrémentation

// Variables pour les popup menus
//var LineHeight       = 29;    // hauteur d'une ligne du menu latéral
//if(ns4)
//{
//	LineHeight = LineHeight-2;
//}
//var ColumnWidth = 150;   // largeur des popups
//var PopupTimer  = null;
//var cursortype  = 'pointer';
//if ( ie4 )
//{
//	cursortype = 'hand';
//}


//** FONCTIONS UTILITAIRES ************************************************************************/

function mailIt(address, linkID, aSubject){
  address = address.replace(/...scoA.../g, "@");
  address = address.replace(/...scoD.../g,".");
	document.getElementById(linkID).href ="mailto:"+address+"?subject="+aSubject;
}

function OpenReferenceWindow(refpage) {
	window.name = "opener";
	newwindow = window.open(refpage, "refwindow", "resizable=1,scrollbars=1,toolbar=1,width=600,height=300");
	newwindow.focus();
	}
function OpenDetailWindow(detpage) {
	window.name = "opener";
	detailwindow = window.open(detpage, "detwindow", "resizable=1,scrollbars=1,toolbar=1,width=550,height=580");
	detailwindow.focus();
	}
function OpenCalloutWindow(thepage) {
	window.name = "callout";
	calloutwindow = window.open(thepage, "calloutwindow", "resizable=1,scrollbars=1,toolbar=6,width=820,height=500");
	calloutwindow.focus();
	}
function linkpage(whichpage) {
  whichindex = whichpage.selectedIndex;
  whichone = whichpage.options[whichindex].value;
  window.location.href = whichone;
  }
 function linkMappage(whichpage) {
  whichindex = whichpage.selectedIndex;
  whichone = whichpage.options[whichindex].value;
  window.location = "subject.php?page="+whichone;
  } 
function showResults() {
	
	var myframe = window.frames['results_iframe'];
	var myresults = document.getElementById('results_container');
	myresults.innerHTML = myframe.document.body.innerHTML;
	// mb 2005-01-28  empty out iframe (save memory?)
	myframe.document.body.innerHTML = "";
	}

function OpenRefWindow(value1,value2,value3,value4) {
		url = "apcat_view_contact.php?sort1=" + value1 + "&sort2=" + value2 + "&sort3=" + value3 + "&sort4=" + value4; 
		newwindow = url;
		window.open(newwindow, "apwindow", "resizeable=0,scrollbars=1,toolbar=1,width=500,height=600");
		}		
function switchcat(whichobject){
	whichindex = whichobject.selectedIndex;
        whichone = whichobject.options[whichindex].value;
	document.location.href = whichone + document.location.search;
	document.browsecat.reset();
}

function switchcounty(whichobject){
	whichindex = whichobject.selectedIndex;
        whichone = whichobject.options[whichindex].value;
	document.location.href = "apcat_records.php?county=" + whichone;
	document.browsecat.reset();
}
function switchCountySurveyor(whichobject){
	whichindex = whichobject.selectedIndex;
        whichone = whichobject.options[whichindex].value;
	document.location.href = "wi_county_surveyors.php?county=" + whichone;
	document.browsecat.reset();
}

function switchsort(whichobject){
	whichindex = whichobject.selectedIndex;
        whichone = whichobject.options[whichindex].value;
	document.location.href = "stateortho.php?sort=" + whichone;
}

function gotoprev(whichrec,whichcounty){
	newrec = whichrec - 10;
	document.location.href = document.location.pathname + "?county=" + whichcounty + "&startrec=" + newrec;
}

function gotonext(whichrec,whichcounty){
	newrec = whichrec + 10;
	document.location.href = document.location.pathname + "?county=" + whichcounty + "&startrec=" + newrec;
}

function showrec(whichtable,whichrec){
	urlstring = "cat_record_" + whichtable + ".php?rec=" + whichrec;
	RecordWindow = window.open(urlstring, "RecordWindow", "resizable=yes,location=no,scrollbars=yes,width=700,height=600");
	RecordWindow.focus();
}
//function CreditsWindow(issue) {
//	window.name="catalog";
//	url="credits.php?" + issue;
//	newwindow = window.open(url,"credits","resizeable=1,scrollbars=1,toolbar=1,width=430,height=600");
//  newwindow.focus();
//}

function ClearOpenCatalogWindow(){
  newwindow.close();
}
function openrecord(whichrecord){	
	urlstring = "briefs_story?news_id=" + whichrecord;
  	RecordWindow = window.open(urlstring, "RecordWindow", "resizable=yes,location=no,scrollbars=yes,width=625,height=400");
	RecordWindow.focus();
	}
function back(){

}

function openprofile(name) {
urlstring = "profile.php?name=" + name;
ProfileWindow = window.open(urlstring, "ProfileWindow", "Resizable=yes, scrollbars=yes, width=425, height=300");
ProfileWindow.focus();
}

function divHelp(message, rightShift, downShift, w, h){

 newdiv = document.createElement("div");
 dstyle = newdiv.style; 
 newdiv.id = "help"; 
 dstyle.width = w +'px';
 dstyle.height = h +'px';
 dstyle.position = 'absolute';
 dstyle.left = rightShift + 'px';
 dstyle.top = downShift + 'px';
 dstyle.padding = "3px"; //Added by Jared
 newdiv.innerHTML = message;
 document.body.appendChild(newdiv);	
}
function OpenPictureWindow(refpage, image) {
	window.name = "opener";
	URL = refpage+"?image="+image;
	newwindow = window.open(URL, "refwindow", "resizable=1,scrollbars=0,toolbar=2,width=650,height=800");
	newwindow.focus();
	
	}
	
function OpenHeightWindow(refpage, height) {
	window.name = "opener";
	newwindow = window.open(refpage, "refwindow", "resizable=1,scrollbars=0,toolbar=0,width=300,height="+height);
	newwindow.focus();
	}	
	
function OpenTinyWindow(refpage) {
	window.name = "opener";
	newwindow = window.open(refpage, "refwindow", "resizable=1,scrollbars=0,toolbar=0,width=300,height=400");
	newwindow.focus();
	}	