function checkradio(feld){
	for (i=0; i<feld.length; i++){
			if(feld[i].checked == true){
				return feld[i].value;
			}
	}
}
function loadingindicator(what) {
	if(what == true || what == 1 || what == 'start' || what=='on') {
		document.getElementById('loadingdiv').style.visibility='visible';	
	
	} else {
		document.getElementById('loadingdiv').style.visibility='hidden';	
	}
}
function placeparse (place) {
		var details = new Array();
		details[0] = new Object();
		details[0]["address"] = place.address;
		details[0]["CountryName"] = place.AddressDetails.Country.CountryName;
		details[0]["CountryNameCode"] = place.AddressDetails.Country.CountryNameCode;
		place = place.AddressDetails.Country;
		if(place.AdministrativeArea!=null) {
			details[0]["AdministrativeAreaName"] = place.AdministrativeArea.AdministrativeAreaName;
			place = place.AdministrativeArea;
		}
		if(place.SubAdministrativeArea != null) {
			details[0]["SubAdministrativeAreaName"] = place.SubAdministrativeArea.SubAdministrativeAreaName;
			place = place.SubAdministrativeArea;
		}
		if(place.Locality!=null) {
		   details[0]["LocalityName"] = place.Locality.LocalityName;
		   place = place.Locality;
		}
		if(place.DependentLocality != null) {
			details[0]["DependentLocalityName"] = place.DependentLocality.DependentLocalityName;
			place = place.DependentLocality;
		}

		
		
		if(place.PostalCode != null) {details[0]["PostalCodeNumber"] = place.PostalCode.PostalCodeNumber;}
		if(place.Thoroughfare!=null) {details[0]["ThoroughfareName"] = place.Thoroughfare.ThoroughfareName;}
		return details;
}


function validatemail(str) {

	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1){
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		return false;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		return false;
	 }
	
	 if (str.indexOf(" ")!=-1){
		return false;
	 }

	 return true	;				
}


function toggledisplay(id) {
	if(document.getElementById(id).style.display=='block') {
		document.getElementById(id).style.display='none';
	} else {
		document.getElementById(id).style.display='block';
	}

	
}
function toggledisplayfade(id) {
	if(document.getElementById(id).style.display=='none') {
		new Effect.Appear(id, { duration: 1.0 });
		new Effect.SlideDown(id);
	} else {
		new Effect.Fade(id, { duration: 1.0 });
		new Effect.SlideUp(id);

	}
}

// start tabs
/*-----------------------------------------------------------
    Toggles element's display value
    Input: any number of element id's
    Output: none 
    ---------------------------------------------------------*/
function toggleDisp() {
    for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if (d.style.display == 'none')
            d.style.display = 'block';
        else
            d.style.display = 'none';
    }
}
/*-----------------------------------------------------------
    Toggles tabs - Closes any open tabs, and then opens current tab
    Input:     1.The number of the current tab
                    2.The number of tabs
                    3.(optional)The number of the tab to leave open
                    4.(optional)Pass in true or false whether or not to animate the open/close of the tabs
    Output: none 
    ---------------------------------------------------------*/
function toggleTab(num,numelems,opennum,animate) {
    if ($('tabContent'+num).style.display == 'none'){
        for (var i=1;i<=numelems;i++){
            if ((opennum == null) || (opennum != i)){
                var temph = 'tabHeader'+i;
                var h = $(temph);
                if (!h){
                    var h = $('tabHeaderActive');
                    h.id = temph;
                }
                var tempc = 'tabContent'+i;
                var c = $(tempc);
                if(c.style.display != 'none'){
                    if (animate || typeof animate == 'undefined')
                        Effect.toggle(tempc,'blind',{duration:0.5, queue:{scope:'menus', limit: 3}});
                    else
                        toggleDisp(tempc);
                }
            }
        }
        var h = $('tabHeader'+num);
        if (h)
            h.id = 'tabHeaderActive';
        h.blur();
        var c = $('tabContent'+num);
        c.style.marginTop = '2px';
        if (animate || typeof animate == 'undefined'){
            Effect.toggle('tabContent'+num,'blind',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
        }else{
            toggleDisp('tabContent'+num);
        }
    }
}

// end tabs
