﻿
 function myRoom() 
 {
    // alert ('screen.width = ' + screen.width + ' screen.height = ' + screen.height); 
    playerLeft = (screen.width-994)/2;
    playerTop = (screen.height-770)/2;
    // alert ('playerLeft = ' + playerLeft + ' playerTop = ' + playerTop); 
    myRoomWindow = open('Controller.aspx', 'TOC', 'resizable=no, scrollbars=no, status=no, location=0, top=26, left=30, height=770, width=994');
    self.close ();
}

function closePopup() {
  window.close();
}

function popUp(filename,width,height) {
	popup=window.open(filename,"popup","height="+height+",width="+width+",top=0,left=0,resizable=yes,status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,location=0");
}

function popUpNoScroll(filename,width,height) {
	popup2=window.open(filename,"popup2","height="+height+",width="+width+",top=0,left=0,resizable=no,status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,location=0");
	popup2.focus();
}

function popUpGame(filename,width,height) {
    popupG=window.open(filename,"popupG","height="+height+",width="+width+",top=0,left=0,resizable=no,status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,location=0");
    if(navigator.vendor){
        // Browser is Safari
	    popupG.resizeTo(width,height+23);
    }else{
	    var ff = navigator.userAgent.indexOf('Firefox');
	    var vista = navigator.userAgent.indexOf('Windows NT 6');
	    var mac = navigator.platform.indexOf('Mac');
	    if (window.XMLHttpRequest &&  ff == -1){
	        // Browser is IE7                                    
		    popupG.resizeTo(width+10,height+81);
	    }else{
		    if(ff > 0){ 
		        // Browser is Firefox
		    	if(vista > 0){
		    		// OS is Vista
		    		popupG.resizeTo(width+6,height+47);
		    	}else{
		    		if(mac > -1){
		    		    // OS X
		    			popupG.resizeTo(width,height+15);
		    		}else{
		    		    // OS is XP
		    		   	popupG.resizeTo(width+6,height+55);
		    		}
				}
		    }else{ 
		        // Browser is IE6
		    	popupG.resizeTo(width+10,height+59);
		    }
	    }
    }
}

function GetCookie(sName)
{
    if (!document.cookie)
		return;
		
    var index = document.cookie.indexOf( sName + "=" );
	if (index == -1)
		return;
	
    var countbegin = (document.cookie.indexOf( "=", index ) + 1);
    var sValue = "";
    if ( 0 < countbegin )
    {
        var countend = document.cookie.indexOf( ";", countbegin );

        if ( countend < 0 )
            countend = document.cookie.length;

        sValue = document.cookie.substring( countbegin, countend );
    }

    return sValue;
}



function buyPopup(filename, width, height) {
	popup3=window.open("BuyPopUp.htm","popup3", "height=420,width=560,top=0,left=0,resizable=no,status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,location=0");
 }
 function standAlonePopup(flvValue) {
	popup4=window.open("TourPopUp.aspx?flv="+flvValue,"popup4", "height=400,width=467,top=0,left=0,resizable=no,status=no,toolbar=no,directories=no,menubar=no,scrollbars=no,location=0");
 }
 
function flashMovie(name) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[name];
	}
	else {
		return document[name];
	}
}

function onPointsUpdate() {
	flashMovie('beBratzFlash').onPointsUpdate();
}

function onGamePointsUpdate() {
//document.write('Suicide Notification');
window.opener.onPointsUpdate();
}

var hap = '';
var hea = '';
var hun = '';

//allow flash to update the meters values whenever they change... to use on session close
function setMeters(percent_happy,percent_heathly,percent_hungry) {
	hap = percent_happy;
	hea = percent_heathly;
	hun = percent_hungry;
}
var mypage_changes = false;

//allow flash to set flag that user has made mypage changes (blocking the meter change of having made no changes in a session)

function setFlagMyPageChanges() {
            mypage_changes = true;
}

var mypage_pals_added = false;

//allow flash to set flag that user has added pals (blocking the meter change of having added no pals in a session)

function setFlagMyPagePalsAdded() {
            mypage_pals_added = true;
}

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

var http = createRequestObject();

function manageSessionClose() {
	var soapPacket = 
		"<?xml version=\"1.0\" encoding=\"utf-8\"?>\
		<soap:Envelope\
			xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \
			xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \
			xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\
			<soap:Body>\
				<SaveUserMeterValuesUsingJonathansWay xmlns=\"http://be-bratz.com/\">\
					<keyCode>" + keycode + "</keyCode>\
					<happyMeter>" + hap + "</happyMeter>\
					<healthyMeter>" + hea + "</healthyMeter>\
					<hungryMeter>" + hun + "</hungryMeter>\
				</SaveUserMeterValuesUsingJonathansWay>\
			</soap:Body>\
		</soap:Envelope>";

	http.open("POST", "http://" + domainName + "/WebServices/General.asmx", false);
	http.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
	http.setRequestHeader("Content-Length", soapPacket.length);
	http.setRequestHeader("SOAPAction", "\"http://be-bratz.com/SaveUserMeterValuesUsingJonathansWay\"");
	//http.onreadystatechange = onMetersSent(); 
	http.send(soapPacket);
}

function onMetersSent() {
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		
	}
}

function pauseVideo() {
    flashMovie('home_theater').pauseVideo();
}