function changeComponent( component ) {
	
	
	if ( component == 'zones'){
			document.getElementById('zones').style.display = "block";			
			document.getElementById("zones").style.visibility="visible";
			document.getElementById('multimedia').style.display = "none";
			document.getElementById("multimedia").style.visibility="hidden";
	}
	else if ( component == ' multimedia' ) {
			document.getElementById('zones').style.display = "none";			
			document.getElementById("zones").style.visibility="hidden";
			document.getElementById('multimedia').style.display = "block";
			document.getElementById("multimedia").style.visibility="visible";

		
	}
	
}

function toggleLayer( whichLayer ) {
	
		var ourLayers = new Array( "cQL", "cMd", "cBus", "cOth" ); 
		var elem = new Array();
		var vis;// = new Array();
		var i=0;
  		var len=ourLayers.length;
  		
		for (i=0; i < len; i++ ){
			if( document.getElementById ) // this is the way the standards work
	    		elem[i] = document.getElementById( ourLayers[i] );
	  		else if( document.all ) // this is the way old msie versions work
	    		elem[i]  = document.all[ ourLayers[i] ];
	  		else if( document.layers ) // this is the way nn4 works
	    		elem[i]  = document.layers[ ourLayers[i] ];
		}

		for (i=0; i < len; i++ ){
			vis = elem[i].style;
  			
			if ( whichLayer == ourLayers[i] ) {
				//alert("Meake me visible" + whichLayer );
				vis.display = "block";
			}
			else {
				//alert("Hide Me" + ourLayers[i] );
				vis.display = "none";
				
			}
  			
  			// alert( "Element " + elem[i].name + " -> display = " + vis.display );
  				//ourLayers[i] );
  		}
  
}



function ChangeMyZone( frm, url ) {
	var zone = frm.value;
	window.location.href = url + "?zone=" + zone;
}

function changePage( action, page, query, string, value ){

	var url = "";
	page--;
	
	if ( query != "" ) {
		url = "?action="+action+"&page="+page+"&"+q+"="+s;
	}
	else{
		url = "?action="+action+"&page="+page;
	}
	window.location.href = url;
}

function redirect( url ){
		window.location.href = url;
}

function Trim(strInput) {
	return strInput.replace(/\s/g, '');
}

function PhotoViewer( popupLocation, id  ){
	
		popupLocation = "http://" + document.domain + "/model/multimedia/image/view.php" + "?id=" + id;
		var popupWidth = 1080;
		var popupHeight = 850;
		var statusBarOn = true;
	
		var heightspeed = 20; 	// vertical speed
		var widthspeed 	= 20;  	// horizontal speed
		var leftdist 	= (screen.width - popupWidth) / 2;    	// distance to left edge of window
		var topdist 	= (screen.height - popupHeight) / 2;   	// distance to top edge of window
		if (document.all)
		{
			if (statusBarOn) 
			{
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			} 
			else
			{ 
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			}
	
			for (sizeheight = 1; sizeheight < popupHeight; sizeheight += heightspeed) 
			{
				popup.resizeTo("1", sizeheight);
			}
			for (sizewidth = 1; sizewidth < popupWidth; sizewidth += widthspeed) 
			{
				popup.resizeTo(sizewidth, sizeheight);
			}
			
			popup.resizeTo(popupWidth, popupHeight);
			popup.location = popupLocation;
		}
		else
		{
			var popup = window.open(popupLocation,"","left=" + leftdist + ",top=" + topdist + ",width=" + popupWidth + ",height=" + popupHeight + ",scrollbars=yes");
		}
	
}

function PopUp( popupLocation  ){
	
		var popupWidth = 1050;
		var popupHeight = 850;
		var statusBarOn = true;
	
		var heightspeed = 20; 	// vertical speed
		var widthspeed 	= 20;  	// horizontal speed
		var leftdist 	= (screen.width - popupWidth) / 2;    	// distance to left edge of window
		var topdist 	= (screen.height - popupHeight) / 2;   	// distance to top edge of window
		if (document.all)
		{
			if (statusBarOn) 
			{
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			} 
			else
			{ 
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			}
	
			for (sizeheight = 1; sizeheight < popupHeight; sizeheight += heightspeed) 
			{
				popup.resizeTo("1", sizeheight);
			}
			for (sizewidth = 1; sizewidth < popupWidth; sizewidth += widthspeed) 
			{
				popup.resizeTo(sizewidth, sizeheight);
			}
			
			popup.resizeTo(popupWidth, popupHeight);
			popup.location = popupLocation;
		}
		else
		{
			var popup = window.open(popupLocation,"","left=" + leftdist + ",top=" + topdist + ",width=" + popupWidth + ",height=" + popupHeight + ",scrollbars=yes");
		}
	
}


function Selector( file, action, type, field ){
		
		var popupWidth = 1080;
		var popupHeight = 800;
		var statusBarOn = true;
	
		var heightspeed = 20; 	// vertical speed
		var widthspeed 	= 20;  	// horizontal speed
		var leftdist 	= (screen.width - popupWidth) / 2;    	// distance to left edge of window
		var topdist 	= (screen.height - popupHeight) / 2;   	// distance to top edge of window
		if (document.all)
		{
			if (statusBarOn) 
			{
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			} 
			else
			{ 
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			}
	
			for (sizeheight = 1; sizeheight < popupHeight; sizeheight += heightspeed) 
			{
				popup.resizeTo("1", sizeheight);
			}
			for (sizewidth = 1; sizewidth < popupWidth; sizewidth += widthspeed) 
			{
				popup.resizeTo(sizewidth, sizeheight);
			}
			
			popup.resizeTo(popupWidth, popupHeight);
			popup.location = file + "?action=" + action + "&type=" + type + "&field=" + field;
		}
		else
		{
			var popup = window.open(file + "?action=" + action + "&type=" + type + "&field=" + field,"","left=" + leftdist + ",top=" + topdist + ",width=" + popupWidth + ",height=" + popupHeight + ",scrollbars=yes");
		}
}

