var path_design='design/index.html';
var fscommands=(navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1);

if (fscommands) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub flash_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call flash_command(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}

function flash_html(src,width,height,id,bgcolor,flashvars) {
	//flashvars+='&fscommands='+(fscommands?1:0);
	if ((bgcolor=='')||(!bgcolor)) bgcolor='#000000';
	var html='';
	html+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	html+='   codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0"';
 	html+='   width="'+width+'"';
 	html+='   height="'+height+'"';
 	html+='   id='+id+'>';
	html+='<param name=movie value="'+src+'">';
	html+='<param name=flashvars value="'+flashvars+'">';
	html+='<param name=quality value=high>';
	html+='<param name=menu value=false>';
	html+='<param name=bgcolor value='+bgcolor+'>';
	html+='<embed quality=high type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" menu="false"';
	html+=' 	src="http://www.hurch.pl/'+src+'"';
 	html+='   bgcolor='+bgcolor;
 	html+=' 	width="'+width+'"';
 	html+='		height="'+height+'"';
 	html+='		flashvars="'+flashvars+'">';
 	html+='</embed>';
	html+='</object>';
	return(html);
}

function flash_generate(src,width,height,id,bgcolor,flashvars,install) {
	var html='';
	if (flash_version()>=6) {
		html+=flash_html(src,width,height,id,bgcolor,flashvars);
	} else if (install) {
	  html+='<p>Do prawidłowego działania serwisu wymagany jest plugin Macromedia Flash 6 lub nowszy.</p><p>';
	  html+=flash_html(path_design+'flash.swf',70,70,'href=index.php');
    html+='</p><p>Nie widzisz animacji? Zainstaluj plugin:</p><p>';
    html+='<a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target=_blank><img src="http://www.hurch.pl/'+path_design+'flash.gif" width=75 height=75></a>';
    html+='</p>';
	}
	document.write(html);
}

function flash_version() {
	var i,v=0;
	if (navigator.plugins.length) {
	  var p=navigator.plugins;
    if ((p)&&(p.length>0)&&(p['Shockwave Flash']))	{
	    var w=p['Shockwave Flash'].description.split(' ');
		  for(i=0;i<w.length;i++) {
		    var j=parseInt(w[i]);
		    if (!isNaN(j))
		      v=Math.max(v,j);
		  }
    }
    return(v);
  } else {
	  for(v=10;v>0;v--) {
      var x=null;
      try {
        x=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+v);
      } catch(e) {}
      if (x) return(v);
    }
    return(0);
	}
}

function flash_command(command,text) {
  //alert(command+' - '+text);
  
	if (command=='open_window') {
	  var v=text.split(',');
		open_window(v[2],v[0],v[1]);
	} else if (command=='open_file') {
	  var v=text.split(',');
		open_file(v[2],v[0],v[1]);
	} else if (command=='open_news') {
		open_news(text);
	} else if (command=='open_search') {
	  var v=text.split(',');
		open_search(v[0],v[1]);
	} else if (command=='open_extranet') {
	  var v=text.split(',');
		open_extranet(v[0],v[1],v[2]);
	}
} 

function favourites() {
	window.external.AddFavorite('http://www.impactmedia.pl/','IMPACT MEDIA');
}

// --------------- open

function open_flash(path) {
	if ((window.opener)&&(!window.opener.closed)) {
		window.opener.location=path;
		window.opener.focus();
	} else {
		var w=window.open(path,'impact_flash');
		w.focus();
	}
}

function open_window(path,dx,dy,target) {
  var w=window.open(path,target,'scrollbars,status=1,resizable=1,width='+dx+',height='+dy+',left='+(screen.width-dx)/2+',top='+(screen.height-dy)/2);
  w.focus();
}

function open_file(path,dx,dy) {
  if (window.window_file)
  	window.window_file.close();
  window.window_file=window.open(path,'impact_file','scrollbars,status=1,resizable,width='+dx+',height='+dy+',left='+((screen.width-dx)/2)+',top='+((screen.height-dy)/2));
  window.window_file.focus();
}

function open_news(path) {
  var w=window.open(path,'impact_news','scrollbars,status=1,resizable=1,width=400,height=480,left=100,top=30');
  w.focus();
}

function open_search(language,search) {
  var w=window.open('/search.php?search='+search+'&language='+language,'impact_window','scrollbars,status=1,resizable=1,width=400,height=480,left=20,top=30');
  w.focus();
}

function open_map(language) {
  var w=window.open('/map.php?language='+language,'impact_window','scrollbars,status=1,resizable=1,width=400,height=480,left=20,top=30');
  w.focus();
}

function open_extranet(language,login,password) {
  var w=window.open('/extranet.php?language='+language,'impact_window','scrollbars,status=1,resizable=1,width=400,height=480,left=20,top=30');
  w.focus();
}