pWidgetsFOID = new Object();


pWidgetsFTID = new Object();

var LastVisitedDivID;
var LastVisitedHTML;
var LastVisitedDivSize;





function pWidgets(object, destOp, rate, delta){


if (!document.all){
	return
}

    if (object != "[object]"){


        setTimeout("pWidgets("+object+","+destOp+","+rate+","+delta+")",0);


        return;


    }


        


    clearTimeout(pWidgetsFTID[object.sourceIndex]);


    


    diff = destOp-object.filters.alpha.opacity;


    direction = 1;


    if (object.filters.alpha.opacity > destOp){


        direction = -1;


    }


    delta=Math.min(direction*diff,delta);


    object.filters.alpha.opacity+=direction*delta;





    if (object.filters.alpha.opacity != destOp){


        pWidgetsFOID[object.sourceIndex]=object;


        pWidgetsFTID[object.sourceIndex]=setTimeout("pWidgets(pWidgetsFOID["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);


    }


}





function displayWindow(url, width, height) {


  var Win = window.open(url,"displayWindow",'width=' + width +


  ',height=' + height + ',resizable=0,scrollbars=0,menubar=0' );


}



function expandAdAnimation(controlID){
	
	if(LastVisitedDivID == "" || LastVisitedDivID == null){
		LastVisitedDivID = controlID;
		LastVisitedHTML = document.getElementById(controlID).innerHTML;

	}else{
		collapseAdAnimation(LastVisitedDivID);
		collapseAd(LastVisitedDivID, LastVisitedHTML);
		LastVisitedDivID = controlID;
		LastVisitedHTML = document.getElementById(controlID).innerHTML;
	}
		
	if (document.getElementById) {  // DOM3 = IE5, NS6
		var o = document.getElementById(controlID);
		LastVisitedDivSize = o.style.height;


		 var i=100; 
		 var interval;   
			 function changeSize(){        
			 i = i + 20;
							
			 o.style.height = i + 'px'; //for IE           
			      if(i>=400){
					  //callUnvisible(interval);
					  window.clearInterval(intervalNew);
						document.getElementById(controlID).style.visibility = "visible";
					  //setTimeout("callUnvisible(" + intervalNew + ");",2000);
					  //window.clearInterval(interval);
				  }                            
			  }    
		intervalNew = window.setInterval(changeSize, 10);
	}
}

function collapseAdAnimation(controlID){
	
		
	if (document.getElementById) {  // DOM3 = IE5, NS6
		var o = document.getElementById(controlID);
		

			 o.style.height = 'auto';
	}
}


function callUnvisible(interval){
		window.clearInterval(interval);
		//setTimeout('document.getElementById("hidepage").style.visibility = "hidden"',2000);
}



function expandAd(controlID, URL){
	//document.getElementById(controlID).style.height = 400;
	//document.getElementById(controlID).innerHTML = "<iframe SCROLLING='no' height = '100%' width='98%' src=" + URL + "  ></iframe>";
	document.getElementById(controlID).style.visibility = "hidden"
	document.getElementById(controlID).innerHTML = "<table border=0 height=395 width=100% border=\"1\"><tr ><td  height=\"100%\" width=\"100%\" align=\"center\" rowspan=\"2\"><iframe FRAMEBORDER=0 SCROLLING='no' height = '100%' width='100%' src=" + URL + "  ></iframe></td><td valign=\"top\" ></br><img src=\"\img/tripple-up.jpg\" onMouseover=\"scrollspeed=-10\" onMouseout=\"scrollspeed=0\"/></br></br></br><img src=\"\img/double-up.jpg\" onMouseover=\"scrollspeed=-5\" onMouseout=\"scrollspeed=0\"/></br></br></br></br><img src=\"\img/center.jpg\"></td></tr><tr><td valign=\"bottom\" ><img src=\"\img/double-down.jpg\" onMouseover=\"scrollspeed=5\" onMouseout=\"scrollspeed=0\"/></br></br></br><img src=\"\img/tripple-down.jpg\" onMouseover=\"scrollspeed=10\" onMouseout=\"scrollspeed=0\"/></br></br></td></tr></table>"; 
	
	

}

function collapseAd(controlID, _LastVisitedHTML){
	//document.getElementById(controlID).style.height = 400;
	document.getElementById(controlID).innerHTML = _LastVisitedHTML; 
}



