/* Bluefish HTML Editor
 * javascript.c - javascript-functions - rather cool
 *
 * Copyright (C) 
 * 2000 Roland Steinbach
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */



#include "default_include.h"

#include <string.h>
#include <stdlib.h>

#include "cap.h"
#include "bluefish.h"
#include "document.h"

#include "javascript.h"

void mouseover_script_cb(GtkWidget * widget, gpointer data)
{
	insert_dbl_text
		("<script language=\"JavaScript\" type=\"text/javascript\">\n<!-- Begin\nfunction bfmovepic(img_name,img_src) {\ndocument[img_name].src=img_src;\n}\n// End -->\n</script>\n",
		 "");
}

void ns47_bugfix_script_cb(GtkWidget * widget, gpointer data)
{
	insert_dbl_text
		("<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\n// Javascript code that fixes a bug in some versions of Netscape Navigator\nfunction reloadPage(init)\n{  //reloads the window if Nav4 resized\n  if (init==true) with (navigator)\n	{\n	  if ((appName==\"Netscape\")&&(parseInt(appVersion)==4))\n		{\n      document.pgW=innerWidth;\n			document.pgH=innerHeight;\n      onresize=reloadPage;\n		}\n	}\n  else if (innerWidth!=document.pgW || innerHeight!=document.pgH)\n    location.reload();\n}\nreloadPage(true);\n// -->\n</script>\n",
		 "");
}

void imagepreload_script_cb(GtkWidget * widget, gpointer data)
{
	insert_dbl_text
	("<script language=\"JavaScript\" type=\"text/javascript\">\n<!-- Begin\nfunction bf_preloadImages() {\n  var d=document; if(d.images){ if(!d.bf_p) d.bf_p=new Array();\n  var i,j=d.bf_p.length,a=bf_preloadImages.arguments; for(i=0; i<a.length; i++)\n  if (a[i].indexOf(\"#\")!=0){ d.bf_p[j]=new Image; d.bf_p[j++].src=a[i];}}\n}/ -->\n</script>\n",
  "");
}
