/**
 * 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);
}

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);
		}
	}
}

function useGiftcode() {
	var giftcode = document.getElementById("giftcode").value;
	var dollId = document.getElementById("giftcodeDollId").value;
	
	if (dollId > 0) {
		ajaxEngine.sendRequest('giftCodes', 'id='+dollId, 'giftcode='+encodeURIComponent(giftcode));
	}
	document.getElementById("giftcode").value = '';
}

function getFlashVars() {
	var bannerType = 32;//5;
	var bannerId;
	var fVars = {};

	if ('object' == typeof(OA_output)) { 
		if ('undefined' !== typeof(Ads.bz[bannerType]) && 'undefined' !== typeof(OA_output[Ads.bz[bannerType]]) && '' !== OA_output[Ads.bz[bannerType]]) {
			var arr = OA_output[Ads.bz[bannerType]].split('|'); 
			if (arr[1]) {
				bannerId = arr[1];
				fVars.adContentUrl = arr[0];
				fVars.adViewCallbackUrl = 'http://ox.stardoll.com/www/delivery/lg.php?bannerid='+bannerId;
				fVars.adClickUrl = 'http://ox.stardoll.com/www/delivery/ck.php?bannerid='+bannerId;
			}
		}
	}

	return fVars;
}

ajaxEngine.registerRequest('giftCodes', '/'+language+'/ajax/giftCodes.php');