function displayWindow2(url, anazwa_okna, width, height) {

  var Win = null ;
  Win= window.open(url, anazwa_okna ,'width=' + width + ',height=' + height + ',resizable=0,scrollbars=1,menubar=0' );
  //openAdInIFRAME(url,width,350);

  if(Win == null){
  	//alert("Not able to open this page because your Pop Up Blocker is enabled.");
	openAdInIFRAME(url,width,350);
  }else{
	  Win.focus();  
  }

}

function add2SessionCookie (value){
  $newCookie = readCookie("SeeAdHistory")
			if ($newCookie != null) {
				$SeenAds = $newCookie;
				$SeenAds = $SeenAds + "|" + value;
				//$_COOKIE['SeeAdHistory'] =   $SeenAds;	
				createCookie ("SeeAdHistory", $SeenAds);
	
		}else{
			$SeenAds =  value;
			//$_COOKIE['SeeAdHistory'] =   $SeenAds;
			createCookie ("SeeAdHistory", $SeenAds);
		}	
}



function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}





function f_open_window_max( aURL, aWinName ) {


  var wOpen;


  var sOptions;





  sOptions = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes,location=yes';


  sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();


  sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString();


  sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';





  wOpen = window.open( '', aWinName, sOptions );


  wOpen.location = aURL;


  wOpen.focus();


  wOpen.resizeTo( screen.availWidth, screen.availHeight );


  wOpen.moveTo(0, 0);


  return wOpen;


}





/**


 * Sprawdza poprawnosc rozszerzenia wybranych plikow przy pomocy <input type="file" .. />


 *


 * Pomocnicza funkcja LimitAttach:


 * @param  object  formularz


 * @param  string  wartosc <input type="file" ... />


 *


 * @return boolean jezeli rozszerzenie wybranego pliku zgodne z podanym w tablicy extArray zwraca false


 *


 * Funkcja SprawdzRozszerzenie:


 * @param  object  formularz


 * @param  string  nazwa elementu <input name="nazwa1">


 * @param  integer ilosc elementow <input> o nazwach "nazwa1 - nazwa+ilosc" (parametr moze byc pusty)


 *


 * @return boolean jezeli wszystkie rozszerzenia sa dobre zwraca true


 */


extArray = new Array(".jpg");





function LimitAttach(form, file) {


  allowSubmit = false;


  if (!file) return;





  while (file.indexOf("\\") != -1)


    file = file.slice(file.indexOf("\\") + 1);


  ext = file.slice(file.indexOf(".")).toLowerCase();


  for (var i = 0; i < extArray.length; i++) {


    if (extArray[i] == ext) { allowSubmit = true; break; }


  } //for


  


  if (allowSubmit)


    return false;


  else


    return true;


} //function LimitAttach





function SprawdzRozszerzenie(form, nazwa, ilosc) {


  WszystkoOK = true;


  if (!ilosc) ilosc = 1;





  for (var i = 1; i <= ilosc; i++) {


    if (ilosc == 1) nazwa_obj = nazwa;


    else nazwa_obj = nazwa+i;


    


    if (form[nazwa_obj]) {


      if (LimitAttach(form, form[nazwa_obj].value)) { WszystkoOK = false; };


    } //if


  }//for





  if (WszystkoOK)


    return true;


  else


    return false;


} //function SprawdzRozszerzenie





/**


 * Displays an error message if an element of a form hasn't been completed and


 * should be


 *


 * @param   object   the form


 * @param   string   the name of the form field to put the focus on


 *


 * @return  boolean  whether the form field is empty or not


 */


function emptyFormElements(theForm, theFieldName, Komunikat)


{


    var isEmpty  = 1;


    var theField = theForm.elements[theFieldName];


    // Whether the replace function (js1.2) is supported or not


    var isRegExp = (typeof(theField.value.replace) != 'undefined');





    if (!isRegExp) {


        isEmpty      = (theField.value == '') ? 1 : 0;


    } else {


        var space_re = new RegExp('\\s+');


        isEmpty      = (theField.value.replace(space_re, '') == '') ? 1 : 0;


    }


    if (isEmpty) {


        // theForm.reset();


        theField.select();


        alert(Komunikat);


        theField.focus();


        return false;


    }





    return true;


} // end of the 'emptyFormElements()' function