function DatePicker( calendar, field ){
		
		var popupWidth = 300;
		var popupHeight = 300;
		var statusBarOn = true;
	
		var heightspeed = 20; 	// vertical speed
		var widthspeed 	= 20;  	// horizontal speed
		var leftdist 	= (screen.width - popupWidth) / 2;    	// distance to left edge of window
		var topdist 	= (screen.height - popupHeight) / 2;   	// distance to top edge of window
		if (document.all)
		{
			if (statusBarOn) 
			{
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			} 
			else
			{ 
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			}
	
			for (sizeheight = 1; sizeheight < popupHeight; sizeheight += heightspeed) 
			{
				popup.resizeTo("1", sizeheight);
			}
			for (sizewidth = 1; sizewidth < popupWidth; sizewidth += widthspeed) 
			{
				popup.resizeTo(sizewidth, sizeheight);
			}
			
			popup.resizeTo(popupWidth, popupHeight);
			popup.location = calendar + "?field=" + field;
		}
		else
		{
			var popup = window.open(calendar + "?field=" + field,"","left=" + leftdist + ",top=" + topdist + ",width=" + popupWidth + ",height=" + popupHeight + ",scrollbars=yes");
		}
}

function DateTimePicker( calendar, field ){
		
		var popupWidth = 300;
		var popupHeight = 300;
		var statusBarOn = true;
	
		var heightspeed = 20; 	// vertical speed
		var widthspeed 	= 20;  	// horizontal speed
		var leftdist 	= (screen.width - popupWidth) / 2;    	// distance to left edge of window
		var topdist 	= (screen.height - popupHeight) / 2;   	// distance to top edge of window
		if (document.all)
		{
			if (statusBarOn) 
			{
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			} 
			else
			{ 
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			}
	
			for (sizeheight = 1; sizeheight < popupHeight; sizeheight += heightspeed) 
			{
				popup.resizeTo("1", sizeheight);
			}
			for (sizewidth = 1; sizewidth < popupWidth; sizewidth += widthspeed) 
			{
				popup.resizeTo(sizewidth, sizeheight);
			}
			
			popup.resizeTo(popupWidth, popupHeight);
			popup.location = calendar + "?field=" + field;
		}
		else
		{
			var popup = window.open(calendar + "?field=" + field,"","left=" + leftdist + ",top=" + topdist + ",width=" + popupWidth + ",height=" + popupHeight + ",scrollbars=yes");
		}
}


function returnDate(date, field){

	if (window.opener && !window.opener.closed) {
		
    	window.opener.insertDate(date, field);
	}
    
	window.close();
}


function ChangeMonth(year, field) {

	var frm = document.calendar;
	changeMonth = frm.month.value;

	window.location.href = "calendar.php?month=" + changeMonth + "&year=" + year + "&field=" +field;

}

function Month(month, year, field ){

	if ( month < 1 ) {
		window.location.href = "calendar.php?month=" + 12 + "&year=" + (year-1) + "&field=" +field;
	}
	else if ( month > 12 ) {
		window.location.href = "calendar.php?month=" + 1 + "&year=" + (year+1) + "&field=" +field;
	}
	else {
		window.location.href = "calendar.php?month=" + month + "&year=" + year + "&field=" +field;
	}

	
}


function isSystemDate( date ){
	return true;
}

function ChangeYear( month, field ) {
	var frm = document.calendar;
	window.location.href = "calendar.php?month=" + month + "&year=" + frm.year.value + "&field=" +field;
}

function Help( topic  ){
	
		popupLocation = "http://help.ezyzone.com/?topic="+ topic;
		
		var popupWidth = 1050;
		var popupHeight = 800;
		var statusBarOn = true;
	
		var heightspeed = 20; 	// vertical speed
		var widthspeed 	= 20;  	// horizontal speed
		var leftdist 	= (screen.width - popupWidth) / 2;    	// distance to left edge of window
		var topdist 	= (screen.height - popupHeight) / 2;   	// distance to top edge of window
		if (document.all)
		{
			if (statusBarOn) 
			{
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			} 
			else
			{ 
				var popup = window.open("","","left=" + leftdist + ",top=" + topdist + ",width=4,height=4,scrollbars=yes,resizable=yes,status=yes");
			}
	
			for (sizeheight = 1; sizeheight < popupHeight; sizeheight += heightspeed) 
			{
				popup.resizeTo("1", sizeheight);
			}
			for (sizewidth = 1; sizewidth < popupWidth; sizewidth += widthspeed) 
			{
				popup.resizeTo(sizewidth, sizeheight);
			}
			
			popup.resizeTo(popupWidth, popupHeight);
			popup.location = popupLocation;
		}
		else
		{
			var popup = window.open(popupLocation,"","left=" + leftdist + ",top=" + topdist + ",width=" + popupWidth + ",height=" + popupHeight + ",scrollbars=yes");
		}
	
}

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function isPointValue(str) {
    str = alltrim(str);
    return /^[-+]?[0-9]+(\.[0-9]+)?$/.test(str);
}

function alltrim(str) {
                return str.replace(/^\s+|\s+$/g, '');
}

