//
//             Copyright (c) 2002, 2003 Smartlink Corp.
//                       All rights reserved.
//

var mailer_path = "mailer/";
var mailer_type =  "asp"; // "htm";

var print_path = "print//";
var fIE    = (window.showModalDialog ? true : false);
var fNS4   = !(document.getElementById);


function doCommand (cmd) {
//   var form = (m_iActiveForm == 0 ? m_sourceForm : m_targetForm);
//   if (!form)
//      return;
if(!m_curEl)
	return;
   var textCtrl =  m_curEl; // form.text;
   if (browser.ie && !browser.mac) {
      textCtrl.createTextRange ().execCommand (cmd);
   }
   else {
      switch (cmd) {
         case "Copy":
            m_clipboard = textCtrl.value;
            break;
         case "Paste":
            textCtrl.focus ();
            if (m_clipboard)
               textCtrl.value = m_clipboard;
            break;
         case "Delete":
            textCtrl.focus ();
            textCtrl.value = "";
            break;
         case "Cut":
            textCtrl.focus ();
            m_clipboard = textCtrl.value;
            textCtrl.value = "";
            break;
      }
   }
	return true;
   
}

function doSpell(ctrls)
{ 
	if(m_fspell) {
		kbdShowHide (false);
		var text;
		var lang = m_curLang;
		var query = 'lang=' + lang + '&dic=Normal';
		if( ctrls )
			text = ctrls;
		else 
			text = m_curEl;
			invokeSpeller(text, query);
	}
	return true;
}	

function doMail (type) 
{

	if(window.kbdShowHide) {
		kbdShowHide (false);
	}	

	var query = "?type=" + type;
	if(type == "email") {
		if( m_curFrame != "" ) 
			query +="&ctrl=" + m_curFrame + "/"+ m_curEl.name;
		else
			query +="&ctrl=" + m_curEl.name;

	}
	var url = "mailer.asp"
	if(mailer_type == "asp") {
		url = type + "_form.asp"
	}
	url = mailer_path + url + query;

	var height = 291;
	switch(type)
	{
		case "email":
			height  = 462;
			break;
		case "feedback":
			height  = 490;
			break;
		case "tellafriend":
			height  = 486;
			break;
	}
	
	if(fIE) {

	    var features = "dialogWidth:438px; dialogHeight:" + height +"px;scroll:no;help:no;status:no;";
		var args = { opener: this };
//		dialog = window.showModalDialog (url, args, features);
		dialog = showDialog_ (url, args, features);
	}
	else {
		dialog = window.open (url, "SendMail", "width=438,height="+height+",toolbar=no,status=no,menubar=no,directories=no,resizable=yes");
	}
	
	return true;
}


function showDialog_ (url, args, features) {
   var href = "", ref = url, query = "", arr = url.split ("?");
   if (arr.length > 1) {
      ref = arr [0];
      query = arr [1];
   }
   var sep = ref.lastIndexOf ("/");
   if (sep >= 0) {
      href = ref.substr (0, sep + 1);
      ref = ref.substr (sep + 1);
   }

   href += "dlgframe.htm" + "?ref=" + ref + (query ? "&" : "") + query;
   return window.showModalDialog (href, args, features);
}

function doDecode()
{
	kbdShowHide (false);

	var query;
	if( m_curFrame != "" ) 
			query = m_curFrame + "/"+ m_curEl.name;
		else
			query = m_curEl.name;

	//alert ("control to decode: " + query);
	invokeDecoder(query);

	// alert("The Decode Service is not available yet.")
}

function doPrint()
{
	var query = "?frame=" + m_curFrame + "&field="+m_curEl.name; 
	window.open( print_path + "printfrm.htm" + query,"", "toolbar=1,scrollbars=0,statusbar=no,width=500,height=400,resizable=1");
	return true;
}

function doHelp(id)
{
	var helpwindow;
	var paramStr;
	if (!id )
		paramStr = '';
	else
	 	paramStr = "?id=" + id;
	helpwindow = window.open("help/help.htm" + paramStr, "Help", "toolbar=0,scrollbars=1,statusbar=no,width=650,height=500,resizable=1");
	helpwindow.focus();
}