﻿//-------------
// Popup
//-------------

// Define popup window parameters
var popupDefaultParams = 'status=no,toolbar=no,menubar=no,location=no,directories=no,top=10,left=10';
var popupDefaultWidth = 540;
var popupDefaultHeight = 550;

// Open popup
function openPopup(url, name, width, height, resizable, scrollbars)
{                    
		// Open the window    
		window.open(
				url, 
				name, 
				popupDefaultParams +         
				',width=' + (width != null ? width : popupDefaultWidth) + 
				',height=' + (height != null ? height : popupDefaultHeight) + 
				',resizable=' +(resizable != null && resizable ? 'yes' : 'no') +
				',scrollbars=' + (scrollbars != null && scrollbars ? 'yes' : 'no'));
}

// Open help popup
function openHelp(id)
{
		openPopup('help.aspx?id=' + id, 'help', null, null, null, null);
}

//---------------------
// Time and date function
//---------------------
function getCacheID()
{
		var date = new Date();
		return date.getHours() + date.getMinutes();
}

// --------------------
// Cookies
// --------------------
function del_cookie(name, listToClear)
{
	document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
	if (listToClear)
	{
		document.getElementById(listToClear).innerHTML = '';
	}
} 

/*
//---------------------
// Cross window pasting
//---------------------
var pasteTimer = null;
var pasteFunction = null;

// Get a document selection
function getSelection(context)
{
		if (context.getSelection)
		{
				return context.getSelection();
		}
		else if (context.selection && document.selection.createRange) 
		{
			 var range = context.selection.createRange();
			 return range.text;           
		}
}

// Enable the cross window pasting
function enableCrossWindowPasting(pasteCallbackFunction, context)
{   
		if (!context)
				context = document;

		// Look for the paste input variable
		var src = document.getElementById("__PASTEIN");
		if (src)
		{
				src.value = getSelection(context);      
		}
		
		// Store callback function
		pasteFunction = pasteCallbackFunction;
			
		// Start the timer
		pasteTimer = setInterval('tryPaste()', 1000);
		
} 

// Disable the cross window pasting 
function disableCrossWindowPasting()
{
		// Stop interval
		if (pasteTimer)
		{
				clearInterval(pasteTimer);     
				pasteTimer = null;          
		}
		
		// Clear any paste value
		var elem = document.getElementById('__PASTEOUT');
		if (elem && elem.value.length > 0)
				elem.value = null;  // Clear        
}

// Check if paste is required
function tryPaste()
{
		// Look for the paste value
		var dest = document.getElementById('__PASTEOUT');
		if (dest && dest.value.length > 0)
		{         
			 // Stop interval
			 if (pasteTimer)
			 {
						clearInterval(pasteTimer);         
						pasteTimer = null;          
			 }

				// Paste
				if (pasteFunction)
				{
						eval(pasteFunction);
				}
						
			 // Clear paste information
			 dest.value = null;       
		}
}

// Copy a value from the opener __PASTEIN variable
function copyFromOpener(name)
{
		if (window.opener && !window.opener.closed)
		{
				var src = window.opener.document.getElementById('__PASTEIN'); 
				if(src && src.value.length > 0)
				{
						var dest = document.getElementById(name);
						if (dest)
						{
								dest.value = src.value;
						}
				}
		}    
}

// paste a value to the opener __PASTEOUT variable
function pasteToOpener(value)
{
		if (window.opener && !window.opener.closed)
		{
				var dest = window.opener.document.getElementById('__PASTEOUT'); 
				if(dest)
				{
						dest.value = value;
				}
		}    
}

// Helper to perform a paste to a FCKEditor
function pasteToFCKEditor(name)
{
	 FCKeditorAPI.GetInstance(name).InsertHtml(document.getElementById('__PASTEOUT').value); 
}
*/
 

