function CheckLoggedDownload(divId){	var userid = readCookie("bbuserid");	if (!(userid>0)){		WriteDiv(divId,"<p align=\"center\"><b><font color=\"red\">Você precisa estar logado para baixar um arquivo</font><b></p>");	}}var requestdownc = makeObject();var ratev;/*voto*/function parseInfoDownload(){	if(requestdownv.readyState == 1){		WriteDiv('div_rate','<div align="center"><img src="http://www.gamevicio.com.br/images/progress.gif">&nbsp;Aguarde...</div>');	}	if(requestdownv.readyState == 4){		var answer =  String (requestdownv.responseText);		WriteDiv('div_rate',answer);		if (ratev=='bad'){			history.go(-1);		}	}}function Vote(id,rate){	ratev = rate;	requestdownv.open('get', RelativeRoot() + 'misc/ajax/download.php?mode=vote&id='+id+'&rate='+rate);	requestdownv.onreadystatechange = parseInfoDownload;	requestdownv.send('');}//contar votovar requestdownv = makeObject();var downloadId;function IncrementDownload(){	var userid = readCookie("bbuserid");	if (userid>0){		requestdownv.open('get', RelativeRoot() + 'misc/ajax/download.php?mode=download&id='+ downloadId+'&r='+Math.random());    	requestdownv.send('');	}}function DownloadStart(){	self.setTimeout("IncrementDownload()", 2000);}download = new Object();download = {	id: null,	idGame: null,	idCategory: null,	start: function(id,mirrorId){		download.setId(id);		if (mirrorId){			download.mirror.setId(mirrorId);		}	},	setId: function(n){		download.id = n;	},	getId: function(){		return download.id;	},	setIdGame: function(n){		download.idGame = n;	},	getIdGame: function(){		return download.idGame;	},	setIdCategory: function(n){		download.idCategory = n;	},	getIdCategory: function(){		return download.idCategory;	},	//avaliação do download	rate:{		vote:null,		ajax:null,		setVote: function(s){			download.rate.vote = s;		},		getVote: function(){			return download.rate.vote;		},		Do: function(vote){			download.rate.setVote(vote);			var ajax = new gAjax('get',global.RelativeRoot() + 'misc/ajax/main.php?mode=rate&id_area=2&id_item='+download.getId()+'&vote='+download.rate.getVote());			ajax.addEvent(1,'loadScreen("div_download_start_option_2")');			ajax.addEvent(4,'download.rate.parseDo()');			download.rate.ajax = ajax;			ajax.send();		},		parseDo: function(){			var ajax = download.rate.ajax;			if (!ajax.isResponseXML()){				return;			}			ajax = ajax.getQueryXML();			var r = ajax.getValue('attributes()->status')=="fail" ? ajax.getValue('error->description') : 'Obrigado por seu voto';			global.div.Write('div_download_start_option_2',r);		}	},	begin:{		start: function(){			if (user.isLogged()){				self.setTimeout('download.increment.Do()', 2000);			}else{				global.div.Write('div_download_start','Você precisa estar logado para efetuar o download. Efetue login ou registre-se');				global.div.Write('div_download_start_option','');			}		}	},	increment: {		mode: 'image',		ajax: null,		Do: function(){			var m = download.increment.mode;			if (m == 'ajax'){				download.increment.DoWithAjax();				return;			}			if (m == 'image'){				download.increment.DoWithImage();				return;			}		},		DoWithImage: function(){			var d = document.createElement("div");			d.setAttribute('display','none');			if (document.body){				document.body.appendChild(d);			}			d.innerHTML = '<img src="http://s9.gamevicio.com.br/gv/download/download/increment/'+download.getId()+'/'+Math.random()+'"/>';		},		DoWithAjax: function(){			var ajax = new gAjax('get',global.RelativeRoot() + 'misc/ajax/main.php?mode=download_increment&id='+download.getId());			download.increment.ajax = ajax;			ajax.send();		}	},	mirror: {		id:null,		setId: function(n){			download.mirror.id = n;		},		getId: function(){			return download.mirror.id;		},		//avaliação do mirror		rate:{			vote:null,			ajax:null,			setVote: function(s){				download.mirror.rate.vote = s;			},			getVote: function(){				return download.mirror.rate.vote;			},			Do: function(vote){				download.mirror.rate.setVote(vote);				var ajax = new gAjax('get',global.RelativeRoot() + 'misc/ajax/main.php?mode=download_mirror_rate&id='+download.mirror.getId()+'&vote='+download.mirror.rate.getVote());				ajax.addEvent(1,'loadScreen("div_download_start_option_1")');				ajax.addEvent(4,'download.mirror.rate.parseDo()');				download.mirror.rate.ajax = ajax;				ajax.send();			},			parseDo: function(){				var ajax = download.mirror.rate.ajax;				if (!ajax.isResponseXML()){					return;				}				ajax = ajax.getQueryXML();				if (ajax.getValue('attributes()->status')=="fail"){					global.div.Write('div_download_start_option_1',ajax.getValue('error->description'));				}else{					global.div.Write('div_download_start_option_1','Obrigado por seu voto');					if (download.mirror.rate.getVote()=='bad'){						history.go(-1);					}				}			}		}	},	paginate: {		ajax: null,		page: 1,		pageTotal:null,		limit: 30,		firstEntry: true,		started: false,		mode: 'increment',//'increment':adiciona mais itens sem esvaziar o div atual, "clear"		setPage: function(n){			comment.paginate.page = n;		},		getPage: function(){			return comment.paginate.page;		},		setPageTotal: function(n){			comment.paginate.pageTotal = n;		},		getPageTotal: function(){			return comment.paginate.pageTotal;		},		setLimit: function(n){			download.paginate.limit = n;		},		getLimit: function(){			return download.paginate.limit;		},		setFirstEntry: function(b){			comment.paginate.firstEntry = b;		},		isFirstEntry: function(){			return comment.paginate.firstEntry;		},		setStarted: function(b){			download.paginate.started = b;		},		isStarted: function(){			return download.paginate.started;		},		getMode: function(){			return download.paginate.mode;		},		//chamada apenas se houver anchor		start: function(){			var v = global.getUrlVars();			var n = v['#page'];			if (n!=false && n>0){				page = n;				comment.paginate.Do(page);			}else{				comment.paginate.setFirstEntry(false);			}		},		Do: function(page){			if (download.paginate.getMode()!='increment'){				if (download.paginate.isFirstEntry()){					download.paginate.setFirstEntry(false);				}else{					window.location.hash = 'page=' + page;				}			}			if (download.paginate.isStarted()){				return;			}			download.paginate.setPage(page);			var ajax = gAjax('get',global.RelativeRoot() + 'misc/ajax/main.php?mode=download_paginate&id_game=' + download.getIdGame()+'&id_category='+download.getIdCategory() + '&page='+download.paginate.getPage()+'&limit='+download.paginate.getLimit());			//ajax.addEvent(1,'loadScreen("div_comment_list")');			ajax.addEvent(4,'download.paginate.parseDo()');			download.paginate.ajax = ajax;			ajax.send();			download.paginate.setStarted(true);		},		parseDo: function(){			var r = download.paginate.ajax.getResponseText();			switch(download.paginate.getMode()){				case 'increment':					global.div.WriteAdd('div_download_list',r);					download.paginate.manageLinkMore();					break;			}			global.evalScripts(r);			download.paginate.setStarted(false);		},		manageLinkMore: function(){			var s;			if (parseInt(download.paginate.getPage())<parseInt(download.paginate.getPageTotal())){				s = '<a href="javascript:void(0)" onclick="download.paginate.Do('+(download.paginate.getPage()+1)+')">Exibir mais</a>';			}else{				s = '';			}			global.div.Write('div_download_list_bottom',s);		}	}}
