function checkedOffer(id_chceked_img, id_header, id_offer){
	document.getElementById(id_header).style.background='#AFAFAF';  
	document.getElementById(id_chceked_img).style.display ='block';
	
	var expires  = 1;
	var c_name = "checked_num=";
	//var old_value = document.cookie.indexOf("checked_num=");
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name);
		if (c_start!=-1){ 
			c_start=c_start + c_name.length; 
			c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		
		var old_value = unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	
		old_value += "|" + id_offer;
	
	var today = new Date();
	today.setTime( today.getTime() );

	if ( expires ){
		var	expires = expires * 1000 * 60 * 60 * 9;
	}

	var expires_date = new Date( today.getTime() + (expires) );	
	
	//sprawdzamy czy ważne jest ciasteczko
	if(today.toLocaleString() >= expires_date.toGMTString())
		document.cookie= "checked_num=;expires=Thu, 01-Jan-1970 00:00:01 GMT";
	else
	document.cookie= "checked_num=" + old_value +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" );
		
	
}

function sort_order_new(idik, src, sort_val, page_num, module)
{
	msg1=src.slice(src.length-8);
	msg2=src.slice(src.length-6,src.length-4);
	
	element=document.getElementById(idik);	
	
	if(idik=='desc')
	{
				if(msg2=="wn")
				{
				    element.src="http://pressitonfinance.com/image/down_on.GIF";
						document.getElementById('asc').src="http://pressitonfinance.com/image/up.GIF";
						newSortOffers(sort_val, idik, page_num, module);
				}
	}
	else
	{
		    if(msg2=="up")
				{
				   element.src="http://pressitonfinance.com/image/up_on.GIF";
					 document.getElementById('desc').src="http://pressitonfinance.com/image/down.GIF";
					 newSortOffers(sort_val, idik, page_num, module);
				}
	}
	
}

function newSortOffers(sorter, orderer, page_num, module)
{
	var url_string = window.location.href;
	var lenght_www = url_string.indexOf("http://pressitonfinance.com/");
	
	//ustawienie pozycji końca adresu www
	if(lenght_www == 0)
		var end_pos = 28;
	else
		var end_pos = 32;
	
	var url_www = url_string.slice(0,end_pos); //adres www bez przekazywanych zmiennych GET
	var url_sub = url_string.slice(end_pos); //zmienne GET
		if(url_string.search("&") != -1){
			url_string_t = url_string.replace("&order=asc", "");
			url_string = url_string_t.replace("&order=desc", "");
			url_string_t = url_string.replace("&sorter=0", "");
			url_string = url_string_t.replace("&sorter=1", "");
			
			URL = url_string+'&order='+orderer + '&sorter=' + sorter;
			//URL = url_www+'index.php?sub='+ module + '&order='+orderer + '&sorter=' + sorter;
		}else{
			URL = url_www+'index.php?sub='+ module + '&order=' + orderer + '&sorter=' + sorter;
			
		}	
			//URL = 'http://pressitonfinance.com/index.php?sub='+ url_sub + '&order=' + orderer + '&sorter=' + sorter;
		window.location=URL;
}

function offerDetailsWindowMB(offer_num,fund,number,n_off,col_ord,col_click) {

   for(i=0;i<n_off;i++){
		document.getElementById('offer'+i).title='click';
		document.getElementById('offhp'+i).title='click';
		document.getElementById('offti'+i).title='click';

	}
	 
	ch_back(number,col_click,'off',col_click);
	number=number.slice(5);
	
	document.getElementById('offer'+number).title='clicked';
	document.getElementById('offhp'+number).title='clicked';
	document.getElementById('offti'+number).title='clicked';
	 
	if(fund==true)
		adr='index.php?sub=offer&offer_num='+offer_num+'&fund=true';	
	else
		adr='index.php?sub=offer&offer_num='+offer_num;
		
	title='Pressiton Finance - ' + offer_num;

	Modalbox.show('<div id="loaderos" style="width: 800px; text-align: center;"><img src="inc/modalbox/spinner.gif" style="border: 0px;" alt=""/></div><iframe id="ifremus" src="' + adr +'" width="805" height="400" frameborder="0" scrolling="yes" onLoad="afterLoadOfferDetails()" >no iframe support...nie obsługiwane ramki</iframe>',
	{title: title, width: 823, height: 555, overlayClose: false});
	//ukrycie bannera
	$('main_button').hide();
	$('banner_estate').hide();
	//po zamknięciu okna MB, wtyświetlenie bannera
	$('MB_close').observe('click', function(){
		$('main_button').show();
		$('banner_estate').show();
	});
}

function afterLoadOfferDetails(){
	$('loaderos').hide();
	$('ifremus').setStyle({height: '500px'});
}

