function BrowseDisplay(txt,num){
	temp = txt;
	temp = temp.replace("&amp;limit=12","");
	temp = temp.replace("&amp;limit=24","");
	temp = temp.replace("&amp;limit=36","");
	temp = temp.replace("&limit=12","");
	temp = temp.replace("&limit=24","");
	temp = temp.replace("&limit=36","");
	temp = temp.replace("language=en_US","");
	temp = temp.replace("language=es_MX","");
	temp = temp.replace("language=pt_BR","");
	temp = temp +"&limit="+num;
	return temp;
}
function bookmark(msg1,msg2){
	var ua=navigator.userAgent.toLowerCase();
	var isKonq=(ua.indexOf('konqueror')!=-1);
	var isSafari=(ua.indexOf('webkit')!=-1);
	var isMac=(ua.indexOf('mac')!=-1);
	var buttonStr=isMac?'Command/Cmd':'CTRL';
	if (document.all){
		window.external.AddFavorite(location.href,document.title);
	} else if (window.sidebar) {
		window.sidebar.addPanel(document.title,location.href,'')
	}    else if(isKonq) {
		alert('You need to press CTRL + B to bookmark our site.');
	} else if(window.opera) {
		void(0); // do nothing here (Opera 7+)
	} else if(isSafari && !isMac) { // Firefox, Netscape, Safari, iCab
		alert(msg1);
	} else if(isSafari && isMac) { // IE5/Mac and Safari 1.0
		alert(msg2);    
	} 
}
function NextItem(){
	var totalscreen=$("#totalwall").attr("value");
	var nexthidden = $("#nexthiddenwall").attr("value");
	var WallPaperItem = $("#wall"+nexthidden).clone();
	WallPaperItem.attr("class","hidden");
	$("#wall"+nexthidden).remove();
	$("#wallcontainer").append(WallPaperItem);
	nexthidden=parseInt(nexthidden)+1;
	if (nexthidden>totalscreen){ nexthidden=1;}
	$("#nexthiddenwall").attr("value",nexthidden);
	var nextshow = $("#nextshowwall").attr("value");
	$("#wall"+nextshow).attr("class","show");
	nextshow=parseInt(nextshow)+1;
	if (nextshow>totalscreen){ nextshow=1;}
	$("#nextshowwall").attr("value",nextshow);
}
function PrevItem(){
	var totalwall=$("#totalwall").attr("value");
	var nextshow = $("#nexthiddenwall").attr("value");
	nextshow=parseInt(nextshow)-1;
	if (nextshow < 1){ nextshow=totalwall;}
	var WallPaperItem = $("#wall"+nextshow).clone();
	$("#wall"+nextshow).remove();
	$("#nexthiddenwall").attr("value",nextshow);
	var nexthidden = $("#nextshowwall").attr("value");
	nexthidden=parseInt(nexthidden)-1;
	if (nexthidden < 1){ nexthidden=totalwall;}
	$("#wall"+nexthidden).attr("class","hidden");
	$("#nextshowwall").attr("value",nexthidden);
	var html =$("#wallcontainer").html();
	$("#wallcontainer").html('');
	$("#wallcontainer").append(WallPaperItem);
	var html2 =$("#wallcontainer").html();
	$("#wallcontainer").html(html2+html);
	$("#wall"+nextshow).attr("class","show");
}

function showRateIt() {
	$('#rating').hide();
	$('#rate').show();
}
function hideRateIt() {
	$('#rate').hide(); 
	$('#rating').show();
}
function showStars(numStars) {
	setTimeout('clearStars()','100');
	setTimeout('fillStars('+numStars+')', '100');
}
function clearStars() {
	for(var i=1; i <= 5; i++) {
		$('#star-'+i).attr('src', imgSrcEmpty);
	}
}
function fillStars(numStars) {
	for(var i=1; i <=numStars; i++) {
		$('#star-'+i).attr('src', imgSrcFull);
	}
	changeText(numStars-1);	
}
function changeText(index) {
	$('#starText').html(messages[index]);
}
function clearText() {
	$('#starText').html("&nbsp;");
}
function disableRating() {
	for(var i=1; i <= 5; i++) {
		document.getElementById('star-'+i).onmouseover=null;
		document.getElementById('star-'+i).onclick=null;
	}
}
function rateIt(rate,game,id) {
	var sURL = prefixURL ;
	var sHTML = $.ajax({type: "GET", url: sURL, data:'rate='+rate+'&game='+game, async: false}).responseText;
	disableRating();
	$('#starText').html(ratesuccess);
}

function adddeletefavorites(gameid,option){
if (option==1){
$.ajax({type: "POST",url: "/mochiads/actions/adddeletefavorite.php",data:'idgame='+ gameid +'&option=' + option,success:getAddFavoriteSuccess, async:true});
};
if (option==0){
$.ajax({type: "POST",url: "/mochiads/actions/adddeletefavorite.php",data:'idgame='+ gameid +'&option=' + option,success:getDelFavoriteSuccess, async:true});
}
}

function getAddFavoriteSuccess(postData){
var res =   postData.substring(0);
if (res == 1) {
document.getElementById('addsuccess').style.display="";
document.getElementById('repeat').style.display="none";
}
 if (res !=1){
 document.getElementById('repeat').style.display="";
 document.getElementById('addsuccess').style.display="none";
 }
 }

function getDelFavoriteSuccess(postData){
var res =   postData.substring(0);
window.top.location.replace("/mochiads/index.php?sel=Favorite"); 
}
