/************************************************************************
*	Module:         /js/js.js
*	Description:    common JScript functions
*	Company:        Net4You
************************************************************************/
function admin(mpage){
   document.onkeydown=function keyC(e){
       if(!document.all){
           startLocation = e.which;
       }else{
           startLocation = event.keyCode;
       }
       if(startLocation == 113){
           window.location = mpage;
       }
   }
}

//
// General Routines
//
function OpenWindow( sUrl, sWndName, nWidth, nHeight )
{
	var wnd = top.open( sUrl , sWndName, "scrollbars=0,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,width=" + nWidth +  ",height=" + nHeight );
	wnd.focus();
	return false;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

//
// Preview handling
//
function previewDescription( sFrameName, sText )
{
	window.frames[ sFrameName ].document.clear();
	window.frames[ sFrameName ].document.write( '<html><body><table width="100%"><tr><td><pre style="font-family: arial,tahoma,verdana;">' + sText + '</pre></td></tr></table></body></html>' );
	window.frames[ "divDescriptionPreview" ].document.close();
}

function previewPicture( sImageTagID, sImageFile )
{
	var oImage = MM_findObj( sImageTagID );
	if ( '' != sImageFile && null != oImage )
	{
		oImage.src = 'file://' + sImageFile;
	}
}

var checkflag = "false";
function check(field) {
	if (checkflag == "false") {
	for (i = 0; i < field.length; i++) {
		field[i].checked = true;}
		checkflag = "true";
		return "Размаркирай всички";
	}else {
		for (i = 0; i < field.length; i++) {
		field[i].checked = false; }
		checkflag = "false";
		return "Избери всички";
	}
}

function ValidateDelete(form){
	txt=form.action.options[form.action.selectedIndex].value
	option=txt
	if (option=="Delete"){
//		if ( confirm( "<?=$asRes[ 'SURE_DELETE' ]?>" ) ) {return true;} else {return false;}
		alert( "<?=$asRes[ 'SURE_DELETE' ]?>" );
		return false;
	}else{
		return true;
	}
}