// JavaScript Document
var scripts = document.getElementsByTagName('script');
var index = scripts.length - 1;
var myScript = scripts[index];
var queryString = myScript.src.replace(/^[^\?]+\??/,'');
var params = get_param( queryString );


function set_time() {
	var ids=document.getElementById('ids').value;
php(CONFIG_HOST+'/js.php?action=refresh&ids='+ids);
		
	var setr=setTimeout("set_time()",1000);}
	
   
function getnow_f (id,price) {
					 $.ajax({type: "POST",
        url: CONFIG_HOST+"/ajax.php",
        data: {action:'check_activate',pid:id},
        dataType: "json",
        success: function(data){	
		if (data.err==1) {
		document.getElementById('pg_logo').src=document.getElementById('pigeon_img_'+id).src
		document.getElementById('pg_title').innerHTML=document.getElementById('title_'+id).innerHTML;
		document.getElementById('pg_price').innerHTML=price;
		document.getElementById('pigeon_id').value=id;
		$('#getnow_d').dialog('open');
		} else show_pigeon_error(data);
				}
				
				
				
    });	
		}
function naddai_f (id) {
	// check for active account
	
				 $.ajax({type: "POST",
        url: CONFIG_HOST+"/ajax.php",
        data: {action:'check_activate',pid:id},
        dataType: "json",
        success: function(data){	
		if (data.err==1) {
		var price=document.getElementById('cur_price_'+id).value;
		var minimal=document.getElementById('cur_minimim_'+id).value;
		price=price*1;
		minimal=minimal*1;
		minimal=(minimal+price);
		document.getElementById('pg1_logo').src=document.getElementById('pigeon_img_'+id).src
		document.getElementById('pg1_title').innerHTML=document.getElementById('title_'+id).innerHTML;
		document.getElementById('pd1_price').value=minimal;
		document.getElementById('pid').value=id;
		document.getElementById('min_p').value=minimal;
		document.getElementById('min_p_text').innerHTML=minimal;
		$('#naddai_d').dialog('open');
		} else show_pigeon_error(data);
		
				}
    });	
		}

var mybuttons_SM = {}
mybuttons_SM[jq_close] = function() {
$(this).dialog('close');};
mybuttons_SM[jq_setmoney] = function() {
					var p=$('#pd1_price').val();p=p*1;
					var min_p=$('#min_p').val();min_p=min_p*1;
					if (p >= min_p) document.getElementById('naddavane_forma').submit();
				};
				
var mybuttonsBN = {}
mybuttonsBN[jq_close] = function() {
$(this).dialog('close');};
mybuttonsBN[jq_getnow] = function() {
					document.getElementById('forma_kupi').submit();
				};

$(function() {

   	$('#getnow_d').dialog({
			resizable: true,
			width: 400,
			autoOpen: false,
			modal: true,
			show: 'slide',
			overlay: {
				backgroundColor: '#333',
				opacity: 0.5
			},
			buttons: mybuttonsBN
		});
   	$('#naddai_d').dialog({
			resizable: true,
			width: 400,
			autoOpen: false,
			show: 'slide',
			modal: true,
			overlay: {
				backgroundColor: '#333',
				opacity: 0.5
			},
			buttons:mybuttons_SM
		});
	set_time();
	
		   })

