function GetRandomNumberString() {
    return Math.round(Math.random() * 1000000).toString();
}

function openpopupwindow(url,toolbar,scrollbars,location,statusbar,menubar,resizable,width,height)
{
	popupproperties="toolbar="+toolbar+",scrollbars="+scrollbars+",location="+location+",statusbar="+statusbar+",menubar="+menubar+",resizable="+resizable;
	if (width!='0') popupproperties+=",width="+width;
	if (height!='0') popupproperties+=",height="+height;
	winpops=window.open(url,"",popupproperties)

}

function votephoto(bid)
{
    if (!bid) {alert('Fotograf seçiniz');} else
     {
    
    $('#spnMsgPD').html('<img src="/images/ajax-loader.gif" /> &nbsp; &#304&#351;lem yap&#305;l&#305;yor.');
       
    this.OnSuccessfulRequest = function ( data ) 
	{

        if (data == 'OK')
        {
        
            vote=$('#ctl00_ContentPlaceHolder1_lblVoteCount').html();
            nvote = parseInt(vote) + 1;
            $('#ctl00_ContentPlaceHolder1_lblVoteCount').html(nvote);
            $('#spnMsgPD').html('Oyunuz al&#305;nm&#305;&#351;t&#305;r. Te&#351;ekk&#252;rler.');
        }
        else        
        {
           $('#spnMsgPD').html(data);
        }    
	}
	
	this.OnError = function ( ) 
	{
		$('#spnMsgPD').html('Hata olu&#351;tu. L&#252;tfen daha sonra deneyiniz.');
	}
	
	contenturl='provider.aspx?dsn=votephoto&bid=' + bid+'&fpr='+GetRandomNumberString();
	
	$.ajax({type:'GET',url:contenturl,error:this.OnError,success:this.OnSuccessfulRequest});
   }
}

// BOXY METHODS  -----------------------------------------------------------------------------------------------------------------------------------------------

$(function() {
  $('.boxy').boxy();
});

var GAPJS = window.GAPJS || {};
GAPJS.BoxyDialog = function() 
{
    
	this.BoxyList = new Array();
}


GAPJS.BoxyDialog.prototype.AddBoxy = function(itemName, data , title1, containername)
{
	options = $.extend({ center:true,fixed:false, modal:true,title: title1 });
	
	var jDialog; 
	if (containername == null || containername == '')
	{
		if (data == null || data == '')
		{
		
			data = '<div style="height:50px; width:430px; visibility:none;">&nbsp;</div>';
		}
		
		jDialog = new Boxy(data, options);
		
	}
	else
	{
		jDialog = new Boxy($('#'+containername), options);
	}
	
	this.BoxyList[itemName] = jDialog;
	return jDialog;
}

GAPJS.BoxyDialog.prototype.Manager = function ( itemName, data , title, containername)
{
	
	var objPannel = this.GetPannel(itemName);
	
	if ( objPannel == null )
	{
	
		objPannel = this.AddBoxy(itemName, data , title, containername);
	}
	else if (containername == null || containername == '') 
	{
	
		objPannel.setContent(data);
	}
	
	objPannel.show();
	
	
}

GAPJS.BoxyDialog.prototype.Close = function ( itemName )
{
	var objPannel = this.GetPannel(itemName);
	if ( objPannel != null )
	{
		objPannel.hide();
	}
}

GAPJS.BoxyDialog.prototype.GetPannel = function ( itemName )
{
	var objPannel = this.BoxyList[itemName];
	
	if ( objPannel != null && objPannel != 'undefined')
	{
		return objPannel;
	}
	return null;
}

function openexamplephoto()
{
    var jGZDialog = new GAPJS.BoxyDialog();
    var data = '<div style="height:500px; width:400px"><img src="/images/examplephoto.png" /></div>';
    jGZDialog.Manager("openexamplephoto",data,'&nbsp;', '');
}