function emptyFormCheckbox(theForm, theFieldName, Komunikat)


{


    


    var theField = theForm.elements[theFieldName];


    if ( theField.checked == false )


    {


 	//theField.select();


        alert(Komunikat);


	theField.focus();


        return false;


    }


    else


    {


	return true;


    }





    return true;


} // end of the 'emptyFormElements()' function





function confirmLink(Aalert) {


  var is_confirmed = confirm(Aalert);


  if (is_confirmed) {


      this.href += '&confirmed=1';


  } //if


  return is_confirmed;


} //function confirmLink





//pozwala na zaznaczanie wszyskich opcji jednorazowo

var checkobj

function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="checkbox")
	if((tempobj.name != "bez_przebiegu") && (tempobj.name != "chkAgree") && (tempobj.name != "ikona_uszkodzony") && (tempobj.name != "ikona_zabytkowy") && (tempobj.name != "ikona_okazja")&& (tempobj.name != "ikona_nowymodel")&& (tempobj.name != "ikona_promocja")&& (tempobj.name != "ikona_nowadostawa")&& (tempobj.name != "ikona_sprzedany")){
		tempobj.checked=checkobj.checked
	}
}
}
}

function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
}



//pozwala na wyswietlanie Ad w iFrame
function animateHeight(id, size)
{
el = document.getElementById(id);
var h_size1 = el.offsetHeight;
if (h_size1 < size)
{
el.style.height = h_size1 + 2+"px";
setTimeout("animateHeight('" + id + "','" + size + "')", 1);
}
}

function minimizeHeight(id, size)
{
el = document.getElementById(id);
var h_size1 = el.offsetHeight;
if (h_size1 > size)
{
el.style.height = h_size1 - 2 + "px";
setTimeout("minimizeHeight('" + id + "','" + size + "')", 1);
}
}

 function writetoLyr(id, message) { 
	document.getElementById(id).innerHTML = message; 
 } 
 
function iframeItemRefresh(iframe,href){
document.getElementById(iframe).src=href
}

function iframeSize(h,iframe){
document.getElementById(iframe).style.height=h+'px'
}

function iframeSizeWidth(w,iframe){
document.getElementById(iframe).style.width=w+'px'
}

function iframeDisplay(url,id) {
document.getElementById(id).style.display="block";
document.getElementById(id).src=url;
}
function iframeHide(url,id) {
document.getElementById(id).style.display="none";
document.getElementById(id).src=url;
}
function iframeDisplayRelative(url,id) {
document.getElementById(id).style.display="block";
document.getElementById(id).src=url;
document.getElementById(id).style.top=document.body.scrollTop + 220;
}
function iframeDisplayRelativeSize(url,id,w) {
document.getElementById(id).style.display="block";
document.getElementById(id).src=url;
document.getElementById(id).style.width=w+'px'
document.getElementById(id).style.top=document.body.scrollTop + 220;
}

function openAdInIFRAME(url,w,h){
	//iframeHide('http://www.google.com','logo');
	document.getElementById('divTopLeft').style.visibility="visible"; 
	iframeItemRefresh('logo', url);
	document.getElementById('logo').style.borderWidth =3 +'px';
	//iframeDisplay('http://www.google.com','logo');
	iframeSize(h,'logo');
	iframeSizeWidth(w,'logo');
	
	
	
}




//pozwala na dragownie IFRAME


// Variables used for "Draggable IFrame" (DIF) functions
var DIF_dragging=false;
var DIF_iframeBeingDragged="";
var DIF_iframeObjects=new Object();
var DIF_iframeWindows=new Object();
var DIF_iframeMouseDownLeft = new Object();
var DIF_iframeMouseDownTop = new Object();
var DIF_pageMouseDownLeft = new Object();
var DIF_pageMouseDownTop = new Object();
var DIF_handles = new Object();
var DIF_highestZIndex=99;
var DIF_raiseSelectedIframe=false;
var DIF_allowDragOffScreen=false;

// Set to true to always raise the dragged iframe to top zIndex
function bringSelectedIframeToTop(val) {
	DIF_raiseSelectedIframe = val;
	}
	
// Set to try to allow iframes to be dragged off the top/left of the document
function allowDragOffScreen(val) {
	DIF_allowDragOffScreen=val;
	}

