// JavaScript Document
function PopUp(url,height,width,redim)
{
	var top=((screen.height)/2)-(height/2);
	var left=((screen.width)/2)-(width/2);
	var params='toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0';	
	if(redim==1)
		var params='toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=1, copyhistory=0, menuBar=0';
	window.open(url,'','top='+top+', left='+left+', height='+height+', width='+width+','+params);
}

function addFav(url)
{
	if((navigator.appVersion.indexOf("MSIE")>0) && (parseInt(navigator.appVersion)>=4))
	{
		if(url==undefined)
		{
			var url="../../www.virtuagirlhd.com/home.php";
		}
		var title="VirtuaGirlHD";
		window.external.AddFavorite(url,title);
	}
	else
	{
		alert("Press CTRL+D to add this site to your favorites");
	}
}

function validAction(action,url,target)
{
	if(window.confirm(action))
	{
		if(target=="parent")
			window.parent.location=url;
		else
			window.location=url;
	}
}

function deleteBlog(ubId,page)
{
	if(window.confirm('Warning.\nAre you sure that you want to permanently delete the selected blog entry?'))
	{
		window.location=page+'@mode=blog&delete_blog='+ubId;
	}
}

function closeBlog(ubId,page)
{
	if(window.confirm('Warning.\nAre you sure that you want to close the selected blog entry?'))
	{
		window.location=page;
	}
}


function deleteNews(ubId)
{
	if(window.confirm('Warning.\nAre you sure that you want to permanently delete the selected news?'))
	{
		window.location='news.php@delete_news='+ubId;
	}
}

function deleteBlogPrivate(ubId)
{
	if(window.confirm('Warning.\nAre you sure that you want to permanently delete the selected private blog entry?'))
	{
		window.location='blog_private.php@delete_blog='+ubId;
	}
}


function deleteComment(ucId)
{
	if(window.confirm('Warning.\nAre you sure that you want to permanently delete the selected comment?'))
	{
		window.location='my_profile_extras.php@mode=comments&delete_comment='+ucId;
	}
}
function deleteReply(ubId,ubrId)
{
	if(window.confirm('Warning.\nAre you sure that you want to permanently delete the selected reply?'))
	{
		window.location='blog.php@ubId='+ubId+'&delete_reply='+ubrId;
	}
}

function BlockUser(usLogin,usId)
{
	if(window.confirm('Warning.\nAre you sure that you want to block '+usLogin+'?\n(make this user\'s posts invisible to others)'))
	{
		window.parent.location='user_profile.php@usLogin='+usLogin+'&mode=admin&BlockUser='+usId;
	}
}
function UnblockUser(usLogin,usId)
{
	if(window.confirm('Warning.\nAre you sure that you want to unblock '+usLogin+'?\n(make this user\'s posts visible to others)'))
	{
		window.parent.location='user_profile.php@usLogin='+usLogin+'&mode=admin&UnblockUser='+usId;
	}
}
function BanUser(usLogin,usId)
{
	if(window.confirm('Warning.\nAre you sure that you want to ban '+usLogin+'?'))
	{
		window.parent.location='user_profile.php@usLogin='+usLogin+'&mode=admin&BanUser='+usId;
	}
}
function UnbanUser(usLogin,usId)
{
	if(window.confirm('Warning.\nAre you sure that you want to unban '+usLogin+'?'))
	{
		window.parent.location='user_profile.php@usLogin='+usLogin+'&mode=admin&UnbanUser='+usId;
	}
}

function toggleDiv(objid,vis)
{
	var obj;
	try
	{
		if(objid.parentNode)	//it's an object. we needn't do anything
			obj = objid;
		else	//it's not an object
			obj = document.getElementById(objid);
	}
	catch(e)	//it's not an object and the browser errors on undefined properties
	{
		obj = document.getElementById(objid);
	}
	if(vis)
	{
		if(obj.style.visibility=='hidden')
			obj.style.visibility='visible';
		else
			obj.style.visibility='hidden';
	}
	else
	{
		if(obj.style.display=='none')
			obj.style.display='block';
		else
			obj.style.display='none';
	}
	return true;
}


function adjustDiv(value,div)
{
	var target=document.getElementById(div);
	if(!target) return;
	target.scrollLeft=target.scrollLeft+value;
	//Tu mets le scrollLeft au max dans tous les cas
}

function moncul(value)
{
	// On parcours tous les objets du document
	var AllObjects =  document.getElementsByTagName('DIV');;
	for (var z = 0; z < AllObjects.length; z++)
	{
		if(!AllObjects[z].id.indexOf("divHelp"))
		{
			document.getElementById(AllObjects[z].id).style.visibility='hidden';
		}
	}
	document.getElementById(value).style.display='block';
	document.getElementById(value).style.visibility='visible';
}

function ChangeButton(value)
{	
	if(document.getElementById(value).src.valueOf().indexOf("open")==-1)
	{
		document.getElementById(value).src='data/help_menu_open.gif';
	}
	else
	{
		document.getElementById(value).src='data/help_menu_close.gif';
	}
}

function ChangeMessage(message,champ)
{
	if(document.getElementById)
		document.getElementById(champ).innerHTML=message;
}

function dl(set)
{
	var url='../dl.php';
	if(set)
		url+='@set='+set;
	if(window.screen.colorDepth==32)
		PopUp(url);
	else if(window.confirm('VirtuaGirl HD requires your screen to be configured in 32bits to function.\n 32bits color gives you more colors, and better color gradations.\n\nTo change your screen settings, right click on your desktop, select Properties then tab Parameters, there choose 32bits and confirm.'))
		PopUp(url);
}


function dlNow2(file)
{
	var isIe=(window.navigator.userAgent.toUpperCase().indexOf('MSIE')!=-1);
	var isOpera=(window.navigator.userAgent.toUpperCase().indexOf('OPERA')!=-1);
    if(isIe && !isOpera)
	{
		window.opener.location='download.php@idl=n&mode=software';
		myDLWindow=window.open(file,'_blank','toolbar=0,location=no,directories=0,status=0, scrollbars=no,resizable=0,width=0,height=0,top=0,left=0');
		window.close();
	}
	else
	{
		window.opener.location='download.php@mode=software';
		window.close();
	}
	return false;
}

function dlNow(file,redUrl,extUrl)
{
	newDLNow(file,redUrl,extUrl);
	return false;
}
function newDLNow(file,redUrl,extUrl)
{
	var isIe=(window.navigator.userAgent.toUpperCase().indexOf('MSIE')!=-1);
	var isOpera=(window.navigator.userAgent.toUpperCase().indexOf('OPERA')!=-1);
    if(isIe && extUrl==0 && !isOpera)
	{
		myDLWindow=window.open(file,'_blank','toolbar=0,location=no,directories=0,status=0, scrollbars=no,resizable=0,width=0,height=0,top=0,left=0');
		location.href=redUrl+'@idl=n';
	}
	else
	{
		//alert('this is not ie, is an ext url, or is Opera');
		location.href = redUrl;
	}
}

function BuyHer(mseId,moName,mseName,SetPriceTicket)
{
	if(window.confirm('You’re about to buy '+moName+' / '+mseName+' for '+SetPriceTicket+' ticket(s).'))
	{
			window.location='set.php@setId='+mseId+'&BuyHer=true';
	}
}



function disable_po(value1,value2)
{
	document.getElementById(value1).disabled=true;
	if(document.getElementById(value1).checked==true)
	{
		document.getElementById(value2).checked='checked';
	}
}





var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ 
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}

function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> characteres Maximum.'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}