/* DIALOG LAYER - CUSTOM ALERT */
	/*if(document.getElementById) {
		window.alert = function(txt) {
			calert(txt);
		}
	}
	*/
	function findPosition( obj ) {
	  if( obj.offsetParent ) {
	    for( var posX = 0, posY = 0; obj.offsetParent; obj = obj.offsetParent ) {
	      posX += obj.offsetLeft;
	      posY += obj.offsetTop;
	    }
	    return [ posX, posY ];
	  } else {
	    return [ obj.x, obj.y ];
	  }
	}
	function innerSize(){
		var Return = new Array();
		if( typeof( window.innerWidth ) == 'number' ) {
			Return[0] = window.innerWidth;
			Return[1] = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			Return[0] = document.documentElement.clientWidth;
			Return[1] = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			Return[0] = document.body.clientWidth;
			Return[1] = document.body.clientHeight;
		}
		return Return;
	}
	function CloseDia(){
		$('#dia').hide();
	}
	function cframeonload(){

		window.parent.element_display('dia_loading', 'none');

		var y;
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight;
		if (test1 > test2){
			y = document.body.scrollHeight;
		} else {
			y = document.body.offsetHeight;
		}
		window.parent.document.getElementById('dia_iframe').style.height = y+5+'px';
	}
	function cframe(Title, Url, Element, TopPosition, DiaWidth){

		var Element = Element || "none";
		var TopPosition = TopPosition || "none";
		var DiaWidth = DiaWidth || "none";

		/* RESET & THEN BUILD DIALOG LAYER */
			element_html('hidiv', '');
			var button = dia_button('Cancel / Close', 'Close', 'CloseDia()');
			var dialog = dia(Title, '<iframe id="dia_iframe" name="dia_iframe" class="diaiframe" src="'+Url+'" frameborder="0" height="100"></iframe>', button);

			element_html('hidiv', dialog);

		/* SET LOCATION & STYLES & LOADER */
			document.getElementById('dia_iframe').style.height = '100px';
			throbber_message('dia_loading', "Loading");

		/* SET HEIGHT */
			if((TopPosition != "none")){
				document.getElementById('hidiv').style.top = TopPosition+"px";

			} else {

				if((Element != "none")){
					var coords = findPosition(Element);
					if(coords[1]>250){
						document.getElementById('hidiv').style.top = (coords[1]-300)+"px";
						/*scroll(0,(coords[1]-300));*/
					} else {
						document.getElementById('hidiv').style.top = "330px";
						scroll(0,0);
					}
				} else {
					document.getElementById('hidiv').style.top = "330px";
					scroll(0,0);
				}

			}

		/* SET WIDTH IF SPECIFIED */
			if(DiaWidth!="none"){
				document.getElementById('dia_table').style.width = DiaWidth+"px";
				var OffsetWidth = DiaWidth/2;
			} else {
				var OffsetWidth = 400;
			}

		/* MOVE IT TO THE CENTER  */
			var width = returnWidth();
			document.getElementById('hidiv').style.right = (width/2)+OffsetWidth+'px';

		/* MAKE IT DRAGGABLE */
			new Draggable('hidiv', {handle:'dia_handle', starteffect:'', endeffect:''});

		return false;

	}
	function csubmit(Message){
		calert('<div id="dia_submit">_replace_</div>');
		throbber_message('dia_submit', Message);
		element_html('dia_buttons', '');
	}
	function calert(Message, Element, Height){

		Element = Element || "none";
		Height = Height || "none";

		var button = dia_button('Close', 'Close', 'CloseDia()');
		var dialog = dia('Note:', Message, button);

		element_html('hidiv', dialog);

		/* SET HEIGHT */
			if((Height != "none")){
				document.getElementById('hidiv').style.top = Height+"px";
			} else {

				if((Element != "none")){
					var coords = findPosition(Element);
					if(coords[1]>250){
						document.getElementById('hidiv').style.top = (coords[1]-250)+"px";
						scroll(0,(coords[1]-300));
					} else {
						document.getElementById('hidiv').style.top = "330px";
						scroll(0,0);
					}
				} else {
					document.getElementById('hidiv').style.top = "330px";
					scroll(0,0);
				}
			}

		/* MOVE IT TO THE RIGHT */
			var width = returnWidth();
			document.getElementById('hidiv').style.right = (width/2)+175+"px";

		/* MAKE IT DRAGGABLE */
			new Draggable('hidiv', {handle:'dia_handle', starteffect:'', endeffect:''});

		return false;
	}
	function returnWidth(){
		if (parseInt(navigator.appVersion)>3) {
			if (navigator.appName=="Netscape") {
				winW = window.innerWidth;
		 	}
		 	if (navigator.appName.indexOf("Microsoft")!=-1) {
				winW = document.body.offsetWidth;
		 	}
		}
		return winW;
	}
	function dia(TITLE, CONTENT, BUTTONS){
		var dia = '<div class="dia" id="dia"><table class="dia_table" id="dia_table"><tbody><tr><td class="dia_content"><h1 id="dia_handle" class="drag">' + TITLE + '</h1><div><div class="dia_body" id="dia_body"><div id="dia_loading"></div>' + CONTENT + '</div><div class="dia_buttons" id="dia_buttons">' + BUTTONS + '</div></div></td></tr></tbody></table></div>';
		return dia;
	}
	function dia_button(VALUE, NAME, ONCLICK){
		var button = '<input class="dia_submit" name="' + NAME + '" value="' + VALUE + '" onClick="' + ONCLICK + '" type="submit">';
		return button;
	}