

var maxdl=276;


function update(form, param) {
  lancuch = form.opis_zd.value;

  maxdl=276;

  dlciagu = lancuch.length;
  maxdlu = maxdl;
  
  if (dlciagu > maxdl) {

    	document.form.opis_zd.value=lancuch.substring(0,maxdlu);
    	alert("Przekroczono maksymalą ilość znaków!"); 

  } // else 

   poznak = maxdl - dlciagu; 
   form.poznak.value = poznak;

}





function kontrola(form) {
  var dat = document.form;

  if (dat.opis_zd.value.length == 0) {
    alert("Wpisz wiadomość!");
    dat.opis_zd.focus();
    return false;
  }
  if (dat.opis_zd.value.length > maxdl) {
    alert("Przekroczyłeś maksymalną ilość znaków!");
    dat.opis_zd.focus();
    return false;
  }
  return true;
} 


//*********** Drag and Drop *******************

function $(v) { return(document.getElementById(v)); }
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function xy(e,v) { return(v?(agent('msie')?event.clientY+document.body.scrollTop:e.pageY):(agent('msie')?event.clientX+document.body.scrollTop:e.pageX)); }

function dragOBJ(d,e) {

	
	function drag(e) { if(!stop) { d.style.top=(tX=xy(e,1)+oY-eY+'px'); d.style.left=(tY=xy(e)+oX-eX+'px'); } }

	var oX=parseInt(d.style.left),oY=parseInt(d.style.top),eX=xy(e),eY=xy(e,1),tX,tY,stop;

	document.onmousemove=drag; document.onmouseup=function(){ stop=1; document.onmousemove=''; document.onmouseup='';  };



}













var commonwin;	







function popup(url) {
if(commonwin) commonwin.close();
commonwin=window.open(url,"CommonWin","menubar=no,scrollbars=no,width=500,height=600,toolbar=no");
}





function mypopup(url) {
if(commonwin) commonwin.close();
commonwin=window.open(url,"CommonWin","location=no,statusbar=yes,menubar=no,scrollbars=no,width=650,height=450,toolbar=no,resizable=yes");
commonwin.document.write("<html><head><title>Sanford</title></head><body bgcolor=\"#FFFFFF\" onBlur=\"self.close()\" onClick=\"self.close()\"><table width=\"100%\" height=\"100%\"><tr><td align=\"center\" valign=\"middle\"><img src=\"http://www.goin.pl/"+url+"\" width=\"600\" border=\"0\" alt=\"Zamknij\" ></td></tr></table></body></html>");
}

function closewin() {
if(commonwin && !commonwin.closed){
	commonwin.close();
}
}







// ALT TEXT


/******************************************/
// vars for configuration

var background_color = "#FFFFCC";
var color = "#000000";
var border = " solid black 1px";
var fontfamily = "arial";
var fontsize = "12";
var hidetime = 50000; // time in millis before info fades
var padding = "5px 5px 5px 5px";

/*****************************************/

var live = new Object();
var nofade = new Object();
var fastfade = false;
var moz_opacity = false;
var ie_opacity = false;
var nodes = new Object();

var tempX = 0;
var tempY = 0;

var ison = false;

var IE = document.all?true:false;
// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE);

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

function setOff(altid) {
	//alert(altid);
	var nodeInst = nodes[altid];
	nodeInst['on'] = false;
	ison = false;
}

function showAltAlt(node, altid, width, closebox) {
	var status = true;
	var nodeInst = nodes[altid];
	if(nodeInst && nodeInst['on'] == true) {
		status = false;
	}

	if(browserDetect() && status) {
		var nodeInst = new Object();
		nodeInst['altid'] = altid;
		nodeInst['width'] = width;
		nodeInst['closebox'] = closebox;
		nodeInst['on'] = true;
		nodes[altid] = nodeInst;		
		node.onmouseout = function offit() { setOff(altid); };
		setTimeout("run('" + altid + "')", 500);	
	}
}

function run(altid) {
	var nodeInst = nodes[altid];
	if(nodeInst['on'] == true) {
		altalt(nodeInst['altid'], nodeInst['width'], nodeInst['closebox']);
	}
}

function hideAltAlt(altid) {
	fadeit(altid, 5);
}

function altalt(altid, width, closebox) {
	
	nid = altid + '-altalt';	
	try {				
		if(live[nid]) {
			return;
		} else {
			live[nid] = true;
		}
		
		leftx = tempX-150;
		bottomy = tempY-0;	
		
		var span = document.getElementById(altid).getElementsByTagName("span")[0];
		var newDiv = document.createElement("DIV");
			
		newDiv.setAttribute("id", nid);
		newDiv.style.position = "absolute";
		newDiv.style.visibility = "hidden";
		newDiv.style.overflow = "hidden";
		newDiv.style.top =  bottomy + "px";
		newDiv.style.left = leftx + "px";
		newDiv.style.border = border;
		newDiv.style.width = width + "px";
		newDiv.style.padding = padding;
		newDiv.style.fontFamily = fontfamily;
		newDiv.style.fontSize = fontsize + "px";
		newDiv.style.paddingRight = "3px";
		newDiv.style.backgroundColor = background_color;
				
		var newSpan = document.createElement("SPAN");
		newSpan = span.cloneNode(true);
		newDiv.appendChild(newSpan);		
		
		var newP = buildInfoP();
		var newA = buildInfoAhref();

		
					
		if(closebox) {
			closeBox(newA, altid);
		} else {
			newA.href="javascript:dontFade('" + altid + "');";			
			var xlink = document.createTextNode("Zamknij ");  
			newA.appendChild(xlink);		
			newA.style.border = "1px";  
			newA.style.backgroundColor = background_color;    
			newA.style.textDecoration = "underline";   
		}
		newP.appendChild(newA);
		newSpan.appendChild(newP);
		
		var body = document.getElementsByTagName("body")[0];	
		body.appendChild(newDiv);					
		newDiv.style.visibility = 'visible';

		if(! closebox) {
			/* setTimeout('fadeit("' + altid + '", 10)', hidetime); */
			closeBox(newA, altid);
			
		}
		
	} catch(err) {	
		alert(err);
	}
}

