// JavaScript Document
var nn4 = document.layers;
var nn6ie7 = document.getElementById;
var nn = nn4 || nn6ie7;
var ie = document.all && !nn;
var dhtml = document.getElementById || document.all || document.layers;

function js_object(myRef) 
	{   
	if (!dhtml) {return;}
	if (nn6ie7) {myRef = document.getElementById(myRef);}
	else if (nn4) {myRef = document.layers[myRef];}
	else {myRef = document.all[myRef];}
	return(myRef);
	}
	
function showobject(objectid,labelid,showlabel,hiddenlabel)
	{
	if (js_object(objectid).style.display==='block')//visible[objectid]
		{
		js_object(objectid).style.display="none";
		js_object(labelid).value=showlabel;
		}
	else
		{
		js_object(objectid).style.display="block";
		js_object(labelid).value=hiddenlabel;
		}
	}
	
function showmanyfiles()	
	{
	var codehtml="";
	var numoffile;
	numoffile=js_object('manyfiles').value;
	for (i=1;i<=numoffile;i++)
		{
		codehtml+= '<input type="file" name="userfile[]" size="30"/><br/>';
		}
	js_object('userfileitem').innerHTML	= codehtml;
	}
	
function getfilepath(editorfc,filepath,pathprefix)
	{
	if (pathprefix==null)
		pathprefix='../files/editor/';
	window.opener.CKEDITOR.tools.callFunction( editorfc, pathprefix+filepath);
	window.close();
	}

function InsertHTML(code)
{
	// Get the editor instance that we want to interact with.
	var oEditor = CKEDITOR.instances.postpagecontent;
	var value = js_object(code).value;

	// Check the active editing mode.
	if ( oEditor.mode == 'wysiwyg' )
	{
		// Insert the desired HTML.
		oEditor.insertHtml( value );
	}
	else
		alert( 'You must be on WYSIWYG mode!' );
}
function checksecurity(formid,securityid,list,keys,msg)
	{
	var a_list=new Array();
	var a_keys=new Array();
	var codecheck='';
	var a_list=list.split(',');
	var a_keys=keys.split(',');
	for (i=0;i<a_keys.length;i++)
			{
			codecheck+=(a_list[a_keys[i]]);
			}
	if(codecheck != js_object(securityid).value)
		{
		sfm_show_error_msg(msg);
		return false;
		}
	else
		{
		return true;
		}
	}
function popup(name,popupath,title,option)
	{
	popup[name] = window.open(popupath, title, option);
	}	
function test(msg)
	{
	alert (msg);	
	return true;
	}
