var MM_contentVersion = 8;
var MM_FlashCanPlay = false;
var plugin = ( navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin )
{
	var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	for (var i = 0; i < words.length; ++i)
	{
		if (isNaN(parseInt(words[i])))
			continue;
		var MM_PluginVersion = words[i]; 
	}
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1))
{
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}
var ver = ( parseFloat( navigator.appVersion ) >= 4 );
var msie = ( navigator.appVersion.indexOf( "MSIE" ) != -1 );

function jump( form )
{
	if( form == null )
		form = 'mainform';
	var f = document.forms[ form ];
	if( !f.pagejump.value.length )
	{
		f.pagejump.selectedIndex=0;
		return;
	}
	f.task.value = 'jump';
	try {
		f.onsubmit();
	}
	catch(e){}
	f.submit();
}
function SubmitForm( form, task )
{
	if( form == null )
		form = 'mainform';
	var f = document.forms[ form ];
	if( typeof( f ) != 'object' )
		return;
	f.task.value = task;
	try
	{
		f.onsubmit();
	}
	catch (e){}
	f.submit();
}
function ResetForm( form )
{
	if( form == null )
		form = 'mainform';
	var f = document.forms[ form ];
	try
	{
		f.reset();
	}
	catch (e){}
}

function SubmitStatusTelefonu( form )
{
	if( form == null )
		form = 'mainform';
	var f = document.forms[ form ];
	if( typeof( f ) != 'object' )
		return;
	if( f.imei.value.length == 0 && f.zlecenie.value.length == 0 )
	{
		alert( 'Podaj numer zlecenia lub numer IMEI!' );
		return false;
	}
	//f.action = 'http://status.teleko.com.pl/index.php';
	f.action = 'index.php';
	try
	{
		f.onsubmit();
	}
	catch (e){}
	f.submit();
}
function SubmitRepairForm( form, todo )
{
	if( form == null )
		form = 'mainform';
	var f = document.forms[ form ];
	if( typeof( f ) != 'object' )
		return;
	f.target = 'repairform';
	f.task.value = todo;
	try
	{
		f.onsubmit();
	}
	catch (e){}
	f.submit();
}
function is_nip_ok1( v ) {
	if( v == '' ) return;
	if( vnip == v ) return vnip_ok;
	vnip = v;
	vnip_ok = false;
	var re = /^[0-9]{10}$/i;
	if( !v.match( re ) ) {
		alert( "Nr NIP jest niewła¶ciwy!" );
		return false;
	}
	var w = Array(6,5,7,2,3,4,5,6,7);
	var sum = 0;
	for(i=0;i<9;i++)
		sum += v.charAt(i)*w[i];
	if( ((sum % 11) % 10) != v.charAt(9) ) {
		alert( "Nr NIP jest niewła¶ciwy!" );
		return false;
	}
	vnip_ok = true;
	return true;
}
function is_nip_ok( v ) {
	var re = /^[0-9]{10}$/i;
	if( !v.match( re ) ) {
		return false;
	}
	var w = Array(6,5,7,2,3,4,5,6,7);
	var sum = 0;
	for(i=0;i<9;i++)
		sum += v.charAt(i)*w[i];
	if( ((sum % 11) % 10) != v.charAt(9) ) {
		return false;
	}
	return true;
}
function is_email_ok( v ) {
	var re = /^[a-z0-9]+([\-\._][a-z0-9]+)*\@[a-z0-9]+([\-\._][a-z0-9]+)*\.[a-z0-9]{2,4}$/i;
	if( !v.match( re ) )
		return false;
	return true;
}
function is_zip_ok( v ) {
	var re = /^[0-9]{2}-[0-9]{3}$/i;
	if( !v.match( re ) )
		return false;
	return true;
}

function doFlash( name, fname, width, height,  bgcolor )
{
	if( bgcolor == null )
		bgcolor='#ffffff';

	if ( MM_FlashCanPlay )
	{
		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
		document.write(' ID="'+name+'" WIDTH="'+width+'" HEIGHT="'+height+'" ALIGN="">');
		document.write('<PARAM NAME="movie" VALUE="'+fname+'" />');
		document.write('<PARAM NAME="quality" VALUE="high" />');
		if( bgcolor != -1 )
		{
			document.write('<PARAM NAME=bgcolor VALUE='+bgcolor+' />');
			document.write('<EMBED src="'+fname+'" quality=high bgcolor='+bgcolor);
		}
		else
		{
			document.write('<PARAM NAME="wmode" VALUE="transparent" />');
			document.write('<EMBED src="'+fname+'" quality="high" wmode="transparent"');
		}
		document.write(' swLiveConnect="FALSE" WIDTH="'+width+'" HEIGHT="'+height+'" NAME="'+name+'" ALIGN=""');
	    document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
		document.write('</EMBED>');
	    document.write('</OBJECT>');
	}
	else
	{
		document.write('<IMG SRC="'+fname+'.gif" WIDTH="'+width+'" HEIGHT="'+height+'" usemap="#'+name+'" BORDER=0>');
	}
}

