function setZoom( objImage ) {
	document.getElementById( "zoom" ).href = objImage.src.replace("/thumb/", "/full/");	
	document.getElementById( "bigImage" ).src = objImage.src.replace("/thumb/", "/full/");	
}

function confirm_exit() {
	if ( needToConfirm ) {
		return "You have not saved changes. Do you want to continue without saving.";
	}
}

function change_made() {
	needToConfirm = true;
}

function change_remove() {
	needToConfirm = false;
}

function collapseCategories( iCount ) {
	for ( i = 1; i <= iCount; i++ ){
		document.getElementById( "section_" + i ).style.visibility = "hidden";
		document.getElementById( "section_" + i ).style.position = "absolute";
		document.getElementById( "expand_" + i ).src = "assets/icon_expand.gif";
	}
}

function delete_confirmation( strName ) {
	return confirm( "Are you sure that you want to delete '" + strName + "'?\nThis can not be undone." );
}

function default_field_clear( objField, strTxt ) {
	if( objField.value == strTxt ){
		objField.value = '';
	}
}

function expandCategories( iCount ) {
	for ( i = 1; i <= iCount; i++ ) {
		document.getElementById( "section_" + i ).style.visibility = "visible";
		document.getElementById( "section_" + i ).style.position = "static";
		document.getElementById( "expand_" + i ).src = "assets/icon_collapse.gif";
	}
}

function field_maxlength( evt, objName, iLen ) {
	var charCode = ( evt.which ) ? evt.which : event.keyCode;
	return ( ( objName.value.length < iLen ) || ( charCode == 8 ) || ( charCode == 46 ) || ( charCode == 37 ) || ( charCode == 39 ) );
}

function keycheck_numbers_only( evt ){
	var charCode = ( evt.which ) ? evt.which : event.keyCode;
	return ( ( charCode == 8 ) || ( charCode == 46 ) || ( charCode == 37 ) || ( charCode == 39 ) || ( charCode > 47 && charCode < 58 ) || ( charCode > 95 && charCode < 106 ) );
}

function remaining_text( objField, objText, iLen ){
	objText.innerHTML = "[ " + ( iLen - objField.value.length ) + " character(s) remaining ]";
}

function toggle( objButton, objFrame ){
	if ( objFrame.style.visibility == "hidden" ){
		objFrame.style.visibility = "visible";
		objFrame.style.position = "static";
		objButton.src = "assets/icon_collapse.gif";
	} else {
		objFrame.style.visibility = "hidden";
		objFrame.style.position = "absolute";
		objButton.src = "assets/icon_expand.gif";
	}
}

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

function remaining_text( objField, objText ){
	var iLength = objField.getAttribute ? parseInt( objField.getAttribute("maxlength") ) : 0;	
	if( objField.value.length > iLength ){
		objField.value = objField.value.substring( 0, iLength );
	}
	objText.innerHTML = "( " + ( iLength - objField.value.length ) + " character(s) remaining. )";
}

function remaining_length( evt, objField, objText ){
	var charCode = ( evt.which ) ? evt.which : event.keyCode;
	var iLength = objField.getAttribute ? parseInt( objField.getAttribute("maxlength") ) : 0;
	if( ( charCode == 8 ) || ( charCode == 37 ) || ( charCode == 39 ) || ( charCode == 46 ) ){
		return true;
	}
	if( objField.value.length <= iLength ){
		return true;
	}
	return false;
}

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = 112,top = 84');");
}

function tab_switch( iTab ){
	window.frames["frame_tab"].src = "tabswitch.cfm?tab=" + iTab;
	document.all.frame_tab.src = "tabswitch.cfm?tab=" + iTab;
}

function swapDIV( objDiv_Show, objDiv_Hide, objDiv_Hide2, objDiv_Hide3, objDiv_Hide4, objDiv_Hide5 ){
	objDiv_Show.style.display = "block";
	objDiv_Hide.style.display = "none";
	if( objDiv_Hide2 != null ){
		objDiv_Hide2.style.display = "none";
	}
	if( objDiv_Hide3 != null ){
		objDiv_Hide3.style.display = "none";
	}
	if( objDiv_Hide4 != null ){
		objDiv_Hide4.style.display = "none";
	}
	if( objDiv_Hide5 != null ){
		objDiv_Hide5.style.display = "none";
	}
}

function toggleDiv( objDiv ){
	if ( objDiv.style.display == "block" ){
		objDiv.style.display = "none";
	} else {
		objDiv.style.display = "block";
	}
}

function swapTab( objTab_Show, objTab_Hide, objTab_Hide2, objTab_Hide3, objTab_Hide4, objTab_Hide5  ){
	objTab_Show.className = "tab";
	objTab_Hide.className = "offtab";
	if( objTab_Hide2 != null ){
		objTab_Hide2.className = "offtab";
	}
	if( objTab_Hide3 != null ){
		objTab_Hide3.className = "offtab";
	}
	if( objTab_Hide4 != null ){
		objTab_Hide4.className = "offtab";
	}
	if( objTab_Hide5 != null ){
		objTab_Hide5.className = "offtab";
	}
}

function bookmarksite(title,url){
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
		window.external.addFavorite(url, title);
}
