// ========================================
//
// 			Class DSPRemoteScript
//
// ========================================
// Konstruktor
// ========================================

function CMSRemoteScript(name)
{
	this.dspName 	= name;			// Scriptname
	this.dspActions = new Array();	// Actions
	
// ========================================
// Aktion erstellen
// ========================================

	this.addAction = function(method,component)
	{
		var action;
		
		action 			 = new Object();
		action.parameter = new Array();
		action.method 	 = method;
		action.component = component;
		
		this.dspActions.push(action);
	}
	
// ========================================
// Paremeter erstellen
// ========================================

	this.addParameter = function(index,name,value,type)
	{
		var action,parameter;
		
		try
		{
			action			= this.dspActions[index];
			parameter 		= new Object();
			parameter.name 	= name;
			parameter.type  = type;
			parameter.value = value;
			
			action.parameter.push(parameter);
		}
		catch(e) {return;}
	}
	
// ========================================
// Aktion senden
// ========================================

	this.sendAction = function()
	{
		var method,component,parameter;
		var text,url;
				
		url     = "http://"   + window.location.host + "/action_dsp?SCRIPT=onRemoteAction";		
		url    += "&SESSION=" + DSPCurrentPage.dspSessionID + "&PAGE=" + DSPCurrentPage.dspName;
		url    += "&SET=local&PARAM=";
		
		text = "<DSPScript name=\"" + this.dspName + "\">";
		
		for(var i=0; i < this.dspActions.length; i++)
		{
			method 	  = this.dspActions[i].method;
			component = this.dspActions[i].component;
			parameter = this.dspActions[i].parameter;
			
			text += "<DSPAction method=\"" + method + "\" component=\"" + component + "\">";
			
			for(var n=0; n < parameter.length; n++)
			{
				text += "<DSPParameter name=\"" + parameter[n].name + "\" ";
				text += "type=\""  + parameter[n].type  + "\" ";
				text += "value=\"" + parameter[n].value + "\"></DSPParameter>";
			}
			
			text += "</DSPAction>";
		}
	
		text += "</DSPScript>";
		url  += escape(text);
		window.location = url;
	}
	
	return(this);
}

// ==================================================
// Sucht einen Frame
// ==================================================

	function CMSFindFrame(win,name)
	{
		var hit,frame,max;
		
		max = win.frames.length;
		
		for(var i=0; i<max; i++)
		{
			frame = win.frames[i];
			
			if(frame.name == name) return(frame);
			else
			{
				if(frame.frames.length > 0)
				{
					hit = CMSFindFrame(frame,name);
					if(hit != null) return(hit);
				}
			}
		}
		
		return(null);
	}

// ==================================================
// Oeffnet ein neues Fenster
// ==================================================

	function CMSOpenWindow(url,name,width,height,location,menubar,toolbar,resizable,scrollbars)
	{
		var gui;
		
		gui = "width=" + width + ",height=" + height;
		
		if(location)   gui += ",location=" 	 + location;
		if(menubar)    gui += ",menubar="	 + menubar;
		if(toolbar)    gui += ",toolbar="	 + toolbar;
		if(resizable)  gui += ",resizable="	 + resizable;
		if(scrollbars) gui += ",scrollbars=" + scrollbars;
		
		window.open(url,name,gui);
	}
	
// ==================================================
// Fuehrt einen Link aus
// ==================================================

	function CMSLinkTo(url,target)
	{
		var frame;

		if(target)
		{
			frame = DSPFindFrame(top,target);
		}
		else frame = window;

		window.location = url;
	}

// ==================================================
// Wechselt eine Bildurl aus
// ==================================================

	function CMSSwitchImage(image,url)
	{
		image.src = url;
	}
