/**
 * Doll scripts
 */

function closeAndGoto ( vTarget, noUnload ) {
	window.opener.location.href = vTarget;
	if (noUnload)
		this.onbeforeunload = null;
	window.close();
}

function navigate ( vUrl ) {
	this.onbeforeunload = null;
	document.location.href = vUrl;
}

function fullDoll ( id, noDb ) {
	cUrl = '/'+language+'/dollsFullsize.php?id='+id+'&maintenance='+noDb;
	var dollWin = window.open(cUrl, 'fullSizeDoll', 'resizable=yes,menubar=no,toolbar=no,statusbar=no');
	dollWin.focus();
}

function goTo () {
	if (confirm(message)) {
		document.location.href = '/'+language+'/album.php';
	}
}

function addEvent_confBeforeUnload ( oBody ) {
	this.onbeforeunload = confBeforeUnload;
}
function confBeforeUnload () {
	return "\n"+message;
}


function showSignup() {
	if (!Sup.logged)
		Sup._open(null,'googleTracking');
}

// promo videos
function hidePlayer() {
	document.getElementById('vidPlayer').style.display = 'none';
	document.getElementById('theDoll').style.display = 'block';
}

function changeTrack(track) {
	if ((document.getElementById('vidPlayer').style.display) == 'none') {
		document.getElementById('vidPlayer').style.display = 'block';
		document.getElementById('theDoll').style.display = 'none';
	}
	playVideo(track);
}


// Comments
function getComments(id, page) {
	ajaxEngine.sendRequest('dollComments', 'id='+id, 'page='+page);
}

var commentArea;
var dollName;
function addComment(id, name) {
	if (!commentArea) {
		commentArea = document.getElementById("dollCommentArea");
	}
	if (!dollName) {
		dollName = document.getElementById("dollName");
	}

    var comment = commentArea.value;
	if (comment.length > 0) {
		ajaxEngine.sendRequest('dollComments', 'action=add', 'id='+id, 'comment='+encodeURIComponent(comment), 'dollName='+name);
	}
	commentArea.value='';
}

function deleteComment(doll, id) {
	ajaxEngine.sendRequest('dollComments', 'action=delete', 'id='+doll, 'cid='+id);
}

ajaxEngine.registerRequest('dollComments', '/'+language+'/ajax/dollComments.php');

var createDollBanner = {
	initDone: false,
	cLogo: function() {
		if (createDollBanner.playVideoTimer != undefined) {	
			clearInterval(createDollBanner.playVideoTimer);
		}
		var signupDolldiv = document.getElementById('joinFreeBanner');
		var signupDollplacer = document.getElementById('dollswfobj');
		var pos = Base.getPos(signupDollplacer);
		
		signupDolldiv.style.left = (pos[0] + 40) + 'px';
		signupDolldiv.style.top = (pos[1] + 400) + 'px';
		signupDolldiv.style.display = 'block';
	},
	closeBanner: function() {
		var signupDolldiv = document.getElementById('joinFreeBanner');
		signupDolldiv.style.display = 'none';
	},
	init: function () {
		if (!createDollBanner.initDone) {
			createDollBanner.initDone = true;
			createDollBanner.playVideoTimer = self.setInterval("createDollBanner.cLogo()", 30000);
			Base.addOnresize(createDollBanner.cLogo);
		}
	}
}