
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = ((userAgent.indexOf("opera") != -1) || (typeof(window.opera) != "undefined"));
var is_saf = ((userAgent.indexOf("applewebkit") != -1) || (navigator.vendor == "Apple Computer, Inc."));
var is_webtv = (userAgent.indexOf("webtv") != -1);
var is_ie = ((userAgent.indexOf("msie") != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4 = ((is_ie) && (userAgent.indexOf("msie 4.") != -1));
var is_ie7 = ((is_ie) && (userAgent.indexOf("msie 7.") != -1));
var is_moz = ((navigator.product == "Gecko") && (!is_saf));
var is_kon = (userAgent.indexOf("konqueror") != -1);
var is_ns = ((userAgent.indexOf("compatible") == -1) && (userAgent.indexOf("mozilla") != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4 = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_mac = (userAgent.indexOf("mac") != -1);

//error handling for JS
var isDebugging = false;
var logJsErrors = true;

function ErrorSetting(msg, file_loc, line_no) {

	//log the error?
    if (logJsErrors){
        var theData = "?type=jserror&sev=1&param1=" + escape(file_loc) + "&param2=" + line_no + "&param3=" + escape(userAgent) + "&text=" + escape(msg);
        var theURL = "/auacms/pages/common/logger.aspx" + theData;
		sendAjaxCall(theURL, handleResponse, "GET"); 
    }
    //alert?
    if (isDebugging) {
        var error_d = "Error in file: " + file_loc +"\nline number:" + line_no + "\nMessage:" + msg;
        alert("Error Found !!!\n--------------\n"+error_d);
        return false;
    } else {
		return true;
	}
}

function handleResponse(responseText) 
{	
	//
}

//window.onerror = ErrorSetting;
//end errorhandling


// Start Overlay DIV //
var hideID;
var slidetimer;
var intervalX = 5;
var intervalY = 5;
var intervalOpac = 5;
var x_Offset = 7;
var y_Offset = 3;

function getposOffsetRel(overlay, offsettype) {
	var totaloffset = (offsettype == "left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl = overlay.offsetParent;
	while (parentEl != null) {
		if (parentEl.className != "centercontainer") {
			totaloffset = (offsettype == "left")? totaloffset + parentEl.offsetLeft : totaloffset + parentEl.offsetTop;
		}
		parentEl = parentEl.offsetParent;
	}
	return totaloffset;
}

function getStylePos(elem) {
	var position = (elem.currentStyle) ? elem.currentStyle["position"] : document.defaultView.getComputedStyle(elem, null).getPropertyValue("position");
	position = (position) ? position.toLowerCase() : position;
	return position;
}

function showSearchBox (curobj, subobjstr, opt_position, inputFieldID) {
	var returnValue = overlay(curobj, subobjstr, opt_position);
	var subobj = document.getElementById(subobjstr);
	if (subobj.style.display != "none") {
		var inputField = getElementByTypeAndID('input', inputFieldID);
		inputField.focus();
	}
	return returnValue;
}

function hideSearchBox(waitTime, boxElement) {
	var boxID = boxElement.id;
	var evt = (evt) ? evt : ((window.event) ? window.event : "");
	var elem = (evt.target) ? evt.target : evt.srcElement;
	//alert ("screenX / screenY: " + evt.screenX + "/" + evt.screenY);
	hideID = window.setTimeout("hideSearchBoxNow('" + boxID + "')", 1000);
}

function stopHide() {
	window.clearTimeout(hideID);
}

function hideSearchBoxNow(boxID) {
	overlayclose(boxID);
	window.clearTimeout(hideID);
}

function overlay(curobj, subobjstr, opt_position){

	if (document.getElementById){
		var subobj = document.getElementById(subobjstr);
		subobj.style.display = (subobj.style.display != "block")? "block" : "none"
		var xpos = getposOffsetRel(curobj, "left");
		xpos = xpos + ((typeof opt_position != "undefined" && opt_position.indexOf("right") != -1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
		var ypos = getposOffsetRel(curobj, "top");
		ypos = ypos + ((typeof opt_position != "undefined" && opt_position.indexOf("bottom") != -1)? curobj.offsetHeight : 0)
		xpos = xpos + x_Offset;
		ypos = ypos + y_Offset;
		//clip for slide
		var direction = "left";
		if (typeof opt_position!="undefined" && opt_position.indexOf("right")!= -1) {
			direction = "right";
		}
		subobj.style.clip = "rect(auto, 0px, 0px, auto)";
		//move to new position
		subobj.style.left = xpos + "px"
		subobj.style.top = ypos + "px"
		//slide in
		slide(subobjstr, 5, 5, 0, direction);
		return false;
	} else {
		return true;
	}
}

function stop_slide(subobjstr) {
	clearTimeout(slidetimer);
	var subobj = document.getElementById(subobjstr);
	subobj.style.clip = "rect(auto, auto, auto, auto)";
	changeOpac(100, subobjstr);
}

function slide(subobjstr, clipX, clipY, opacity, direction) {
	var subobj = document.getElementById(subobjstr);
	if (direction == "left" && (clipX < subobj.offsetWidth || clipY < subobj.offsetHeight)) {
		opacity += intervalOpac;
		changeOpac(opacity, subobjstr);
		clipX += intervalX;
		clipY += intervalY;
 
		subobj.style.clip = "rect(auto, " + clipX + "px, " + clipY + "px, auto)";
		slidetimer = setTimeout("slide('" + subobjstr + "', " + clipX + ", " + clipY + ", " + opacity + ", '" + direction + "');", 0);
	 } else {
		if (direction == "right" && (clipX > 0 || clipY < subobj.offsetHeight)) {
			opacity += intervalOpac;
			changeOpac(opacity, subobjstr);
			clipX -= intervalX;
			clipY += intervalY;
 
			subobj.style.clip = "rect(auto, " + subobj.offsetWidth + "px, " + clipY + "px, " + clipX + "px)";
			slidetimer = setTimeout("slide('" + subobjstr + "', "  + clipX + ", " + clipY + ", " + opacity + ", '" + direction + "');", 0);
		} else {
			stop_slide(subobjstr);
		}
	}
}

function overlayclose(subobj){
	document.getElementById(subobj).style.display="none";
}
// End Overlay DIV //

function setField (idField, varValue) {
	document.getElementById(idField).value = varValue;
}


// Start DHTML Help //
/***********************************************
* Show Hint script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
		
var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
	if (whichedge=="rightedge"){
		var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
	}
	else {
		var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
			edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
	}
	return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth, autohide){
	if ((ie||ns6) && document.getElementById("hintbox")){
		dropmenuobj=document.getElementById("hintbox")
		dropmenuobj.innerHTML=menucontents
		dropmenuobj.style.left=dropmenuobj.style.top=-500
		if (tipwidth!=""){
			dropmenuobj.widthobj=dropmenuobj.style
			dropmenuobj.widthobj.width=tipwidth
		}
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
		dropmenuobj.style.visibility="visible"
		if (autohide == 'true') {
			obj.onmouseout=hidetip
		}
	}
}

function hidetip(e){
	dropmenuobj.style.visibility="hidden"
	dropmenuobj.style.left="-500px"
}

function createhintbox(){
	var mydropmenuobj = document.getElementById("hintbox");
	if (mydropmenuobj == undefined) {
		var divblock=document.createElement("div");
		divblock.setAttribute("id", "hintbox");
		document.body.appendChild(divblock);
	}
}

if (window.addEventListener) {
	window.addEventListener("load", createhintbox, false) 
}
else { 
	if (window.attachEvent) {
		window.attachEvent("onload", createhintbox) 
	} else { 
		if (document.getElementById) {
			window.onload=createhintbox
		}
	}
}

// End DHTML Help //

function correctLink(id, target) {
	var anchor = document.getElementById(id);
	anchor.target = target;
}

//marks a form as dirty
function setDirty(DirtyIndicatorFieldID) {
	var DirtyIndicatorField = document.getElementById(DirtyIndicatorFieldID);
	DirtyIndicatorField.value = "1";
}

 //changes the status (disabled)true/false) of a stylesheet		
function setActiveStyleSheet(title, status) {
	var c, i, t;

	if(!(c = document.styleSheets)) {return true;}

	for (i = 0; i < c.length; i++) {
		if (c[i].title == title) {
			if (status == "on") {
				c[i].disabled = false;
			} else {
				c[i].disabled = true;
			}
		}
	}
	return true;
}

//p und br tauschen
function ChangePBR(e,ta) {
return false;
var TastenWert;
if (e && e.which) 
     {
         e = e;
         TastenWert = e.which;
     }
     else
     {
         e = event;
         TastenWert = e.keyCode;
     }
 if (TastenWert == 13)
     {
         var editor = GetEditor(e.srcElement.id);
         if (e.shiftKey)
             {
             InsertText('<p></p>');
             }
             else
             {
             InsertText('<br>');
             }
     return false;
     }
}


// Browser ermitteln
ns4 =(document.layers)? 1:0;
ie4 =(document.all)? 1:0;
dom =(document.getElementById)? 1:0;
if (ie4) dom =false;

// Bilder tauschen
function swap(which,sr) {
	document.images[which].src=eval(sr+'.src');
}

// Layer anzeigen
function show(img) {
	if (ns4) {
		document.layers[img].visibility = "show";
	}
	if (ie4) {
		document.all[img].style.visibility = "visible";
	}
	if (dom) {
		document.getElementById(img).style.visibility = "visible";
	}	
}

// Layer verstecken
function hide(img) {
	if (ns4) {
		document.layers[img].visibility = "hide";
	}
	if (ie4) {
		document.all[img].style.visibility = "hidden";
	}
	if (dom) {
		document.getElementById(img).style.visibility = "hidden";
	}	
}

	
// Suchfeld anzeigen
var suche_visible = 0;

function suche() {
	//if (suche_visible == 0) {
		show('suchbereich');
		if (ie4) document.suchformular.criteria.focus();
		suche_visible = 1;
	//}
	//else {
	//	hide('suchbereich');
	//	suche_visible = 0;
	//}
}


// Satellitenfenster oeffnen
function openWin(url) {
	satellit =window.open(url,"Satellitenfenster","height=420,width=440,left=20,top=20,screenX=20,screenY=20,resizable=no,menubar=no,scrollbars=no,status=no,toolbar=no,adressbar=no");
	satellit.window.focus();
}

function openHelpdesk(url) {
	satellit =window.open(url,"Helpdesk","height=540,width=700,left=20,top=20,screenX=20,screenY=20,resizable=no,menubar=no,scrollbars=yes,status=no,toolbar=no,adressbar=no");
	satellit.window.focus();
}

// irrelevant:siehe jeweiliges codebehind
//function openSitemap(url) {
//	satellit =window.open(url,"SiteMap","height=540,width=690,left=20,top=20,screenX=20,screenY=20,resizable=no,menubar=no,scrollbars=yes,status=no,toolbar=no,adressbar=no");
//	satellit.window.focus();
//}

function openTourguide(url) {
	satellit =window.open(url,"TourGuide","height=355,width=200,left=20,top=20,screenX=20,screenY=20,resizable=no,menubar=no,scrollbars=no,status=no,toolbar=no,adressbar=no");
	satellit.window.focus();
}

function openVR(url) {
	satellit =window.open(url,"VRPanorama","height=768,width=720,left=20,top=20,screenX=20,screenY=20,resizable=no,menubar=no,scrollbars=no,status=no,toolbar=no,adressbar=no");
	satellit.window.focus();
}

function hrefOeffnenImOpener(wohin){
	opener.location.href = wohin;
	this.window.focus();
}

// Tourguide
function putInFocus()
{
    setTimeout("self.focus()",200);
}

function putInFocusInline()
{
    setTimeout("self.focus()",200);
}

function fnTrapKD(btn){
 if (document.all){
   if (event.keyCode == 13)
   { 
     event.returnValue=false;
     event.cancel = true;
     btn.click();
   } 
 } 
 else 
 {
	/*
	if(window.event.which== 13) {
     window.event.returnValue=false;
     window.event.cancel = true;
     btn.click();
	}
	*/
 }
}

function fnTrapKD1(evt, btn){
	evt = (evt) ? evt : event;
	var keyCode = evt.keyCode;
	if (keyCode == 13)
	{ 
		evt.returnValue = false;
		evt.cancel = true;
		myClick(btn);
	} 
}

function myClick(myBtn) {
	if (is_ie) {
		myBtn.click()
	} else {
		if (myBtn.href != "" && myBtn.href != undefined) {
			document.location.href = myBtn.href;
		} else {
			myBtn.onclick();
		}
	}
}

function FocusFld(obj, literal) 
{
	if (obj.value == literal)
		obj.value = "";	
}
function BlurFld(obj, literal)
{ 
	if (obj.value == "")
		obj.value = literal;
}

function pausecomp(millis) {
	var date = new Date();
	var curDate = null;
	do { 
		curDate = new Date(); 
	} 
	while(curDate-date < millis);
} 

function getElementByTypeAndName(elementtype, elementname) {

	 var i=0;
	 for( i=0 ; i<document.getElementsByTagName(elementtype).length ; i++) {
	 if (document.getElementsByTagName(elementtype)[i].name.indexOf(elementname)>-1) {
	   return document.getElementsByTagName(elementtype)[i];
	  }
	 }
}

function getElementByTypeAndID(elementtype, elementid) {
	//alert("getElementByTypeAndID(" + elementtype + ", " + elementid + ")");
	 var i=0;
	 for( i=0 ; i<document.getElementsByTagName(elementtype).length ; i++) {
	 //if (i<9) {
	 // alert(i + ": " + document.getElementsByTagName(elementtype)[i].id);
		//}
	 if (document.getElementsByTagName(elementtype)[i].id.indexOf(elementid)>-1) {
	   return document.getElementsByTagName(elementtype)[i];
	  }
	 }
}

function showhide(elementtype, elementid, elementvisibility) {

	//switch visibilty of an element
	//receives elementtype ("td", "div",...),, elementid (or part of) and visibility : "hidden"|"visible"
	//alert("showhide(" + elementtype + ", " + elementid + ", " + elementvisibility + ")");
	
	 var whichElem = getElementByTypeAndID(elementtype, elementid);
	 whichElem.style.visibility=elementvisibility;
	 //for( i=0 ; i<document.getElementsByTagName(elementtype).length ; i++) {
	 //if (document.getElementsByTagName(elementtype)[i].id.indexOf(elementid)>-1) {
	 //  document.getElementsByTagName(elementtype)[i].style.visibility=elementvisibility;
	 // }
	 //}
}

function showhideinline(elementtype, elementid, elementvisibility) {

	//switch visibilty of an element
	//receives elementtype ("td", "div",...),, elementid (or part of) and visibility : "hidden"|"visible"
	//alert("showhide(" + elementtype + ", " + elementid + ", " + elementvisibility + ")");
	
	var whichElem = getElementByTypeAndID(elementtype, elementid);
	if (whichElem.style.display == "inline") {
		whichElem.style.display = "none";
	}
	else {
		whichElem.style.display = "inline";
	}
	
	// var i=0;
	// for( i=0 ; i<document.getElementsByTagName(elementtype).length ; i++) {
	// if (document.getElementsByTagName(elementtype)[i].id.indexOf(elementid)>-1) {
	//   if (document.getElementsByTagName(elementtype)[i].style.display == "inline") {
	//     document.getElementsByTagName(elementtype)[i].style.display = "none";
	//   }
	//   else {
	//     document.getElementsByTagName(elementtype)[i].style.display = "inline";
	//   }
	   //document.getElementsByTagName(elementtype)[i].style.display=elementvisibility;
	//  }
	// }
}

function switchinline(elementtype, elementid, elementvisibility) {

	//switch visibilty of an element
	//receives elementtype ("td", "div",...),, elementid (or part of) and visibility : "hidden"|"visible"
	//alert("showhide(" + elementtype + ", " + elementid + ", " + elementvisibility + ")");
	
	var whichElem = getElementByTypeAndID(elementtype, elementid);
	whichElem.style.display=elementvisibility;
	// var i=0;
	// for( i=0 ; i<document.getElementsByTagName(elementtype).length ; i++) {
	// if (document.getElementsByTagName(elementtype)[i].id.indexOf(elementid)>-1) {
	//   document.getElementsByTagName(elementtype)[i].style.display=elementvisibility;
	//  }
	// }
}

//get element object based on its element id
function getElement(elementID)
{
	if (document.getElementById) { // DOM3 = IE5, NS6 
		return document.getElementById(elementID);
	} 
	else { 
		if (document.layers) { // Netscape 4 
			return document.elementID;
		} 
		else { // IE 4 
			return document.all.elementID; 
		} 
	}
}


// disable the element
function disableElement(elementID){
		var ID = elementID;
		
		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById(ID).disabled = true; 
		} 
		else { 
			if (document.layers) { // Netscape 4 
				document.ID.disabled = true; 
			} 
			else { // IE 4 
				document.all.ID.disabled = true; 
			} 
		}
}

// enable the element
function enableElement(elementID){
		var ID = elementID;
		
		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById(ID).disabled = false; 
		} 
		else { 
			if (document.layers) { // Netscape 4 
				document.ID.disabled = false; 
			} 
			else { // IE 4 
				document.all.ID.disabled = false; 
			} 
		} 
}

// set the element invisible
function setElementInvisible(elementID){
		var ID = elementID;
		
		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById(ID).style.display = 'none'; 
		} 
		else { 
			if (document.layers) { // Netscape 4 
				document.ID.display = 'none'; 
			} 
			else { // IE 4 
				document.all.ID.style.display = 'none'; 
			} 
		}
}

// set the element visible
function setElementVisible(elementID){
		var ID = elementID;
		
		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById(ID).style.display = 'block'; 
		} 
		else { 
			if (document.layers) { // Netscape 4 
				document.ID.display = 'block'; 
			} 
			else { // IE 4 
				document.all.ID.style.display = 'block'; 
			} 
		} 
}

//fade or unfade the page element
function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

//if an element is invisible, make it visible, else make it ivisible 
function shiftOpacity(id, millisec) { 
    if(document.getElementById(id).style.opacity == 0) { 
        opacity(id, 0, 100, millisec); 
    } else { 
        opacity(id, 100, 0, millisec); 
    } 
} 

//for destinations home template only --> braucht noch revision
function shiftDIV(idVisible, idInvisible1, idInvisible2, idInvisible3, millisec, btnBold, btnNormal1, btnNormal2, btnNormal3){
		
	if(document.getElementById(idInvisible1).style.opacity == 100) { 
		opacity(idInvisible1, 100, 0, millisec/2); 
	}
	setElementInvisible(idInvisible1);
	styTog(btnNormal1,'fontWeight', 'font-weight', 'normal');
    
    if(document.getElementById(idInvisible2).style.opacity == 100) { 
		opacity(idInvisible2, 100, 0, millisec/2); 
    }
	setElementInvisible(idInvisible2);
	styTog(btnNormal2,'fontWeight', 'font-weight', 'normal');
	
	if(document.getElementById(idInvisible3).style.opacity == 100) { 
		opacity(idInvisible3, 100, 0, millisec/2); 
    }
	setElementInvisible(idInvisible3);
	styTog(btnNormal3,'fontWeight', 'font-weight', 'normal');
	
	setElementVisible(idVisible);
	opacity(idVisible, 0, 100, millisec); 
	styTog(btnBold,'fontWeight', 'font-weight', 'bold');
	
}


/* 
styTog() -- a function to toggle CSS style attributes
This function accepts four parameters from the calling event:
targ_id, which is the id of the target element;
sty_attrJ, which is the style attribute's name in JavaScript syntax;
sty_attrC, which is the style attribute's name in CSS syntax;
set_val, which is the second toggle state value;

The element id, "zedSpan" is reserved for this function's use.
*/
function styTog(targ_id,sty_attrJ,sty_attrC,set_val){ 
var targ=document.getElementById(targ_id);
var targ_stat="";
var targ_sty="";
var attr_chk=sty_attrC.toLowerCase()
var excp_flag=0;
if(attr_chk.indexOf("color")!=-1 || attr_chk.indexOf("font")!=-1){
excp_flag=1;
if(!document.getElementById("zedSpan")){
var insSpan=document.createElement("span");
insSpan.setAttribute("id","zedSpan");
document.body.appendChild(insSpan);
}
var zS=document.getElementById("zedSpan").style
zS[sty_attrJ]=set_val;
}
if(targ.currentStyle){ //code for IE
if(excp_flag==1)set_val=zS[sty_attrJ];
targ_stat=targ.currentStyle[sty_attrJ];
}else{ //code for W3C-spec-compatible
if(excp_flag==1){
var tst_span=document.getElementById("zedSpan");
var tst_sty=document.defaultView.getComputedStyle(tst_span,"");
set_val=tst_sty.getPropertyValue(sty_attrC);
excp_flag=0;
}
targ_sty=document.defaultView.getComputedStyle(targ,"");
targ_stat=targ_sty.getPropertyValue(sty_attrC);
}
targ_stat!=set_val ? targ.style[sty_attrJ]=set_val : targ.style[sty_attrJ]="";
}

// <FunctionsForTextBoxesInMultilineMode>
// Keep user from entering more than maxLength characters
function limitNumberOfCharactersOnKeypress(control){
    maxLength = control.getAttribute('MaxLength');
    value = control.value;
     if(maxLength && value.length > maxLength-1){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
     }
}
// Cancel default behavior
function limitNumberOfCharactersOnBeforePaste(control){
    maxLength = control.getAttribute('MaxLength');
     if(maxLength)
     {
          event.returnValue = false;
     }
}
// Cancel default behavior and create a new paste routine
function limitNumberOfCharactersOnPaste(control){
    maxLength = control.getAttribute('MaxLength');
    value = control.value;
     if(maxLength){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}
// </FunctionsForTextBoxesInMultilineMode>

function addListItemTitles(selBoxID) {
	selBox = document.getElementById(selBoxID);
	for (i=0; i<=selBox.length - 1; i++) {
		selBox.options[i].setAttribute('title',selBox.options[i].text);
	}
}

//AJAX
var oXmlHttp = null;
var callbackFunc = null;

function sendAjaxCall(url, callback, method) {
	//url: Name of the URL to call on the server (e.g.: http://www.aua.com/abc.aspx?paramter1=value1)
	//callback: Name of the function, which receives the result from the server
	try {
		// initialize the XMLHttp object
		if (!oXmlHttp){
			oXmlHttp = init();
		}else if(oXmlHttp.readyState!=0){
			oXmlHttp.abort();
			oXmlHttp = null;
			oXmlHttp = init();
		}
		//define global callback var for processrequest
		callbackFunc = callback;
		// define an event handler for the readystatechange event
		oXmlHttp.onreadystatechange = processRequest;
		
		if (method.toUpperCase() == "GET") {
			// make a HTTP GET request to the URL "ASYNCHRONOUSLY"
			oXmlHttp.open("GET", url, true);
		} else {
			oXmlHttp.open("POST", url, true);
			// unlike GET the XMLHttp object has to have this request header, if it is sent via POST
			// unlike GET, POST does not restrict the size of the payload that is sent to the server
			// !! setRequestHeader() should be called after open() !!
			oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
		}
		// send the request
		// the single argument of the send() method is for the request body
		// since the get method doesn't require a body, we must pass in null
		oXmlHttp.send(null);
	}
	catch(err) {
		if (oXmlHttp){
			oXmlHttp.abort();
			oXmlHttp = null;
		}
	}	
}

function processRequest() {
// The XMLHttp object has a property called readyState that changes as the request goes through and the response is received
// readyState of 0 signifies that the object has been created but the open() method hasn't been called
// readyState of 1 signifies that the open() method has been called but the request hasn't been sent
// readyState of 2 signifies that the request has been sent
// readyState of 3 signifies that a partial response has been received
// readyState of 4 signifies that all data has been received and the connection has been closed
// readyState of 4 signifies request is complete
	try {
		if (oXmlHttp.readyState == 4) {
		// status of 200 signifies sucessful HTTP call
			if (oXmlHttp.status == 200) {
				callbackFunc(oXmlHttp.responseText);
			}
			else{
				if (oXmlHttp){
					oXmlHttp.abort();
					oXmlHttp = null;
				}
			}
		}
	}
	catch(err) {
		if (oXmlHttp){
			oXmlHttp.abort();
			oXmlHttp = null;
		}
	}
}


function init() 
{
	// create cross-browser XMLHttp object
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		var aVersions = ["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];
		for (var i = 0; i < aVersions.length; i++){
			try{
				var initXmlHttpObject = new ActiveXObject(aVersions[i]);
				return initXmlHttpObject;
			} catch (oError) {
				//Do nothing
			}
		}
	}
}

// Thumbnail Zoom
function setZoom(img, dir, width, height, margin, zIndex, delay) {
  setTimeout(function() {
    if (img.dir==dir) {
      img.style.width=width;
      img.style.height=height;
      img.style.margin=margin;
      img.style.zIndex=zIndex;
      img.parentNode.parentNode.style.zIndex=zIndex;
    }
  }, delay);
}

function larger(img, width, height) {
  img.dir='rtl';
  now=parseInt(img.style.zIndex);
  for (i=now+1; i<=10; i++) {
    w=(width*(10+i))/20+'px';
    h=(height*(10+i))/20+'px';
    m=(-i)+'px 0 0 '+(-width*i/40)+'px';
    setZoom(img, 'rtl', w, h, m, i, 20*(i-now));
  }
}

function smaller(img, width, height) {
  img.dir='ltr';
  now=parseInt(img.style.zIndex);
  for (i=now-1; i>=0; i--) {
    w=(width*(10+i))/20+'px';
    h=(height*(10+i))/20+'px';
    m=(-i)+'px 0 0 '+(-width*i/40)+'px';
    setZoom(img, 'ltr', w, h, m, i, 20*(now-i));
  }
}