function fadeit(altid, op) {
	
	nid = altid + '-altalt';
	var node = document.getElementById(nid);		
	if(nofade[nid] == true) {
		node.style.opacity = "1";
		nofade[nid] = false;
		return;
	}
	
	if(op > 0 && fastfade == false) {
		op = op - 1;
		if(ie_opacity) {
			var ieop = op * 10;		
			node.style.filter = "alpha(opacity="+ ieop + ")";
		} else if (moz_opacity) {
			//alert('mozo');
			var mozop = op * 10;
			node.style.MozOpacity= mozop + "/100";
		} else {
			node.style.opacity = "." + op;
		}
		fadefunct = 'fadeit("' + altid + '", ' + op + ')';
		setTimeout(fadefunct, 30);

	} else {
		var node = document.getElementById(nid);
		node.style.visibility = 'hidden';			
		var body = document.getElementsByTagName("body")[0];
		body.removeChild( node );	
		live[nid] = false;
	}	
}

function dontFade(altid) {
	nid = altid + '-altalt';
	nofade[nid] = true;
	
	var span = document.getElementById(altid).getElementsByTagName("span")[0];
	infoDiv = document.getElementById(nid);
	var newSpan = document.createElement("SPAN");
	newSpan = span.cloneNode(true);
	var oldspan = infoDiv.getElementsByTagName("span")[0];
	var pnid = nid + 'pid';
	infoDiv.removeChild(oldspan);
	
	var ahref = buildInfoAhref(); 
	closeBox(ahref, altid);
	var newP = buildInfoP();
	newP.appendChild(ahref);
	newSpan.appendChild(newP);
		
	infoDiv.appendChild(newSpan);
}

function buildInfoAhref() {
	var newA = document.createElement("A");
	newA.style.color = "#000000";
	newA.style.textDecoration = "none";
	newA.style.fontSize = "10px";
	newA.style.border = "solid black 1px";
	newA.style.padding = "0px 2px 0px 2px";
	newA.style.backgroundColor = "#FFFFFF";
	return newA;								
}

function closeBox(ahref, altid) {
	ahref.href="javascript:hideAltAlt('" + altid + "');";			
	var xlink = document.createTextNode("X");
	ahref.appendChild(xlink);
}

function buildInfoP() {
		var newP = document.createElement("P");
		newP.style.textAlign = "right";
		newP.style.margin = "5px 5px 0px 0px";
		return newP;
}

function browserDetect() {
	var isgood = false;
	var agt=navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);	
	if(agt.indexOf('safari')!=-1) {
		isgood = true;
	} else if((agt.indexOf('mozilla')!=-1) && (agt.indexOf('gecko')!=-1)) {
		
		var rvindex = agt.indexOf("rv:");
		var rv2end = agt.substring(rvindex + 3, agt.length);
		var parenIndex = rv2end.indexOf(")");
		var rev = rv2end.substring(0, parenIndex); 
		if(rev < 1.7) {
			fastfade = true;
			//alert(	moz_opacity );
		}
		isgood = true;
	} else if(agt.indexOf('opera')!=-1) {
		fastfade = true;
		isgood = true;
		//moz_opacity = true;
	} else if(agt.indexOf('msie')!=-1) {
		if(agt.indexOf('mac')!=-1) {	
			ie_opacity = false;
			fastfade = true;
		} else {
			ie_opacity = true;
		}
		isgood = true;
	}
	return isgood;
}


function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
    		tempX = event.clientX + document.body.scrollLeft;
    		tempY = event.clientY + document.body.scrollTop;
  	} else {  // grab the x-y pos.s if browser is NS
    		tempX = e.pageX;
    		tempY = e.pageY;
  	}
 }  







//Pop-under window- By JavaScript Kit
//Credit notice must stay intact for use
//Visit http://javascriptkit.com for this script

//wlaczenie i wylaczenie pop-under
var active=0;

//specify page to pop-under
var popunder="";

//specify popunder window features
//set 1 to enable a particular feature, 0 to disable
var winfeatures="width=800,height=610,scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0";

//Pop-under only once per browser session? (0=no, 1=yes)
//Specifying 0 will cause popunder to load every time page is loaded
var once_per_session=1;

///No editing beyond here required/////

function get_cookie(Name) {
  var search = Name + "=";
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1) { // if cookie exists
      offset += search.length;
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end));
      }
   }
  return returnvalue;
}

function loadornot(){
if (get_cookie('popunder')=='' && active==1){
loadpopunder();
document.cookie="popunder=yes";
}
}

function loadpopunder(){
win2=window.open(popunder,"",winfeatures);
win2.blur();
window.focus();
}

if (once_per_session==0 && active==1)
loadpopunder();
else
loadornot();






