function OpenWindow(url, name, spec) {
	 newwindow = window.open(url, name, spec); 
	 if (window.focus) {newwindow.focus()}
}

function CTChanger(obj, onoff) {
	if(onoff) {
		obj.src = obj.src.replace('.gif','_o.gif');
	}else{
		obj.src = obj.src.replace('_o.gif','.gif');
	}
}

function CTChangeSlideshow(divobj, obj, direction, numpix, speed) {
	var iNewPicNum = 1;
	var showHolder = document.getElementById(obj);
	if(showHolder) {
		hrefAr = showHolder.src.split('/');
		iCurrentPicNum = parseFloat(hrefAr[hrefAr.length-1].replace('.jpg',''));
		if(direction=='next'){
			if(iCurrentPicNum==numpix){
				iNewPicNum = 1;	
			}else{
				iNewPicNum = iCurrentPicNum + 1
			}
		}else{
			if(iCurrentPicNum==1){
				iNewPicNum = numpix;	
			}else{
				iNewPicNum = iCurrentPicNum - 1
			}
		}
		var newHref = '';
		for(xx=0;xx<hrefAr.length-1;xx++) {
			newHref = newHref + hrefAr[xx] + '/';
		}
		newHref = newHref + iNewPicNum + '.jpg';
		showHolder.alt='';
		BlendImage(divobj, obj, newHref, speed);
	}
}


var BlendImageRunning = false;
function BlendImage(divid, imageid, imagefile, millisec) { 
    if(!BlendImageRunning) {
		BlendImageRunning = true;
		var speed = Math.round(millisec / 100); 
		var timer = 0; 
		document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
		changeOpac(0, imageid); 
		document.getElementById(imageid).src = imagefile; 
		for(i = 0; i <= 100; i++) { 
			setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
			timer++;
		} 
	}
} 
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(opacity==100) {
		BlendImageRunning = false;
	}
} 

function clearField(fId, sMatch, sChange){
	if(sChange == null) sChange = '';
	if(fId.value == sMatch)
	{ fId.value = sChange; }
}

function isValidField(sText, iType){
	if(iType==1)
	{ ValidChars = "0123456789"; }
	else if(iType==2)
	{ ValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-@"; }
	else if(iType==3)
	{ ValidChars = "0123456789."; }
	else if(iType==4)
	{ ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "; }
	var isValid=true;
	var Char;
	for (i = 0; i < sText.length && isValid == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{ isValid = false; }
	}
	return isValid;
}

function loadGoogleMap(mapDiv, sLat, sLng, sZoom){
	geocoder = new GClientGeocoder();
	map = new GMap2(document.getElementById(mapDiv));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.removeMapType(G_HYBRID_MAP);
	map.addMapType(G_PHYSICAL_MAP);
	
	var givenmaptypes = map.getMapTypes();
	map.setMapType(givenmaptypes[0]);
	
	if(sLat && sLng) {
		if(!sZoom) {
			sZoom = 2;
		}
		map.setCenter(new GLatLng(sLat,sLng), sZoom);
		var point = new GLatLng(sLat,sLng);
		map.addOverlay(new GMarker(point,{clickable:false, title:'We are here!'}));
	}else{
		map.setCenter(new GLatLng(11.43695521614319,105.99609375), 4);	
	}
}