// Method to be used by iframe content document to specify what object can be draggable in the window
function addHandle(o, win) {
	
	if (arguments.length==2 && win==window) {
		// JS is included in the iframe who has a handle, search up the chain to find a parent window that this one is dragged in
		var p = win;
		while (p=p.parent) {
			alert("yes");
			if (p.addHandle) { 
			alert("yes1");
			p.addHandle(o,win,true); return; }
			if (p==win.top) { 
			alert("no");
			return; } // Already reached the top, stop looking
			}
		
		return; // If it reaches here, there is no parent with the addHandle function defined, so this frame can't be dragged!
		}
	var topRef=win;
	var topRefStr = "window";
	while (topRef.parent && topRef.parent!=window) {
		topRef = topRef.parent;
		topRefStr = topRefStr + ".parent";
		}
	// Add handlers to child window
	if (typeof(win.DIF_mainHandlersAdded)=="undefined" || !win.DIF_mainHandlersAdded) {
		// This is done in a funky way to make Netscape happy
		with (win) { 
			eval("function OnMouseDownHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.DIF_begindrag(evt, "+topRefStr+") }");
			eval("document.onmousedown = OnMouseDownHandler;");
			eval("function OnMouseUpHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.DIF_enddrag(evt, "+topRefStr+") }");
			eval("document.onmouseup = OnMouseUpHandler;");
			eval("function OnMouseMoveHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.DIF_iframemove(evt, "+topRefStr+") }");
			eval("document.onmousemove = OnMouseMoveHandler;");
			win.DIF_handlersAdded = true;
			win.DIF_mainHandlersAdded = true;
			}
		}
	// Add handler to this window
	if (typeof(window.DIF_handlersAdded)!="undefined" || !window.DIF_handlersAdded) {
		eval("function OnMouseMoveHandler(evt) { if(typeof(evt)=='undefined'){evt=event;}DIF_mouseMove(evt, window) }");
		eval("document.onmousemove = OnMouseMoveHandler;");
		window.DIF_handlersAdded=true;
		}
	o.style.cursor="move";
	var name = DIF_getIframeId(topRef);
	if (DIF_handles[name]==null) {
		// Initialize relative positions for mouse down events
		DIF_handles[name] = new Array();
		DIF_iframeMouseDownLeft[name] = 0;
		DIF_iframeMouseDownTop[name] = 0;
		DIF_pageMouseDownLeft[name] = 0;
		DIF_pageMouseDownTop[name] = 0;
		}
	DIF_handles[name][DIF_handles[name].length] = o;
	}

// Generalized function to get position of an event (like mousedown, mousemove, etc)
function DIF_getEventPosition(evt) {
	var pos=new Object();
	pos.x=0;
	pos.y=0;
	if (!evt) {
		evt = window.event;
		}
	if (typeof(evt.pageX) == 'number') {
		pos.x = evt.pageX;
		pos.y = evt.pageY;
	}
	else {
		pos.x = evt.clientX;
		pos.y = evt.clientY;
		if (!top.opera) {
			if ((!window.document.compatMode) || (window.document.compatMode == 'BackCompat')) {
				pos.x += window.document.body.scrollLeft;
				pos.y += window.document.body.scrollTop;
			}
			else {
				pos.x += window.document.documentElement.scrollLeft;
				pos.y += window.document.documentElement.scrollTop;
			}
		}
	}
	return pos;
}

// Gets the ID of a frame given a reference to a window object.
// Also stores a reference to the IFRAME object and it's window object
function DIF_getIframeId(win) {
	// Loop through the window's IFRAME objects looking for a matching window object
	var iframes = document.getElementsByTagName("IFRAME");
	for (var i=0; i<iframes.length; i++) {
		var o = iframes.item(i);
		var w = null;
		if (o.contentWindow) {
			// For IE5.5 and IE6
			w = o.contentWindow;
			}
		else if (window.frames && window.frames[o.id].window) {
			w = window.frames[o.id];
			}
		if (w == win) {
			DIF_iframeWindows[o.id] = win;
			DIF_iframeObjects[o.id] = o;
			return o.id; 
			}
		}
	return null;
	}