function openPic_old(imageName,imageWidth,imageHeight,alt,posLeft,posTop) {
	newWindow = window.open("","newWindow","alwaysRaised,scrollbars=auto,status=no,titlebar=no,toolbar=no,hotkeys=no,location=no,menubar=no,resizable=yes,width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><head><title>'+alt+'</title></head><body onload="window.focus()" bgcolor="#000000" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="/*self.close()*/"><table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%"><tr><td align="center" valign="center">'); 
	newWindow.document.write('<a href="#" onclick="window.close()"><img border="0" src="'+imageName+'" width="'+imageWidth+'" height="'+imageHeight+'" alt="'+alt+'" /></a>'); 
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function openPic(img,w,h,alt,left,top,margin) {

	// 720x405 -> 16:9 :)
	var dw = 720;
	var dh = 405;

	if( margin == null )
		margin = 0;

	newWindow = window.open("","newWindow","alwaysRaised,scrollbars=auto,status=no,titlebar=no,toolbar=no,hotkeys=no,location=no,menubar=no,resizable=yes,width="+(w?w+2*margin:dw+2*margin)+",height="+(h?h+2*margin:dh+2*margin)+",left="+left+",top="+top);
	newWindow.document.open();

	var xh = 0;
	if( typeof( document.all ) != 'object' )
		xh = 20;

	var strImg = '';
	if( w )
	{
		strImg += '<img border="0" src="'+img+'" width="'+w+'" height="'+h+'" alt="'+alt+'" />';
	}
	else
	{
		if( typeof( document.all ) == 'object' )
			strImg += '<img onload="window.resizeTo(this.width+'+(2*margin)+',this.height+'+(2*margin)+');" border="0" src="'+img+'" alt="'+alt+'" />';
		else
			strImg += '<img onload="window.resizeTo('+dw+','+dh+');window.resizeTo(this.width+'+(dw+2*margin)+'-window.innerWidth,this.height+'+(dh+2*margin)+'-window.innerHeight);" border="0" src="'+img+'" alt="'+alt+'" />';
	}

	var str = '';
	str += ''
		+'<html>'
		+'<head>'
		+'<title>'+alt+'</title>'
		+'</head>'
		+'<body onload="window.focus()" bgcolor="#000000" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="/*self.close()*/">'
		+'<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">'
		+'<tr>'
		+'<td align="center" valign="center">'
		;
	if( strImg.substr( -4 ) == '.swf' )
	{
		str += ''
			+'FLASH!!!'
			+strImg
			+''
			;
	}
	else
	{
		str += ''
			+'<a href="javascript:window.close()">'
			+strImg
			+'</a>'
			;
	}

	str += ''
		+'</td>'
		+'</tr>'
		+'</table>'
		+'</body>'
		+'</html>'
		;
	newWindow.document.write( str );
	newWindow.document.close();
	newWindow.focus();
}

function setAsHomePage() {
	if( window.external ) {
		overDiv.style.behavior = 'url(#default#homepage)';
		overDiv.setHomePage('http://www.teleko.eu');
	}
}

function PopupSwieta()
{
//	openPic( 'pl_img/popup_swieta.jpg',300,232,'TELEKO - Wesołych Świąt i Szczęśliwego Nowego Roku!',0,0, 20 );
}
/*
function PopupSwietaOnTimer()
{
	grphcs=new Array(6)
	Image0=new Image();
	Image0.src=grphcs[0]="/fileadmin/template/main/images/werbeformen/online/flyinglayers/al.gif";
	Image1=new Image();
	Image1.src=grphcs[1]="/fileadmin/template/main/images/werbeformen/online/flyinglayers/bl.gif"
	Image2=new Image();
	Image2.src=grphcs[2]="/fileadmin/template/main/images/werbeformen/online/flyinglayers/cl.gif"
	Image3=new Image();
	Image3.src=grphcs[3]="/fileadmin/template/main/images/werbeformen/online/flyinglayers/dl.gif"
	Image4=new Image();
	Image4.src=grphcs[4]="/fileadmin/template/main/images/werbeformen/online/flyinglayers/el.gif"
	Image5=new Image();
	Image5.src=grphcs[5]="/fileadmin/template/main/images/werbeformen/online/flyinglayers/fl.gif" 

	Amount=4; //Smoothness depends on image file size, the smaller the size the more you can use!
	Ypos=new Array();
	Xpos=new Array();
	Speed=new Array();
	Step=new Array();
	Cstep=new Array();
	ns=(document.layers)?1:0;
	ns6=(document.getElementById&&!document.all)?1:0;

	if (ns){
	for (i = 0; i < Amount; i++){
	var P=Math.floor(Math.random()*grphcs.length);
	rndPic=grphcs[P];
	document.write("<LAYER NAME='sn"+i+"' LEFT=-100 TOP=0><img src="+rndPic+"></LAYER>");
	}
	}
	else{
	document.write('<div style="position:absolute;top:0px;left:-100px"><div style="position:relative">');
	for (i = 0; i < Amount; i++){
	var P=Math.floor(Math.random()*grphcs.length);
	rndPic=grphcs[P];
	document.write('<img id="si'+i+'" src="'+rndPic+'" style="position:absolute;top:0px;left:-100px">');
	}
	document.write('</div></div>');
	}
	WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight;
	WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth;
	for (i=0; i < Amount; i++){                                                                
	 Ypos[i] = Math.round(Math.random()*WinHeight);
	 Xpos[i] = Math.round(Math.random()*WinWidth);
	 Speed[i]= Math.random()*5+3;
	 Cstep[i]=0;
	 Step[i]=Math.random()*0.1+0.05;
	}
}
function fall(){
var WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight;
var WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth;
var hscrll=(ns||ns6)?window.pageYOffset:document.body.scrollTop;
var wscrll=(ns||ns6)?window.pageXOffset:document.body.scrollLeft;
for (i=0; i < Amount; i++){
sy = Speed[i]*Math.sin(90*Math.PI/180);
sx = Speed[i]*Math.cos(Cstep[i]);
Ypos[i]+=sy;
Xpos[i]+=sx; 
if (Ypos[i] > WinHeight){
Ypos[i]=-100;
Xpos[i]=Math.round(Math.random()*WinWidth);
Speed[i]=Math.random()*5+3;
}
if (ns){
document.layers['sn'+i].left=Xpos[i];
document.layers['sn'+i].top=Ypos[i]+hscrll;
}
else if (ns6){
document.getElementById("si"+i).style.left=Math.min(WinWidth,Xpos[i]);
document.getElementById("si"+i).style.top=Ypos[i]+hscrll;
}
else{
eval("document.all.si"+i).style.left=Xpos[i];
eval("document.all.si"+i).style.top=Ypos[i]+hscrll;
} 
Cstep[i]+=Step[i];
}
setTimeout('fall()',20);
}
*/

function doPopupMovie()
{
	var w = 640;
	var h = 480;
	var dw = 640;
	var dh = 480;
	var margin = 0;
	var left = 0;
	var top = 0;

	var xh = 0;
	if( typeof( document.all ) != 'object' )
		xh = 20;

	var newWindow = window.open("popupMovie.php","newWindow","alwaysRaised,scrollbars=auto,status=no,titlebar=no,toolbar=no,hotkeys=no,location=no,menubar=no,resizable=yes,width="+(w?w+2*margin:dw+2*margin)+",height="+(h?xh+h+2*margin:xh+dh+2*margin)+",left="+left+",top="+top);
	newWindow.focus();

}

function PopupAnkieta( sig )
{
	var w = 560;
	var h = 400;
	var dw = 560;
	var dh = 400;
	var margin = 0;
	var left = 0;
	var top = 0;

	if( margin == null )
		margin = 0;

	var url = "index.php?page=ankieta&sigid="+sig+"&task=ankieta";
	var ankietaWindow = window.open(url,"ankietaWindow","alwaysRaised,scrollbars=yes,status=no,titlebar=no,toolbar=no,hotkeys=no,location=no,menubar=no,resizable=yes,width="+(w?w+2*margin:dw+2*margin)+",height="+(h?h+2*margin:dh+2*margin)+",left="+left+",top="+top);
	ankietaWindow.focus();
}