// Gets the page x, y coordinates of the iframe (or any object)
function DIF_getObjectXY(o) {
	var res = new Object();
	res.x=0; res.y=0;
	if (o != null) {
		res.x = o.style.left.substring(0,o.style.left.indexOf("px"));
		res.y = o.style.top.substring(0,o.style.top.indexOf("px"));
		}
	return res;
	}

// Function to get the src element clicked for non-IE browsers
function getSrcElement(e) {
	var tgt = e.target;
	while (tgt.nodeType != 1) { tgt = tgt.parentNode; }
	return tgt;
	}

// Check if object clicked is a 'handle' - walk up the node tree if required
function isHandleClicked(handle, objectClicked) {
	if (handle==objectClicked) { return true; }
	while (objectClicked.parentNode != null) {
		if (objectClicked==handle) {
			return true;
			}
		objectClicked = objectClicked.parentNode;
		}
	return false;
	}
	
// Called when user clicks an iframe that has a handle in it to begin dragging
function DIF_begindrag(e, win) {
	// Get the IFRAME ID that was clicked on
	var iframename = DIF_getIframeId(win);
	if (iframename==null) { return; }
	// Make sure that this IFRAME has a handle and that the handle was clicked
	if (DIF_handles[iframename]==null || DIF_handles[iframename].length<1) {
		return;
		}
	var isHandle = false;
	var t = e.srcElement || getSrcElement(e);
	for (var i=0; i<DIF_handles[iframename].length; i++) {
		if (isHandleClicked(DIF_handles[iframename][i],t)) {
			isHandle=true;
			break;
			}
		}
	if (!isHandle) { return false; }
	DIF_iframeBeingDragged = iframename;
	if (DIF_raiseSelectedIframe) {
		DIF_iframeObjects[DIF_iframeBeingDragged].style.zIndex=DIF_highestZIndex++;
		}
	DIF_dragging=true;
	var pos=DIF_getEventPosition(e);
	DIF_iframeMouseDownLeft[DIF_iframeBeingDragged] = pos.x;
	DIF_iframeMouseDownTop[DIF_iframeBeingDragged] = pos.y;
	var o = DIF_getObjectXY(DIF_iframeObjects[DIF_iframeBeingDragged]);
	DIF_pageMouseDownLeft[DIF_iframeBeingDragged] = o.x - 0 + pos.x;
	DIF_pageMouseDownTop[DIF_iframeBeingDragged] = o.y -0 + pos.y;
	}

// Called when mouse button is released after dragging an iframe
function DIF_enddrag(e) {
	DIF_dragging=false;
	DIF_iframeBeingDragged="";
	}

// Called when mouse moves in the main window
function DIF_mouseMove(e) {
	if (DIF_dragging) {
		var pos = DIF_getEventPosition(e);
		DIF_drag(pos.x - DIF_pageMouseDownLeft[DIF_iframeBeingDragged] , pos.y - DIF_pageMouseDownTop[DIF_iframeBeingDragged]);
		}
	}

// Called when mouse moves in the IFRAME window
function DIF_iframemove(e) {
	if (DIF_dragging) {
		var pos = DIF_getEventPosition(e);
		DIF_drag(pos.x - DIF_iframeMouseDownLeft[DIF_iframeBeingDragged] , pos.y - DIF_iframeMouseDownTop[DIF_iframeBeingDragged]);
		}
	}

// Function which actually moves of the iframe object on the screen
function DIF_drag(x,y) {
	var o = DIF_getObjectXY(DIF_iframeObjects[DIF_iframeBeingDragged]);
	// Don't drag it off the top or left of the screen?
	var newPositionX = o.x-0+x;
	var newPositionY = o.y-0+y;
	if (!DIF_allowDragOffScreen) {
		if (newPositionX < 0) { newPositionX=0; }
		if (newPositionY < 0) { newPositionY=0; }
		}
	DIF_iframeObjects[DIF_iframeBeingDragged].style.left = newPositionX + "px";
	DIF_iframeObjects[DIF_iframeBeingDragged].style.top  = newPositionY + "px";
	DIF_pageMouseDownLeft[DIF_iframeBeingDragged] += x;
	DIF_pageMouseDownTop[DIF_iframeBeingDragged] += y;
	}




function OpenFullCarFaxWindow(url) {
 var Win = window.open(url,"displayWindow",'toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes' );
}

//second way of moving IFRAME


