country = "en-us";

$( document ).ready( function(){
	var moreFunc = function(){
		loginRegEvent();
		logValidation();
		secretCode();
		hashLanguage();
		enableCalendar();
	}
	
	setTimeout( function(){ $("#getflash").css("display","block");  } , 90 );
	
	if( not_real_page == true ){
		facebook();
		homeRotator(); 
		bratzTimeline();
		//logValidation();
		bratzanniversary();
		//loginRegEvent();
		chooseCountry();
		checkBioPages();
		//GoogleListener();
		//enableCalendar();
		playVideo();
		wtbRandomizer();
		accessVib();
		checkFlashContent();
		activeMenu();
		//secretCode();
		scrollingGames();
		scrollingCatalog();
		//bratz10Catalog();
		redirect();
		homePromos();
		interstitial();
		musicPlayer();
		//$( document ).pngFix();
		//loginTabs();
		googleConListen();
		moreFunc(); 
		rockPage();
		checkWtb();
		comingsoon();
		loadCoupons();
	}
	else{
		$.get( base + "/pub/en-us/bratzHash.js" , { } , function( geturl ){
				var result = eval( "(" + geturl + ")" );
				bratzHash = result;
				//hashLanguage();
				moreFunc();
		});
		
	}
});

$( window ).load( function() {

	setTimeout( function() {
		$("#div-bios-menu-cloe").click();
	},1000);

});

function comingsoon(){
	if( $__( $( "#wrapper-comingsoon" ) ) ){
		$("#div-content-"+language).css("background","url()");
		//$("#div-logo").css("display","none");
		$("#div-main").css("height","873px"); 
		//$("#div-menu-wrapper-en-us").css("left","202px");
		//$("#div-menu-wrapper-en-us").css("top","-53px");
	}
}

function googleConListen(){
	if( google_return_con == "reg" ){
			$("#register").click();
	}
}

function loadCoupons(){
	
	var params = { wmode : "transparent" };
	params.base = base + "smarty_files/templates/flash/coupons/bratz_coupons_flash/";
	var attributes = { };
	var flashvars = { couponXML : "couponXML/bratz.xml" };
	
	if(couponSource){
		flashvars.source = couponSource;

	}else{
		flashvars.source = "web";
	}
	
	swfobject.embedSWF("smarty_files/templates/flash/coupons/bratz_coupons_flash/FallCouponApplication.swf", "bratz-coupons", "800", "650", "9.0.0","smarty_files/templates/flash/expressInstall.swf", flashvars, params, attributes);
	
}


function hashLanguage(){
	/* Translation for Registration */

	$("#dialog-title").html(bratzHash.language.registration.reg_step1);
	$("#dialog-desc").html(bratzHash.language.registration.introduction);
	$("#dialog-dob").html(bratzHash.language.registration.reg_dob);
	$("#dialog-date").val(bratzHash.language.registration.reg_yyyymmdd);
	$("#calendar").html(bratzHash.language.registration.reg_calendar);
	$("#span-reg-firstname").html(bratzHash.language.registration.reg_firstname);
	$("#span-reg-lastname").html(bratzHash.language.registration.reg_lastname);
	$("#span-reg-username").html(bratzHash.language.registration.reg_username);
	$("#span-reg-password").html(bratzHash.language.registration.reg_password);
	$("#span-reg-gender").html(bratzHash.language.registration.reg_gender);
	$("#span-reg-girl").html(bratzHash.language.registration.reg_girl);
	$("#span-reg-boy").html(bratzHash.language.registration.reg_boy);
	$("#span-reg-email").html(bratzHash.language.registration.reg_email);
	$("#span-reg-parentemail").html(bratzHash.language.registration.reg_parent_email);
	$("#span-reg-country").html(bratzHash.language.registration.reg_country);
	$("#span-reg-state").html(bratzHash.language.registration.reg_state);
	$("#reg-signup-state").html(bratzHash.language.registration.reg_selectone);
	$("#span-reg-zip").html(bratzHash.language.registration.reg_zip);
	$("#span-news").html(bratzHash.language.registration.reg_newsletters);
	$("#span-reg-optin1").html(bratzHash.language.registration.reg_optin1);
	$("#span-reg-optin2").html(bratzHash.language.registration.reg_optin2);
	$("#btn-next").html(bratzHash.language.registration.reg_next);
	$("#reg-complete, #p-reg-complete").html(bratzHash.language.registration.reg_complete);
	$("#reg-complete").html(bratzHash.language.registration.reg_complete);
	$("#enable-product-code").html(bratzHash.language.registration.reg_productcode);
	$("#complete-btn-close").html(bratzHash.language.registration.reg_close);
	
	$("#logon-header-left").html(bratzHash.language.login.login_desc);
	$("#span-login-username").html(bratzHash.language.login.login_username);
	$("#span-login-password").html(bratzHash.language.login.login_password);
	$("#span-login-password").html(bratzHash.language.login.login_password);
	$("#a-logon-forgot").html(bratzHash.language.login.login_forgot);
	$("#a-logon-register").html(bratzHash.language.login.login_register);
	$("#btn-logon").html(bratzHash.language.login.login_button);
	$("#forgot-header-left").html(bratzHash.language.login.login_forgot);
	$("#p-forgot-desc").html(bratzHash.language.login.login_forgot_emailed);
	$("#forgot-firstname").html(bratzHash.language.login.forgot_firstname);
	$("#forgot-email").html(bratzHash.language.login.forgot_email);
	$("#span-forgot-username").html(bratzHash.language.login.forgot_username);
	$("#span-forgot-email").html(bratzHash.language.login.forgot_parent_email);
	$("#forgot-submit").html(bratzHash.language.login.forgot_submit);
	$("#btn-submit").html(bratzHash.language.others.labelSubmit);

	$("#tab-classic").html(bratzHash.language.newGames.classic);
	$("#tab-modern").html(bratzHash.language.newGames.current);

	/* Translation For Bios Pagination */
	$("#tab-bio").html(bratzHash.language.bio.bio);
	$("#tab-downloads").html(bratzHash.language.bio.downloads);
	$("#tab-blog").html(bratzHash.language.bio.blog);
	

	/* Translation for Masquerade page */
	$("#intro").html(bratzHash.language.masq.instructions);
	$("#h1-masq").html(bratzHash.language.masq.header)
	
	/* For New Catalog Translation */
	/* Categories */
	$("#cata-category").html(bratzHash.language.catalog.category);
	$("#cata-dolls").html(bratzHash.language.catalog.dolls);
	$("#cata-accessories").html(bratzHash.language.catalog.accessories);
	$("#cata-lifestyle").html(bratzHash.language.catalog.lifestyle);
	$("#cata-stylingheads").html(bratzHash.language.catalog.stylingheads);
	/* Sub Categories */
	$("#cata-productline").html(bratzHash.language.catalog.productline);
	$("#cata-onthemic").html(bratzHash.language.catalog.onthemic);
	$("#cata-platinumshimmerz").html(bratzHash.language.catalog.platinumshimmerz);
	$("#cata-rock").html(bratzHash.language.catalog.rock);
	$("#cata-stylininthecity").html(bratzHash.language.catalog.stylininthecity);
	$("#cata-allglammedup").html(bratzHash.language.catalog.allglammedup);
	$("#cata-masqueradebybratz").html(bratzHash.language.catalog.masqueradebybratz);
	/* Other */
	$("#cata-search").html(bratzHash.language.catalog.search);
	$("#cata-found").html(bratzHash.language.catalog.found);
	$("#cata-of").html(bratzHash.language.catalog.of);
	$("#cata-products").html(bratzHash.language.catalog.products);
	
	/* Video Page */
	$("#watch-video").html(bratzHash.language.video.watch);

	/* If country is canada, masquerade can display Canadian version, if not display US version*/
	if(page == "masqueradegame"){
		$(".choosecountry").click(function(){
			//if(this.id == "fr-ca"){
		if(this.id == "en-ca" || this.id == "fr-ca"){  
				window.location = base+"?section=masqueradegame&uriLang=" + this.id + "&currCountry=" + this.id;
			}else{
				window.location = base+"?section=masqueradegame&uriLang=en-us&currCountry=" + this.id;
			}
		});
		/*
		$(".choosecountry").click(function(){
			if(this.id != "en-us"){
				window.location = base+"?section=masqueradegame&uriLang=en-us&currCountry=" + this.id;
			}
		});
		*/
	}
		
	/* Shifts around positionings on certain graphics based on language*/

	if(language == "nl"){
		$("#tab-modern").css("top" , "5px");
	}
	if (language != "en"){
		$("#div-games-yasmin ").css("left" , "-275px");
		$("#div-img-cloe").css("left" , "-265px");
		$("#div-catalog-sasha").css("left" , "-270px");
	}
}

function $__( objId ) {
        return $( objId ).get(0);
}

function musicPlayer(){
	
	if(page != "video"){

		if( $__( $( "#music-player" ) ) ){
			/* see if off exists */
			var params = { wmode : "transparent" };
			var attributes={wmode : "transparent" };
			var on = bratzHash.language.toplinks["audio-on"];
			var off = bratzHash.language.toplinks["audio-off"];
			
				
			if(getCookie("volOff")){
				
				var flashvars=
				{
					onString:on, 
					offString:off, 
					playState:0
				}
			
				flashvars.songURL = base+"smarty_files/templates/sounds/Bratz_en.mp3";
			
				swfobject.embedSWF( "smarty_files/templates/flash/build/MGAMusicPlayer.swf" , "music-player" , "105" , "20" , "9.0.0" , "", flashvars , params , attributes );

			} else { 
				var flashvars=
				{
					onString:on, 
					offString:off, 
					playState:0
				}
					
						flashvars.songURL = base+"smarty_files/templates/sounds/Bratz_en.mp3";

			
				swfobject.embedSWF( "smarty_files/templates/flash/build/MGAMusicPlayer.swf" , "music-player" , "105" , "20" , "9.0.0" , "", flashvars , params , attributes );
					}
				
      		}
		}
} 

function gotoLink( website ){
	window.open( website ,"","menubar=1,resizable=1,location=1,status=1,scrollbars=1" );
}

function interstitial(){
	
	if(  $__( $( "#interstitial" ) ) ) {
		
		var interstit = bratzHash.interstitial.image;
		
		$("#interstitial").css( {"background-image" : "url("+ interstit  +")" } );
	
	}
}

function facebook(){

	var retailer = $.getUrlVar('facebook');
	
	if ( retailer != null && retailer != "") {
	
		var gotoWebsite = "";
		var arr = new Array();
    	arr["walmart"] = "http://www.walmart.com/search/search-ng.do?search_constraint=0&ic=48_0&search_query=Bratz";
    	arr["kmart"] = "http://www.kmart.com/shc/s/search_10151_10104?keyword=bratz";
    	arr["toyrus"] = "http://www.toysrus.com/shop/index.jsp?categoryId=2274244";
    	arr["target"] = "http://www.target.com/b/ref=gp_se_search-results-box/189-5397131-8887211?ie=UTF8&node=1038692";
		arr["amazon"] = "http://www.amazon.com/s/?ref=ty_mga_direct&tag=mgaentertainm-20&ie=UTF8&hidden-keywords=bratz%20-barbie&rh=n:165793011,p_6:ATVPDKIKX0DER#/ref=sr_nr_p_lbr_one_browse-bin_0?rh=n%3A165793011%2Cp_6%3AATVPDKIKX0DER%2Cp_lbr_one_browse-bin%3ABratz&bbn=165793011&hidden-keywords=bratz+-barbie&ie=UTF8&qid=1290147192&rnid=2364405011";
	
		gotoWebsite = arr[ retailer ];
		pageTracker._trackEvent('Facebook', gotoWebsite);
		window.location = gotoWebsite;
		
	}
}

var currentWebsite = "";

function openInterstitial(id) {
	flashInt(id);
}
	
function redirect(id){


	var arr = new Array();
	    arr["wtb-walmart"] = "http://www.walmart.com/search/search-ng.do?search_constraint=0&ic=48_0&search_query=Bratz";
	    arr["wtb-kmart_2"] = "http://www.kmart.com/shc/s/search_10151_10104?keyword=bratz";
	    arr["wtb-toyrus"] = "http://www.toysrus.com/shop/index.jsp?categoryId=2274244";
	    arr["wtb-target_2"] = "http://www.target.com/b/ref=gp_se_search-results-box/189-5397131-8887211?ie=UTF8&node=1038692";
		arr["wtb-amazon"] = "http://www.amazon.com/s/?ref=ty_mga_direct&tag=mgaentertainm-20&ie=UTF8&hidden-keywords=bratz%20-barbie&rh=n:165793011,p_6:ATVPDKIKX0DER#/ref=sr_nr_p_lbr_one_browse-bin_0?rh=n%3A165793011%2Cp_6%3AATVPDKIKX0DER%2Cp_lbr_one_browse-bin%3ABratz&bbn=165793011&hidden-keywords=bratz+-barbie&ie=UTF8&qid=1290147192&rnid=2364405011";
		arr["wtb-tikes2"] = "http://www.littletikes.com/";
		
		arr["facebook"] = "http://www.facebook.com/bratz";
	 	arr["promo-middle"] = "http://www.facebook.com/bratz";
	    arr["myspace"] = "http://www.myspace.com/bratz.girlz";
		arr["redirect-facebook"] = "http://www.facebook.com/bratz";
		arr["facebook-icon"] = "http://www.facebook.com/bratz";
		arr["redirect-myspace"] = "http://www.myspace.com/bratz.girlz";
		arr["social-media-facebook"] = "http://www.facebook.com/bratz";
		arr["social-media-facebook-es"] = "http://www.facebook.com/bratz.es";
		arr["social-media-twitter"] = "http://www.twitter.com/bratz";
		arr["social-media-youtube"] = "http://www.youtube.com/bratz";
		arr["contest-header"] = "http://www.girlslife.com/post/2010/10/07/And-the-Next-Bratz-is.aspx";
		arr["contest-header2"] = "http://www.missoandfriends.com/contests/girl-of-the-moment.php";
	    arr["social-media-img1"] = "http://www.facebook.com/bratz";
	    arr["social-media-img2"] = "http://www.myspace.com/bratz.girlz";
		arr["tru_canada_fr"] = "http://www.toysrus.ca/home/index.jsp?categoryId=2567269&overrideStore=TRUSCA&locale=fr_CA";
		arr["walmart_canada_fr"] = "http://www.walmart.ca/search?q=bratz&DepartmentID=0&AncestorID=10012&destination=here&lang=fr";
		arr["tru_canada_en"] = "http://www.toysrus.ca/family/index.jsp?categoryId=11373342";
		arr["walmart_canada_en"] = "http://www.walmart.ca/search?q=bratz&DepartmentID=0&AncestorID=10012&destination=here";
		/* UK links */
		arr["amazon_uk"] = "http://www.amazon.co.uk/gp/search/ref=sr_in_-2_p_n_featured_charact_15?rh=n%3A468292%2Cn%3A%21595312%2Cn%3A%21595314%2Cn%3A364098031%2Cp_n_featured_character_browse-bin%3A367974031&bbn=364098031&ie=UTF8&qid=1307704360&rnid=356968031";
		arr["entertainer_uk"] = "http://www.thetoyshop.com/SoftToysAndDolls/FashionDolls/Bratz";
		arr["tesco_uk"] = "http://direct.tesco.com/search/default.aspx?search=bratz&confirm.x=0&confirm.y=0";
		arr["toyrus_uk"] = "http://www.toysrus.co.uk/index.jsf?fh_eds=%EF%BF%BD&fh_search=bratz&fh_refpath=facet_6&fh_refview=lister&fh_view_size=10&fh_start_index=0&fh_location=%2f%2ftrus%2fen_GB%2fcategories%3C{trus_trus}%2fitemtype%3dproduct&fh_reffacet=brand&omitxmldecl=yes&fh_maxdisplaynrvalues_brand=-1";
		arr["littlewoods_uk"] = "http://www.littlewoods.com/e/q/bratz.end?cmtag=o&_requestid=16545";
		arr["woolworths_uk"] = "http://www.woolworths.co.uk/e/q/bratz.end?cmtag=o&_requestid=36595";
		arr["smyths_uk"] = "http://www.smythstoys.com/Shop_Product_List.aspx?Profile=Sterling&query=bratz";
		arr["toysmaster_uk"] = "http://www.toymastershop.co.uk/search.aspx?SearchTerm=bratz";
		arr["bigw_au"] = "http://www.bigw.com.au";
		arr["target_au"] = "http://www.target.com.au";
		arr["toyrus_au"] = "http://www.toysrus.com.au";
		arr["toyworld_au"] = "http://www.toyworld.com.au";
		arr["myer_au"] = "http://www.myer.com.au";
		arr["toyscenter"] = "http://www.toyscenter.it";
		arr["giocheria"] = "http://www.giocheria.it";

		$(".where-to-buy").click( function(){
			$("#interstitial-"+language).fadeIn("slow");
			currentWebsite = arr[this.id];
		 });

	$("#interstitial-yes").click( function(){ 
		gotoLink( currentWebsite );
		pageTracker._trackEvent('retailers', currentWebsite);
		$("#interstitial-"+language).fadeOut("slow");
	});

	$("#interstitial-no").click( function(){ 
		$("#interstitial-"+language).fadeOut("slow");
	});
}

function flashInt( id ){
	var arr = new Array();
	   	arr["blogfacebook"] = "http://www.facebook.com/bratz";
 		arr["lovematch"] = "http://www.facebook.com/bratz#!/bratz?sk=app_293535017357100";

		currentWebsite = arr[ id ];	

		$("#interstitial-"+language).css("top","400px");
		$("#interstitial-"+language).fadeIn("slow");
}

function bratzanniversary(){
	if(bratzPage == "timeline" || bratzPage == "catalog"){
		$("#div-bratz10-container").css("display" , "none");
	}
}

function chooseCountry(){
	
	$(".choosecountry").hover(function() {
			var countryid = this.id + "-mouseover";
			//alert(countryid);
			$("#country-texture-hover").addClass(countryid);
		},
			function() {
			var countryid = this.id + "-mouseover";
			$("#country-texture-hover").removeClass(countryid);
		}
	);

		if( $__( $( "#div-country-chooser" ) ) ){
				$("#a-country, #a-flag").click( function(){
					$("#country-wrapper").css("display","block");
				});

				$("#country-header-close").click( function() {
					$("#country-wrapper").css("display","none");
				});
				
				if (page != "masqueradegame"){
					$(".choosecountry").click( function() {
						if ( $("#country-wrapper").css("display") == "block") {
							var currCountry = this.id;
							setCookie("bratzlang", this.id);
							window.location= base+"?section=" + page + "&uriLang=" + this.id;
							pageTracker._trackEvent('Country:', currCountry);

						}
					});
				}

		}//end if
		
		if($__( $( "#canada-lang-chooser" ) ) ){
			
			$("#glam_"+country).addClass("glamactive");	
		
			$(".canadaLang").click(function(){
				$(".canadaLang").removeClass("glamactive");
				$("this.id").addClass("glamactive");	
			});		
		}	
}

function rockPage(){
	$("#enter-now").click( function(){ 
		iFrameWindow();
	} );
	$("#x-close-iframe").click( function(){ 
		$("#div-x-close-wrapper").css("display" , "none");
			closeIframe();
	});

	if( data.length > 0  ){
		iFrameWindow();
	}
}

function iFrameWindow(){
		$("#div-rock-iframe-wrapper,#iframe-rock, #div-x-close-wrapper").fadeIn("slow");
		if( data != "" ){
			$("#iframe-rock").attr("src","sweepstakes/index.php?data=" + data );
		}
		else{
			$("#iframe-rock").attr("src","sweepstakes/index.php");
		}
}

function launchRock(){
	if ( obj.id ){
		$("#rock-game-wrapper").css("display","block");
		$("#games-wrapper").css("z-index" , "1500");

			var params = { wmode : "transparent" };
			params.base = base + "smarty_files/templates/flash/bratzrock/"
		 	var attributes = {};
			var flashvars = {  };

			if( bratzrockdata != "" ){
				flashvars.data = bratzrockdata;
			}

			swfobject.embedSWF("smarty_files/templates/flash/bratzrock/BratzMusicVideoGame.swf", "rock-game", "800", "600", "9.0.0","smarty_files/templates/flash/expressInstall.swf", flashvars, params, attributes);  

			var currentGame = this.id;

			pageTracker._trackEvent('BratzGame', currentGame);	
			
			$("#rock-game-close").click(function(){
				$("#rock-game-wrapper").css("display","none");
				$("#games-wrapper").css("z-index" , "500");
			});
	}
	else{
		
		$("#overlay-wrapper").css({ "display" : "block" }).animate({ "opacity" : ".76" ,  "height" : "1135px"} , 1500 , function(){
			
			$("#logon-wrapper,#overlay-login").css({ "display" : "block" , "opacity" : "1" });
			$("#forgot-wrapper").css("display","none");
			$("#logon-dialog").css("display","block");
			
			$("#a-logon-forgot").click( function(){
				$("#logon-wrapper").css("display","none");
					$("#forgot-wrapper").fadeIn('slow');
					$("#div-forgot").css("height","252px");
			});
		 });
	}
	
}

function scrollingGames(){
	
		$(".games").click(function(){

			$(".games-scroller").css("z-index" , "502");
		});
	
	if(  $__( $( ".games-scroller" ) ) ){
		var arr = bratzHash.games;

		if (game){
			var toString = "<a href='javascript://' id='" + bratzHash.games[game].id + "' class='games png'></a>";
			
			if (game == "bratzrock"){
				launchRock();
			}
			
			for( x in arr ){
				
					toString += "<a href='javascript://' id='" + arr[x].id + "' class='games png'></a>";
				
			}
				$(".game-items").html( toString );	
				$(".game-items").cycle({ 
					cleartype:  !$.support.opacity, 
					cleartypeNoBg: true,
					fx: 'fade', 
					speed:  'slow', 
					timeout: 0, 
					next:   '.next', 
					prev:   '.prev' 
				});
				
					$(".games").mouseover(function(){
						$(".games-scroller").addClass("gamesOver")
					});
					$(".games").mouseleave(function(){
						$(".games-scroller").removeClass("gamesOver")
					});
		}	
		else{
                for( x in arr ){
                                if ( x != game ) {
                                        toString += "<a href='javascript://' id='"+ arr[x].id +"' class='games png'></a>";
                                }
                        }
                        $(".game-items").html( toString );
                        $(".game-items").cycle({
                                cleartype:  !$.support.opacity,
                                cleartypeNoBg: true,
                                fx: 'fade',
                                speed:  'slow',
                                timeout: 0,
                                next:   '.next',
                                prev:   '.prev'
                        });
						$(".games").mouseover(function(){
							$(".games-scroller").addClass("gamesOver")
						});
						$(".games").mouseleave(function(){
							$(".games-scroller").removeClass("gamesOver")
						});

	}

	
	$("#games-masquerade-en").click(function(){
		window.location="?section=masquerade";
	});

	$("#games-rock-"+language).click(function(){
		if(obj.id){
			$("#rock-game-wrapper").css("display","block");
			$("#games-wrapper").css("z-index" , "1500");
			var params = { wmode : "transparent" , base : "smarty_files/templates/flash/bratzrock/"};
			params.base = base+"smarty_files/templates/flash/bratzrock/";
		 	var attributes = {};
			var flashvars = { };
			swfobject.embedSWF("smarty_files/templates/flash/bratzrock/BratzMusicVideoGame.swf", "rock-game", "800", "600", "9.0.0","smarty_files/templates/flash/expressInstall.swf", flashvars, params, attributes);  

			var currentGame = this.id;

			pageTracker._trackEvent('BratzGame', currentGame);	
		}else{
			$("#login").click();  
		}
	});
	$("#rock-game-close").click(function(){
			$("#rock-game-wrapper").css("display","none");
			$("#games-wrapper").css("z-index" , "500");
	});

	
	$("#games-glam-"+language).click(function(){
		$("#glam-game-wrapper").css("display","block");
		$("#games-wrapper").css("z-index" , "1500");
			
			var params = { wmode : "transparent" };
 			var attributes = {};
			var flashvars = { };
			swfobject.embedSWF("smarty_files/templates/flash/Glam_bratz_2010/Bratz_Glam2.swf", "glam-game", "600", "400", "9.0.0","smarty_files/templates/flash/expressInstall.swf", flashvars, params, attributes);  
			
			var currentGame = this.id;
			
			pageTracker._trackEvent('BratzGame', currentGame);	
	});
	
	$("#glam-game-close").click(function(){
			$("#glam-game-wrapper").css("display","none");
			$("#games-wrapper").css("z-index" , "500");
	});
	
	$("#games-lovemeter-"+language).click(function(){
	
			
		$("#lovemeter-game-wrapper").css("display","block");
		$("#games-wrapper").css("z-index" , "1500");
			
			var params = { wmode : "transparent" };
 			var attributes = {};
			var flashvars = { };
			swfobject.embedSWF("smarty_files/templates/flash/love_meter_bratz_2010/lovemeter.swf", "lovemeter-game", "600", "400", "9.0.0","smarty_files/templates/flash/expressInstall.swf", flashvars, params, attributes);
			
			var currentGame = this.id;
		
			pageTracker._trackEvent('BratzGame', currentGame);  			

	});
	
	
	$("#lovemeter-game-close").click(function(){
			$("#lovemeter-game-wrapper").css("display","none");
			$("#games-wrapper").css("z-index" , "500");
	});
	
	$("#games-fishtank-"+language).click(function(){
	
			
		$("#fishtank-game-wrapper").css("display","block");
		$("#games-wrapper").css("z-index" , "1500");
			
			var params = { wmode : "transparent" };
 			var attributes = {};
			var flashvars = { };
			swfobject.embedSWF("smarty_files/templates/flash/FishTank.swf", "fishtank-game", "600", "400", "9.0.0","expressInstall.swf", flashvars, params, attributes);
			
			var currentGame = this.id;
		
			pageTracker._trackEvent('BratzGame', currentGame);  	
	});
	
	
	$('#fishtank-game-close').click(function(){
			$("#fishtank-game-wrapper").css("display","none");
			$("#games-wrapper").css("z-index" , "500");
	});
		
	$("#games-mall-"+language).click(function(){
		
		if( obj.id ){
		$("#mall-game-wrapper").css("display","block");
		$("#games-wrapper").css("z-index" , "1500");
			var params = { wmode : "transparent" , base: "smarty_files/templates/flash/bratzmall/build/" };
			//params.base = base + "smarty_files/templates/flash/bratzmall/build/";
 			var attributes = {};
			var flashvars = {gamepipe: "http://www.bratz.com/gamepipe/index.php"};
			//flashvars.gamepipe = gamepipe + "index.php";
			swfobject.embedSWF("smarty_files/templates/flash/bratzmall/build/BoutiqueLoader.swf", "mall-game", "800", "600", "9.0.0","expressInstall.swf", flashvars, params, attributes); 
			
			var currentGame = this.id;
		
			pageTracker._trackEvent('BratzGame', currentGame);
			
				}else { 
					//setCookie("secretcode", "1");
					setTimeout( function(){ $("#login").click(); } , 500 );
					 
				} 	
	});
	
	
	
	$('#mall-game-close').click(function(){
			$("#mall-game-wrapper").css("display","none");
			$("#games-wrapper").css("z-index" , "500");
	});
		
	
}
	if(  $__( $( ".game-items" ) ) ){
			var google_conversion_label = "RZSeCMrr4AEQgIyC7wM";
			$("#google_conversion").html("<img src='http://www.googleadservices.com/pagead/conversion/1038124544/?label=RZSeCMrr4AEQgIyC7wM&amp;guid=ON&amp;script=0' border='0' />");
	}
	
}


function scrollingCatalog(){
	
	if( $__( $("#div-catalog-container") ) ){
		
		var catalog_arr = bratzHash.productGallery.a_allprod.dolls;
		
		var toString = "";
		
		for( x in catalog_arr ){
			
			toString += "<div class=\"doll-list\">";
			toString += "<img src=\""+ catalog_arr[x]["imgpath"] +"\" class=\""+ catalog_arr[x]["cssClass"]+"\"/>";	
			toString += "<p class=\"dolls-desc\">" + catalog_arr[x]["description"]  + "</p>";
			toString += "</div>";
			
		}
		
		$("#dolls-wrapper").html( toString );
		
		
		
		var catalog_acc = bratzHash.productGallery.a_allprod.accessories;

		var accString = "";

		for( x in catalog_acc ){

				accString += "<div class=\"acc-list\">";
				accString += "<img src=\""+ catalog_acc[x]["imgpath"] +"\" class=\""+ catalog_acc[x]["cssClass"]+"\"/>";	
				accString += "<p class=\"acc-desc\">" + catalog_acc[x]["description"]  + "</p>";
				accString += "</div>";

			}

	$("#acc-wrapper").html( accString );

	$("#acc-wrapper, #dolls-wrapper").cycle({ 
			cleartype:  !$.support.opacity, 
			cleartypeNoBg: true,
	   		fx: 'fade', 
		    speed:  'slow', 
		    timeout: 0, 
		    next:   '.next', 
		    prev:   '.prev' });
	
	}

}

function bratz10Catalog(){
		
		var catalog10_arr = bratzHash.productGallery.a_allprod.dolls10;
		
		var toString = "";
		
		for( x in catalog10_arr ){
			
			toString += "<div class=\""+ catalog10_arr[x]["cssClass"]+"\" id=\""+ catalog10_arr[x]["cssId"]+"\" >";
			toString += "<img src=\""+ catalog10_arr[x]["imgpath"] +"\" />";
			toString += "<img src=\""+ catalog10_arr[x]["iconpath"] +"\" class=\"iconclass\"/>";	
			toString += "<p class=\"bratz10-desc\">" + catalog10_arr[x]["description"]  + "</p>";
			toString += "<p class=\"bratz10-bio\">" + catalog10_arr[x]["bio"]  + "</p>";
			toString += "</div>";
			
		}
		
		
		
		$("#bratz10-wrapper").html( toString );
		
		var flashVersion = getFlashVersion().split(',').shift();
		if (jQuery.browser.mozilla && flashVersion >= 10){
		
		$("#bratz10-wrapper").cycle({ 
				cleartype:  !$.support.opacity, 
				cleartypeNoBg: true,
		   		fx: 'fade', 
			    speed:  'slow', 
			    timeout: 0, 
			    next:   '.next', 
			    prev:   '.prev' });
	
		}else if(jQuery.browser.msie){
			
			$(".bratz10").css("background" , "#ffffff");
			$("#bratz10-container").css("background" , "url('smarty_files/templates/images/catalog2.png')");
			
			$("#bratz10-wrapper").cycle({ 
					cleartype:  !$.support.opacity, 
					cleartypeNoBg: true,
			   		fx: 'fade', 
				    speed:  'slow', 
				    timeout: 0, 
				    next:   '.next', 
				    prev:   '.prev' });
			
		}
		
		
		
		/*$(".doll-selector").hover(function(){
			
			var currentbratz = this.id.split("-");				
			currentten = currentbratz[1];
			
			alert(currentten);
			
			
			$(".bratz10").each( function( val , i ) {
					$("#" + this.id ).removeClass( this.id + "-current");
					$("#" + this.id  ).addClass( "not-current" );
				});
				
			$("#"+currentten).removeClass("not-current");
			$("#"+currentten).addClass( currentten + "-current");
			
		});*/

		
}

function getFlashVersion(){

	// ie
	try {
		try {
			// avoid fp6 minor version lookup issues
			// see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
			var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
			try { axo.AllowScriptAccess = 'always'; }
			catch(e) { return '6,0,0'; }
		} catch(e) {}
		return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
		// other browsers
	} catch(e) {
		try {
			if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
				return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
			}
		} catch(e) {}
	}

return '0,0,0';

}

function homeRotator(){
	
	
	if(  $__( $( "#rotator-wrapper" ) ) ){
			var google_conversion_label = "_s_kCNLq4AEQgIyC7wM";
			$("#google_conversion").html("<img src='http://www.googleadservices.com/pagead/conversion/1038124544/?label=_s_kCNLq4AEQgIyC7wM&amp;guid=ON&amp;script=0' border='0' />");
	}
	
		/*Old dolls */
		
		if(country !="en-us" && country !="en-uk"){
			var htmlString = "<img src='smarty_files/templates/images/home_cloe.png' />";
			htmlString += "<img src='smarty_files/templates/images/home_jade.png' />";
			htmlString += "<img src='smarty_files/templates/images/home_sasha.png' />";
			htmlString += "<img src='smarty_files/templates/images/home_yasmin.png' />";
		}
		else{
		
		var htmlString = "<img src='smarty_files/templates/images/10th_girls/10th_ann_Adri.png' />";
		htmlString += "<img src='smarty_files/templates/images/10th_girls/10th_ann_Ashby.png' />";
		htmlString += "<img src='smarty_files/templates/images/10th_girls/10th_ann_Carrie.png' />";
		htmlString += "<img src='smarty_files/templates/images/10th_girls/10th_ann_Joelle.png' />";
		htmlString += "<img src='smarty_files/templates/images/10th_girls/10th_ann_Leora.png' />";
		htmlString += "<img src='smarty_files/templates/images/10th_girls/10th_ann_Liliana.png' />";
		htmlString += "<img src='smarty_files/templates/images/10th_girls/10th_ann_Lydia.png' />";
		htmlString += "<img src='smarty_files/templates/images/10th_girls/10th_ann_Shadi.png' />";
		htmlString += "<img src='smarty_files/templates/images/10th_girls/10th_ann_Shira.png' />";
		htmlString += "<img src='smarty_files/templates/images/10th_girls/10th_ann_Tyla.png' />";
		}
	
	var flashVersion = getFlashVersion().split(',').shift();
	
	if (jQuery.browser.mozilla && flashVersion >= 10) {
		
	
		$("#div-home-rotator").html(htmlString);
		$("#div-home-rotator").cycle({
				fx: 'fade',
				speed: 'slow',
				timeout: 5000 
		});

				//drop the code for the fading thing here.
	} else if(jQuery.browser.msie) {
				var params = { wmode : "transparent"};
				var attributes = {};
				var flashvars = {};
				
				if(country!="en-us"){
					flashvars.image1 = "smarty_files/templates/images/home_cloe.png,1,10";
					flashvars.image2= "smarty_files/templates/images/home_jade.png,2,10";
					flashvars.image3= "smarty_files/templates/images/home_sasha.png,3,10";
					flashvars.image4= "smarty_files/templates/images/home_yasmin.png,4,10";
				}else{
					flashvars.image1 = "smarty_files/templates/images/10th_girls/10th_ann_Adri.png,1,10";
					flashvars.image2 = "smarty_files/templates/images/10th_girls/10th_ann_Ashby.png,2,10";
					flashvars.image3 = "smarty_files/templates/images/10th_girls/10th_ann_Carrie.png,3,10";
					flashvars.image4 = "smarty_files/templates/images/10th_girls/10th_ann_Joelle.png,4,10";
					flashvars.image5 = "smarty_files/templates/images/10th_girls/10th_ann_Leora.png,4,10";
					flashvars.image6 = "smarty_files/templates/images/10th_girls/10th_ann_Liliana.png,4,10";
					flashvars.image7 = "smarty_files/templates/images/10th_girls/10th_ann_Lydia.png,4,10";
					flashvars.image8 = "smarty_files/templates/images/10th_girls/10th_ann_Shadi.png,4,10";
					flashvars.image9 = "smarty_files/templates/images/10th_girls/10th_ann_Shira.png,4,10";
					flashvars.image10 = "smarty_files/templates/images/10th_girls/10th_ann_Tyla.png,4,10";
				}
				
				if (jQuery.browser.msie && (jQuery.browser.version > 6.9999) && (jQuery.browser.version < 7.9999) ){
					$("#rotator-wrapper").css({"left" : "-400px" , "top" : "-50px"});
				}
				
				//$("#rotator-wrapper").css({"left" : "-400px" , "top" : "-50px"});
				//$("#rotator-wrapper-ann").css({"left" : "-450px" , "top" : "-50px"});
				
				$("#rotator-wrapper").css("top" , "-50px");
				
				//$("#div-catalog-wheretobuy-"+ language ).css({"left" : "-50px", "top" : "-35px"});
				
				swfobject.embedSWF("smarty_files/templates/flash/ImageFader.swf", "div-home-rotator", "550", "876", "9.0.0","smarty_files/templates/flash/expressInstall.swf", flashvars, params, attributes);

				$("#a-flash-desc,#p-flash-desc").css({"display":"block"});
		
	}
	else {
		
			$("#div-home-rotator").html(htmlString);
			$("#div-home-rotator").cycle({
					fx: 'fade',
					speed: 'slow',
					timeout: 5000 });
		}

	
}

function wtbRandomizer(){
	
	if(country == "en-us"){

	  var arr = new Array();
	
		arr[0]=bratzHash.wtbLogos.toysrus;
		arr[1]=bratzHash.wtbLogos.amazon;
		arr[2]=bratzHash.wtbLogos.target;
		arr[3]=bratzHash.wtbLogos.walmart;
		arr[4]=bratzHash.wtbLogos.kmart;
		arr[5]=bratzHash.wtbLogos.tikes;
		
		$('#array').text(arr.join(', '));
			arr = $.shuffle(arr);

		$(".retail-1").html("<img src='smarty_files/templates/images/wtb_logos/" +arr[0] + ".png'/>").attr("id" , arr[0]);
		$(".retail-2").html("<img src='smarty_files/templates/images/wtb_logos/" +arr[1] + ".png'/>").attr("id" , arr[1]);
		$(".retail-3").html("<img src='smarty_files/templates/images/wtb_logos/" +arr[2] + ".png'/>").attr("id" , arr[2]);
		$(".retail-4").html("<img src='smarty_files/templates/images/wtb_logos/" +arr[3] + ".png'/>").attr("id" , arr[3]);
		$(".retail-5").html("<img src='smarty_files/templates/images/wtb_logos/" +arr[4] + ".png'/>").attr("id" , arr[4]);
		$(".retail-6").html("<img src='smarty_files/templates/images/wtb_logos/" +arr[5] + ".png'/>").attr("id" , arr[5]);
		
	}
}

function checkWtb(){
	if(country == "fr-fr" && page == "wheretobuy"){
		window.location = "?section=bratzhomepage";
		
	}
}


function bratzTimeline(){
	
		var htmlString = "<div><img src='smarty_files/templates/images/timeline/2001.jpg' /></div>";
		htmlString += "<div><img src='smarty_files/templates/images/timeline/2002.jpg' /></div>";
		htmlString += "<div><img src='smarty_files/templates/images/timeline/2003.jpg' /></div>";
		htmlString += "<div><img src='smarty_files/templates/images/timeline/2004.jpg' /></div>";
		htmlString += "<div><img src='smarty_files/templates/images/timeline/2005.jpg' /></div>";
		htmlString += "<div><img src='smarty_files/templates/images/timeline/2006.jpg' /></div>";
		htmlString += "<div><img src='smarty_files/templates/images/timeline/2007.jpg' /></div>";
		htmlString += "<div><img src='smarty_files/templates/images/timeline/2008.jpg' /></div>";
		htmlString += "<div><img src='smarty_files/templates/images/timeline/2009.jpg' /></div>";
		htmlString += "<div><img src='smarty_files/templates/images/timeline/2010.jpg' /></div>";

		$("#div-timeline-rotator").html(htmlString);
		$("#div-timeline-rotator").cycle({
				fx: 'fade',
				speed: 'slow',
				timeout: 5000 });

				//drop the code for the fading thing here.
}



function secretCode(){
	
	$("#enable-product-code").click( function(){
			setCookie( "secretcode", "1" );
			window.location = "";
	});

	$("#toplink-secret-code, .secretcode-promo, #glam-secretcode-en, #glam-secretcode-fr,#glam-secretcode-es").click(function(){
		

		if( obj.id || session_start == true){
			
			$("#input-secret-code").val("");
			$("#secretcode-basic").css("display","none");
			
			if( not_real_page == true){
				$("#secret-code-"+language).fadeIn('slow');
				$("#glam-secretcode-box").fadeIn('slow');
			}
			else{
				$("#glam-secretcode-box").fadeIn('slow');
			}

			//$("#secret-code-"+language, "#glam-secretcode-box").fadeIn('slow');
			
			$("#input-secret-code").keyup( function(){
				var secret_code = $("#input-secret-code").val();
				var s = true;
				if( this.value.length >= 6 ){
					$("#btn-submit").css("display" , "block");
				} else {
					$("#btn-submit").css("display" , "none");
				}
			});

			$("#secretcode-close").click(function(){
				$("#secret-code-"+language).fadeOut('slow');
			});
			
			$("#glam-secretcode-close").click(function(){
				$("#glam-secretcode-box").fadeOut('slow');
			});
	
		} else { 
			//setCookie("secretcode", "1");			
			setTimeout( function(){ $("#login, #glam-login").click(); } , 500 );

		}

	});

	$("#promo-left").click( function(){
		window.location =  "?section=bratzgames";

	 });
	
	if(getCookie("secretcode") != null && getCookie("secretcode") != "") {	
	 	setTimeout( function(){ $("#toplink-secret-code, .secretcode-promo").click();  } , 500 );
			setCookie("secretcode", null);
			deleteCookie("secretcode");
	 }


	$(".btn-secretcode").click( function(){
		var girl = 0;
		var secret_code = $("#input-secret-code").val();
		/*$(".radio-secretcode").each( function( i , val ){ 
			if( $( this ).attr("checked") ){
				girl =  this.value;
			}
		});*/

		var secreturl = ( not_real_page == true ) ? "?request=secretcode" : base+"index.php?request=secretcode";

		user_id = ( not_real_page == true ) ? obj.id : glam_user_id; 


		 $.post(secreturl, { secret_code : secret_code , girl : girl , user_id : user_id , website_id : website_id }, function( http ){
         	var s_return = eval( http );
         	if( s_return > 0 ){
				
         		if( not_real_page == true ){
					alert(bratzHash.language.registration.addSecretCode); 
				}
				else{
					alert("Your Item has been added");
				}
	
				var geturl = ( not_real_page == true ) ? "?request=download&id=": base+"index.php?request=download&id=";
				$.get(geturl + s_return , { id : s_return } , function( geturl ){
					window.location = geturl;

				} );

			}
			else if( s_return == 0 ){
				alert("You have already registered this product.");
				var geturl = ( not_real_page == true ) ? "?request=download&id=": base+"index.php?request=download&id=";
				$.get(geturl + s_return , { id : s_return } , function( geturl ){

					window.location = geturl;
				} );
			}
			else if( s_return < 0 ){
				
				if( not_real_page == true ){
					alert(bratzHash.language.login.check_secretcode); 
				}
				else{
					alert("Please check your secret code and try again.");
				}
				
				
			}
		});
		
	 });
	
}

function checkBioPages(){
	if( $__( $( "#div-bio-box" ) ) ){
		
		if(page == "bratzgirlz" && country == "es-es"){
			$("#div-img-yasmin").css("left" , "-265px");
			$("#div-img-sasha").css("left" , "-269px");
			$("#div-img-jade").css("left" , "-280px");
		}
		
		$(".bio-box-menu").click(function(){
			
		})
		
		$(".div-bios-menu-common").click( function(){ 
			
				var stringcurrent = this.id.split("-");				
				currentGirl = stringcurrent[3];

				$(".div-bios-menu-common").each( function( val , i ) {
						$("#" + this.id ).removeClass( this.id + "-current");
						$( this ).addClass( this.id );
						
				 });
				
				$( this ).removeClass("div-bios-menu-yasmin").addClass( this.id + "-current");
				
				$(".all, .chat").css("display","none");
				$("#div-chat-" + currentGirl + "-" + language).css("display" , "block");
				$("#div-img-" + currentGirl ).css("display","block");
				$("#div-circle-" + currentGirl ).css("display"	,"block");
				
				
				//getDollsProfile( currentGirl );
				$("#div-bio-copy").html( bratzHash.girls[currentGirl].bio ); 
				$("#div-blog-copy").html(bratzHash.girls[currentGirl].blog);			
				$("#bio-header").html( bratzHash.girls[currentGirl].header ); 
				
				$("#bio-header-int").html( bratzHash.girls[currentGirl].header ); 
				$("#blog-header").html(bratzHash.girls[currentGirl].blogheader);
				$("#blog-header-int").html(bratzHash.girls[currentGirl].blogheader);
				
		});
		
			$("#div-chat-" + currentGirl + "-" + language).css("display" , "block");			
			$("#div-img-" + currentGirl ).css("display","block");				
			$("#div-circle-" + currentGirl ).css("display"	,"block");
			
			//getDollsProfile( currentGirl );
			$("#div-bio-copy").html( bratzHash.girls[currentGirl].bio );
			$("#div-blog-copy").html( bratzHash.girls[currentGirl].blog);
			$("#bio-header").html( bratzHash.girls[currentGirl].header );
			$("#bio-header-int").html( bratzHash.girls[currentGirl].header ); 
			$("#blog-header").html( bratzHash.girls[currentGirl].blogheader);
			$("#blog-header-int").html( bratzHash.girls[currentGirl].blogheader);
		
		$("#a-blog-header").click( function(){
			$("#div-bio-copy").css("display","none");
			$("#div-blog-copy").css("display","block");
		});
		
		$("#a-bio-header").click( function(){
			$("#div-blog-copy").css("display","none");
			$("#div-bio-copy").css("display","block");
		});
	}	
	
		$("#a-blog-header").click( function(){
			$("#div-bio-copy").css("display","none");
			$("#div-blog-copy").css("display","block");
		});
		
		$("#a-bio-header").click( function(){
			$("#div-blog-copy").css("display","none");
			$("#div-bio-copy").css("display","block");
		});
	
	$('#div-chat-copy').cycle({ 
	    fx:    'scrollUp',
	 	speed:  1000,
	    timeout: 15000
	});

}

function homePromos(){
	
	
	if(  $__( $( "#div-btm-promo" ) ) ){

		var promoleft = bratzHash.homepromos.promoleft;
		var sPromoLeft="";

		for (x in promoleft) {
			var img = "<img src='" + promoleft[x]["img"] + "' width=177 height=164 border=0/>";
			var link = "<a id='game-" + promoleft[x]["item"] + "' href='" + promoleft[x]["link"] + "'>" + img + "</a>\n";
			sPromoLeft += link;
		}
		
		var promoright = bratzHash.homepromos.promoright;
		var sPromoRight="";

		for (x in promoright) {
			var img = "<img src='" + promoright[x]["img"] + "' width=177 height=164 border=0/>";
			var link = "<a id='game-" + promoright[x]["item"] + "' href='" + promoright[x]["link"] + "'>" + img + "</a>\n";
			sPromoRight += link;
		}
		
		var promomiddle = bratzHash.homepromos.promomiddle;
		
		$("#promo-left").html(sPromoLeft);
		$("#promo-right").html(sPromoRight);
		$("#promo-left,#promo-right").cycle({ 
		    fx:     'fade', 
	    	speed:   300,	//'slow' 
		    timeout: 3000, 
			cleartype: true, 
			cleartypeNoBg: true
		});
		
		
		$(".promo-middle").html("<img src='" + promomiddle + "'/>");
		
	}
	
	$("#heart-close").click(function(){
		$("#heart-overlay").fadeOut('slow');
	});
}

function playVideo(){

	switch( location.hostname ) {
		case "localhost":
			var videoBase = "http://localhost/latest_bratz/smarty_files/templates/video/";
			break;
		case "webdevcentral.mgae.com":
			var videoBase = "http://webdevcentral.mgae.com/dev/latest_bratz/smarty_files/templates/video/";
			break;
		default:
			var videoBase = "http://www.bratz.com/smarty_files/templates/video/";
			break;
	}
	
	
	if( $__( $( "#div-video-content" ) ) ){
		var v = $("#bratz-videos :selected").val();
		var text = $( "#bratz-videos[value='" + v + "']").text();
		if(page == "video"){
			/*old dimension for video 320 x 240*/
			var params = { wmode : "transparent" };
			var attributes = { id : "flash-bool" };
			var flashvars = { videoURL : videoBase + country + "/" + v + ".f4v" , loop : 1 , skinColor : "0xB60050"};
			swfobject.embedSWF("smarty_files/templates/flash/build/MGAVideoPlayer.swf", "video-player", "430", "261", "9.0.0","expressInstall.swf", flashvars, params, attributes);
		}
		$("#watch-video").click(function(){	
			$("#webisode-video-wrapper").html("");
			$("#webisode-video-wrapper").html("<div id=\"video-player\"></div>");
			var v = $("#bratz-videos :selected").val();
			if (v == ""){
				alert(bratzHash.language.video.selectvideo);
			}
			else {
				var params = { wmode : "transparent" };
				var attributes = { id : "flash-bool" };
				var flashvars = { videoURL : videoBase + country + "/" + v + ".f4v" , loop : 1 , skinColor : "0xB60050"};
				swfobject.embedSWF("smarty_files/templates/flash/build/MGAVideoPlayer.swf", "video-player", "430", "261", "9.0.0","expressInstall.swf", flashvars, params, attributes);
			}
		});

		pageTracker._trackEvent('BratzVideo', v);

	}
}

function accessVib(){
	//alert(getCookie("vib"));
	
	if(obj.id){
		if ( getCookie("vib") == "1" ) {
			window.location="?section=bratzvib";
			setCookie("vib", null);	
			deleteCookie("vib");	
		}
	}
	
	$("#menu-vib-"+country).click(function(){
		if( obj.id ){
			window.location =  "?section=bratzvib";
		}
		else{
			setCookie("vib", "1");
			$("#login").click();  
		}
		
	});
	
	if(page == "bratzvib"){
		if(obj.id){

			setCookie("vib", null);
			deleteCookie("vib");
			
			//do nothing, let them in
			
			setTimeout( function(){ $("#video-underlay").fadeOut('slow');  } , 5000);
			
			setTimeout( function(){ 
			var params = { wmode : "transparent" };
			var attributes = { id : "flash-bool" };
			var flashvars = { videoURL : "http://c1886602.r2.cf0.rackcdn.com/4_makingbratz3.f4v" , loop : 1 , skinColor : "0xB60050" };
			swfobject.embedSWF("smarty_files/templates/flash/build/MGAVideoPlayer.swf", "teaser-video", "480", "240", "9.0.0","expressInstall.swf", flashvars, params, attributes);
			}, 5000);
		}
		else{
			setCookie("vib", "1");
			window.location = "?section=bratzhomepage";
		}
	}
	
	if(page == "bratzhomepage"){
		
		if ( getCookie("vib") == "1") {
			$("#overlay-wrapper").css({ "display" : "block" }).animate({ "opacity" : ".76" ,  "height" : "1135px"} , 1500 , function(){
				$("#logon-wrapper").css({ "display" : "block" , "opacity" : "1" });
			});
			setCookie("vib",null);
			deleteCookie("vib");
			
		}
	}
}

function checkFlashContent(){
	
	if(  $__( $( "#home-overlay-wrapper" ) ) ){
		
		var params = { wmode : "transparent" };
		var attributes = { id : "flash-bool" };
		var flashvars = { videoURL : "http://c1886602.cdn.cloudfiles.rackspacecloud.com/BRPAD0013H_Party_v2.f4v" , loop : 1  };
		swfobject.embedSWF("smarty_files/templates/flash/build/MGAVideoPlayer.swf", "home-overlay-video", "850", "580", "9.0.0","expressInstall.swf", flashvars, params, attributes);
		
		
	$("#home_video_close").click( function(){
		$("#home-overlay-wrapper").css("display" , "none");
		
		$("#video-wrapper, #home-overlay-wrapper, #flash-bool").html("");
	});
		
	}
	
	if(country!="en-us"){
		$("#div-btm-promo").css("top" , "-186px");
	}
	
	var params = { wmode : "transparent" };
	 var attributes = { wmode : "transparent" };

	 var flashvars = { };

	 swfobject.embedSWF("smarty_files/templates/flash/home_promo.swf", "div-home-promo", "630", "520", "9.0.0","expressInstall.swf", flashvars, params, attributes);  	

		setTimeout( function(){
			$("#div-btm-promo").fadeIn('slow');
		} , 2000 );

}

function activeMenu(){
	if(page == "moxiehomepage")
	{
		$("#div-menu-home").css({"background-position" : "439px 125px", "top" : "39px"});
		
		$("#div-menu-bios, #div-menu-games, #div-menu-catalog").mouseover(function() {
		$("#div-menu-home").css({"background-position" : "439px 250px", "top" : "29px"});
		});
		
		$("#div-menu-bios, #div-menu-games, #div-menu-catalog").mouseout(function() {
		$("#div-menu-home").css({"background-position" : "439px 125px", "top" : "39px"});
		});
		
	}
	
	else if(page == "bratzgirlz")
	{
		$("#div-menu-bios").css({"background-position" : "359px 125px", "top" : "39px"});

		$("#div-menu-home, #div-menu-games, #div-menu-catalog").mouseover(function() {
		$("#div-menu-bios").css({"background-position" : "359px 250px", "top" : "29px"});
		});

		$("#div-menu-home, #div-menu-games, #div-menu-catalog").mouseout(function() {
		$("#div-menu-bios").css({"background-position" : "359px 125px", "top" : "39px"});
		});
	}
	
	else if(page == "bratzgames")
	{
		$("#div-menu-games").css({"background-position" : "234px 125px", "top" : "39px"});

		$("#div-menu-home, #div-menu-bios, #div-menu-catalog").mouseover(function() {
		$("#div-menu-games").css({"background-position" : "234px 250px", "top" : "29px"});
		});

		$("#div-menu-home, #div-menu-bios, #div-menu-catalog").mouseout(function() {
		$("#div-menu-games").css({"background-position" : "234px 125px", "top" : "39px"});
		});
	}
	
	else if(page == "bratzcatalog")
	{

		$("#div-menu-home, #div-menu-bios, #div-menu-games").mouseover(function() {
		$("#div-menu-catalog").css({"background-position" : "144px 250px", "top" : "29px"});
		});

		$("#div-menu-home, #div-menu-bios, #div-menu-games").mouseout(function() {
		$("#div-menu-catalog").css({"background-position" : "144px 125px", "top" : "39px"});
		});
	}
}
/* Google Analytics */

function loginRegEvent(){
	
	if(  $__( $( "#register" ) ) ){
		var google_conversion_label = "tA8bCMLs4AEQgIyC7wM";
			$("#google_conversion").html("<img src='http://www.googleadservices.com/pagead/conversion/1038124544/?label=tA8bCMLs4AEQgIyC7wM&amp;guid=ON&amp;script=0' border='0' />");
	}
	
	if( $__( $( "#login-register-box" ) ) || $__( $( "#div-glam-secretcode" ) )  )
	{
		$("#register").click( function(){ 
			if( getCookie("coppaCookie") ){
                                $("#overlay-wrapper").css({ "display" : "block" }).animate({ "opacity" : ".76" ,  "height" : "1135px"} , 1500 , function(){
                                        $("#dialog-date").val(bratzHash.language.registration.reg_yyyymmdd);
                                        $("#overlay-box").css({ "display" : "block" , "opacity" : "1" });
                                        $("#overlay-dialog").css({ "display" : "block" , "opacity" : "1" });
						regValidateObj.json_send.acct_type = getCookie("acct_type");
						regValidateObj.hideElem();	
						regValidateObj.expandBuilt();
                                 } );

			}
			else{
				$("#overlay-wrapper").css({ "display" : "block" }).animate({ "opacity" : ".76" ,  "height" : "1135px"} , 1500 , function(){
					$("#dialog-date").val(bratzHash.language.registration.reg_yyyymmdd);
					$("#overlay-box").css({ "display" : "block" , "opacity" : "1" });
					$("#overlay-dialog").css({ "display" : "block" , "opacity" : "1" });
					regValidateObj.checkDate();
				 } );
			}
		} );

			$("#a-logon-register").click( function(){
					if(not_real_page == true){
						$("#register").click();	
					} 
					else{
						$("#overlay-wrapper").css({ "display" : "block" }).animate({ "opacity" : ".76" ,  "height" : "1135px"} , 1500 , function(){
						$("#dialog-date").val("yyyymmdd");
						$("#overlay-box").css({ "display" : "block" , "opacity" : "1" });
						$("#overlay-dialog").css({ "display" : "block" , "opacity" : "1" });
						regValidateObj.checkDate();
						});
					}
					$("#logon-dialog").css("display","none");
			});
		
		$("#login, #glam-login").click( function(){	
			$("#overlay-wrapper").css({ "display" : "block" }).animate({ "opacity" : ".76" ,  "height" : "1135px"} , 1500 , function(){
				
				$("#logon-wrapper,#overlay-login").css({ "display" : "block" , "opacity" : "1" });
				$("#forgot-wrapper").css("display","none");
				$("#logon-dialog").css("display","block");
				
				/*old
				$("#a-logon-forgot").click( function(){
					$("#logon-wrapper").css("display","none");
						$("#forgot-wrapper").fadeIn('slow');
						$("#div-forgot").css("height","252px");

				});
				*/
				
				$("#a-logon-forgot").click( function(){
					setTimeout( function(){
						$("#logon-wrapper").css({ "display" : "none" ,  "opacity" : "0"  });
						$("#forgot-wrapper").css({ "opacity" : "1" , "display" : "block" });
						$("#div-forgot").css({ "display" : "block" , "opacity" : "1" });						
					} , 500 );	
				});
		
			 });

		});
		
		$("#myacct-userid, #myacct-password").keypress( function(event) {
				if (event.keyCode == '13') {$("#btn-logon").click();}
		});
		
		$("#btn-logon").click( function() {

			var url = ( not_real_page == true ) ? "?request=login" : base+"index.php?request=login";

				$.post( url , { username: jQuery.trim( $("#myacct-userid").val() ) , website_id : website_id , password: jQuery.trim( $("#myacct-password").val() ) } , function(http){ 
					var stringBool = eval( "(" + http + ")" );
					if( stringBool == "3" ){
							if(not_real_page == true){
								alert(bratzHash.language.errors.errorcode1); 
							}
							else{
								alert("Please check your username and password and try again.");
							}
					}
					else if( stringBool == "2" ){
						alert("You do not have access to this account. Please check with your parent for approval."); 
					}
					else if( stringBool == "0" ){ 
						
						if( getCookie("vib") == "1" ) {	
							window.location = "?section=vib";
						} else {
							window.location = " ";
						}
					 }
				});

		 });


		$("#logout").click( function(){ 
			
				$.post("?request=logout",function( ){
					
					if(page == "bratzvib"){
						window.location = "?section=bratzhomepage";
					}
					else{
					window.location = "";
					}
				});
		} );
	}
	
	if( $__( $("#dialog-close") ) ){
		$("#dialog-close, #login-li-dialog-close , #logon-header-close , #forgot-password-close, #update-cancel").click(function(){
			$("#overlay-box,#overlay-login").css({ "display" : "none" , "opacity" : "0" });
			$("#overlay-wrapper").animate({ "opacity" : "0" , "height" : "0px" } , 1500 , function(){ $( this ).css("display" , "none"); } );

			$("#dialog-content-2").css({ "display" : "none" });
			$("#dialog-content").css({ "display" : "block" });
			$("#dialog-title").html(bratzHash.language.registration.reg_step1); 
			$("#overlay-dialog").css({ "width" : "385px" , "height" : "230px" });	
			if( not_real_page == true ){
				$("#reg-save").attr("id","btn-next").html(bratzHash.language.registration.reg_next);  
			}
			else{
				$("#reg-save").attr("id","btn-next").html("Next");
			}
			
			

		});
		
		$("#logon-header-close").click( function() {
			//This is for #logon-header-close
			setTimeout( function() {
				setCookie("vib",null);
				deleteCookie("vib");
				setCookie("secretcode",null);
				deleteCookie("secretcode");
			},1000);
		});
	}
	if( $__( $("#forgot-submit") ) ){
		$("#forgot-submit").click(function(){ 
			var first_name = $("#input-forgot-firstname").val();
			var input_value = $("#input-forgot-email").val();
			var radio_type = null;
			    $(".radio-forgot-password").each( function( i , val ){ if( $( this ).attr("checked") ){ radio_type = this.value; } });
			    $.post("?request=forgotpasswordbyusername", { first_name : first_name , input_value : input_value, radio_type : radio_type } , function( http ){
				
					if( http == 0 ){
						alert(bratzHash.language.login.forgot_cantfind);
					}
					else if( http == 1 ){
						alert(bratzHash.language.login.forgot_sendtoparent);
						$("#forgot-wrapper, #overlay-wrapper").css("display" , "none");
					}
					else if( http == 2 ){
						alert(bratzHash.language.login.forgot_sendtoemail);
						$("#forgot-wrapper, #overlay-wrapper").css("display" , "none");
					}
					
			    });

		});
	}
}

function buildAllChildAccess(){
	$("#div-mychildren").html("");
	$.post("?request=mychildaccess" , { parent_email_id : obj.parent_email_id } , function( http ){ 
			if( http != "false" ){
			var json_arr = eval("(" + http + ")");
			for( x in json_arr ){
				childLoop( json_arr[x] );
			}
			}
			else{
				$("#div-mychildren").html(bratzHash.language.myacct.myacct_childnotregistered);
			}

	});
} 

function buildAllActivities(){
	var stringHtml = "";
	$.post("?request=mykidactivities" , { parent_email_id : obj.parent_email_id } , function( http ){
			var json_arr = eval("(" + http + ")");
			for( x in json_arr ){
				if( json_arr[x]["userInfo"] ){
					stringHtml += "<ul id=\"ul-activities-name\">"
					stringHtml += "<li class=\"li-activities\" ><span>" + bratzHash.language.myacct.myacct_name + "</span><input type=\"text\" id=\"activities-name\" value=\""+ json_arr[x]["userInfo"]["first_name"]  +"\"></li>";
					stringHtml += "<li class=\"li-activities\"><span>" + bratzHash.language.myacct.myacct_productregistered + "</span><input class=\"input-activities\" value=\"" + kidsLoop( json_arr[x] , x ) + "\"></li>";
					stringHtml +="</ul>";
				}
			}
		$("#div-activities").html( stringHtml );
	 });
}

function kidsLoop( obj_arr , i  ){
	var stringProducts = "";
	for( x in obj_arr ){
		if( obj_arr[x]["product_name"] ){
			stringProducts += obj_arr[x]["product_name"];
			if( obj_arr.length - 1 != x  ){
				stringProducts += ", ";
			} 
		}
	}
	return stringProducts = stringProducts.substr( 0 , stringProducts.length - 2 );
}

function childLoop( obj_arr ){
        var ulInfoString = "";
        var finalString = "";

        for( x in obj_arr ){
                if( !obj_arr[x]["user_access_id"] ){
                        /*upper part*/
                        ulInfoString += "<ul id=\"ul-mychildren-info\"><li class=\"li-children\"><div><span>" + bratzHash.language.myacct.myacct_activitiesname + "</span><input type=\"text\" class=\"input user_id"+obj_arr[x]["user_id"] +"\" id=\"mychildren-id\" value=\""+ obj_arr[x]["first_name"] +"\" name=\"first_name\"></div></li>";
                        ulInfoString += "<li class=\"li-children\"><div><span>ID:</span><input type=\"text\" class=\"input\" id=\"mychildren-id\" value=\""+ obj_arr[x]["user_id"] +"\" disabled></div></li>";
                        ulInfoString += "<li class=\"li-children\"><div><span>" + bratzHash.language.myacct.myacct_password + "</span><input type=\"text\" class=\"input user_id"+ obj_arr[x]["user_id"] +"\" id=\"mychildren-password\" name=\"password\" /></div></li>";
                        if( obj_arr[x]["email"] ){
                        ulInfoString += "<li class=\"li-children\"><div><span>" + bratzHash.language.myacct.myacct_email + "</span><input type=\"text\" class=\"input user_id"+ obj_arr[x]["user_id"] +"\" id=\"mychildren-email\" value=\"" + obj_arr[x]["email"] + "\" name=\"email\" /></div></li></ul>";
                        }
                }

        }
        var global_id = null;
        var string1 = "<ul id=\"ul-mychildren-info\" class=\"clear\">";
        string1 += "<p id=\"p-mychildren\" class=\"clear\">" + bratzHash.language.myacct.myacct_checkaccess + "</p>";
        for( x in obj_arr ){
                if( obj_arr[x]["user_access_id"] ){
                        global_id = obj_arr[x]["user_id"];
                        string1 += continueLoop( obj_arr[x] );
                }
        }
        string1 += "<li class=\"li-button-save\"><button id=\""+ global_id +"\" onclick=\"mychildsave( this )\">" + bratzHash.language.myacct.myacct_btnsave +"</button><button>" + bratzHash.language.myacct.myacct_btncancel + "</button></li>";
        string1 += "</ul>";
        finalString += ulInfoString;
        finalString += string1;
        $("#div-mychildren").html( $("#div-mychildren").html() + finalString );

}

function continueLoop( arr ){
                var strInfoString = "";
                return strInfoString += "<li class=\"li-children\"><span>"+ arr["website_domain"]  +":</span><input type=\"checkbox\" "+ checkedState( arr )+" class=\"user_id"+ arr["user_id"] +"\" name=\""+ arr["user_access_id"]+"\" /></li>";
}

function checkedState(arr){
        if( arr["access_bool"] == "1" ){
                return "checked=\"checked\"";
        }
}


function mychildsave( obj ){
      var json_send = {};
      $(".user_id" + obj.id ).each(function( i , val ){
                 if( $(this).is('input:checkbox') ){
                                json_send[ "website_" + $( this ).attr("name") ] = $( this ).attr("name") + "," + checkboxstatus( $( this ).attr("checked") );
                }
                 else{
                        if( $( this ).val()  != "" ){
                                 json_send[ $( this ).attr("name") ] = $( this ).attr("name") + "," + $( this ).val();
                       }
                 }
         });
 
        json_send.user_id = "user_id," + obj.id;

         $.post("?request=childrenupdate" , json_send , function(){

          } );
 }


function checkboxstatus( val ){
         if( val == "true" || val == true ){
                 return "1";
         }
         else{
                 return "0";
         }
}

function buildAllProducts(){
	var json_arr;

	var website_obj = { "1" : ["nara_icon_logo_v2.png", "160px"] , "3" : ["bratz_icon_logo_v2.png","110px"] , "4" : ["moxieteenz_icon_logo_v2.png", "110px"] }

	$.post("?request=myproducts" , { id : obj.id } , function( http ){ 
			if( http ){
			json_arr = eval("(" + http + ")");	
			var sku = "";
			for( x in json_arr ){
				if( json_arr[x]["website_id"] == website_id ){
					if( json_arr[x]["sku"] != "undefined" || json_arr[x]["sku"] != undefined ){
						sku += "<li class=\"li-products\" >";
						sku += "<img class=\"div-product-image\" src=\"http://c2154692.cdn.cloudfiles.rackspacecloud.com/" + jQuery.trim(json_arr[x]["product_key"]) + ".png\" />";
						sku += "<span>" + json_arr[x]["product_name"]  + "</span>";
						sku += "</li>";
					}

				}
			}

		$("#ul-products").html( sku );

		$("#product-website").css( { "width" : website_obj[website_id][1] , "background-image" : "url(http://c2154692.cdn.cloudfiles.rackspacecloud.com/"+ website_obj[ website_id ][0]  +")" } );
			}
			else{
				$("#ul-products").html( bratzHash.language.myacct.myacct_notregistered );
			}
	});

	$("#sort-by-website").change( function(){
		var sku = "";
		for( x in json_arr ){
                                if( json_arr[x]["website_id"] == this.value ){
                                        if( json_arr[x]["sku"] != "undefined" || json_arr[x]["sku"] != undefined ){
						sku += "<li class=\"li-products\" >";
                                                sku += "<img class=\"div-product-image\" src=\"http://c2154692.cdn.cloudfiles.rackspacecloud.com/" + json_arr[x]["product_key"] + ".png\" />";
                                                sku += "<span>" + json_arr[x]["product_name"]  + "</span>";
                                                sku += "</li>";

                                        }

                                }
               }
		$("#ul-products").html( sku );
		$("#product-website").css( { "width" : website_obj[this.value][1] , "background-image" : "url(http://c2154692.cdn.cloudfiles.rackspacecloud.com/"+ website_obj[this.value][0]  +")" } );
	});
}

function getAllupdateElems(){
	var obj_ = { };
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;

	if( $("#first_name").val().length >= 2 ){
		obj_.first_name = "first_name," + $("#first_name").val();
		$("#first_name").css("border","1px solid #AFAFAF");	
	}
	else{
		$("#first_name").css("border","1px solid red");	
	}

	if( $("#last_name").val().length >= 2 ){
		obj_.last_name = "last_name," + $("#last_name").val();
		$("#last_name").css("border","1px solid #AFAFAF");	
	}
	else{
		$("#last_name").css("border","1px solid red");	
	}

	if( $("#password").val() != "" || $("#password").val() != "******" ){
		if( $("#password-confirm").val() != $("#password").val() ){
			$("#password-match").html(bratzHash.language.myacct.myacct_error1);
		}
		else{
			$("#password-match").html("");
			obj_.password = "password," + $("#password").val();
		}
	}

	if( filter.test( $("#email").val() ) ){
		obj_.email = "email," + $("#email").val();
	 }

	if( $("#myacct-postal_code").val().length > 4 ){
		obj_.postal_code = "postal_code," + $("#myacct-postal_code").val();
		$("#myacct-postal_code").css("border","1px solid #AFAFAF");	
	}
	else{
		$("#myacct-postal_code").css("border","1px solid red");	
	}


	obj_.country_id = "country_id," + $("#choose-country option:selected").attr("id");
	obj_.state_id = "state_id," + $("#choose-state option:selected").attr("id");
	obj_.gender = ( $("#input-f").attr("checked") )? "gender,f" : "gender,m";
	obj_.user_id = "user_id," + obj.id ;

	$.post("?request=regupdate" , obj_ , function( http ){ });


}

function buildCountry(){
	var obj = bratzHash.countryList;
	var stringCountry = "";
	for( x in obj ){
		stringCountry += "<option id=\""+ obj[x]["country_id"] +"\" " + selectCountry( obj[x]["country_id"] ) + ">"+ obj[x]["local_name"] + "</option>";
	}
	$("#choose-country").html( stringCountry ).change( function(){
			getBuildState( this.options[ this.selectedIndex ].id );
	 });	
}

function selectCountry( current_id ){
	if( current_id == obj.country_id ){
		return "selected=\"selected\"";
	}
}

function getBuildState( id ){
	var state = bratzHash.stateList[ id ];
	var stringState = "";
	for( x in state ){
		stringState += "<option id=\""+ state[x]["state_id"] +"\">" + state[x]["local_name"] + "</option>";
	}
	$("#choose-state").html( stringState );	
}

function getBuildState2( id ){
	var state = bratzHash.stateList[ id ];
	var stringState = "<option id=\"0\">" + bratzHash.language.registration.selectone + "</option>";
	for( x in state ){
		stringState += "<option value=\""+ state[x]["state_id"] +"\">" + state[x]["local_name"] + "</option>";
	}
	$("#reg-signup-state").html( stringState );	
}

function buildState(){
	var state = bratzHash.stateList[ obj.country_id ];
	var stringState = "";
	for( x in state ){
		stringState += "<option id=\""+ state[x]["state_id"] +"\" "+ selectState( state[x]["state_id"] ) +" >" + state[x]["local_name"] + "</option>";
	}
	$("#choose-state").html( stringState );	
}

function selectState( current_id ){
	if( current_id == obj.state_id ){
		return "selected=\"selected\"";
	}
	else{
		return "";
	}
}

function loginTabs() {

	if(obj.id){
			var toplinks = parseInt( (obj.username.length * 19) + 3 ) + "px";
			$("#div-top-links").css("width", toplinks);
	}
	
}

function GetUnity() {
	if (typeof unityObject != "undefined") {
		return unityObject.getObjectById("unityPlayer");
	}
	return null;
}

function logValidation(){
	if(obj.id){
			
			$("#myaccount").click( function(){
					$("#password").val("******");
					$("#password-confirm").val("");
					$("#overlay-wrapper").css({ "display" : "block" }).animate({ "opacity" : ".76" ,  "height" : "1135px"} , 1500 , function(){
						$("#logon-wrapper").css({"display" : "none"});
						$("#overlay-login,#login-dialog-wrapper,#div-myacct,#div-profile-wrapper,#login-ul-dialog-header,#myacct-header-text,#div-all-info").css({"display" : "block","opacity" : "1"});
						$("#login-dialog-wrapper").css({"display" : "none"}).animate({ "opacity" : "1" , "height" : "408px" , "width" : "628px"} , 500 , function(){


							if( obj.acct_type == "parent" ){
								$("#myacct-header-text").html(bratzHash.language.myacct.myacct_parentconsole);
								$(".li-parent-email").css("display","none");
								$("#first_name").val(obj.first_name);
								$("#last_name").val(obj.last_name);
								$("#username").val(obj.username);
								$("#input-" + obj.gender ).attr("checked","checked");
								$("#email-account").val( obj.email );
								buildCountry();
								buildState();
								$("#myacct-postal_code").val( obj.postal_code );
							}
							
							else if( obj.acct_type == "child" ){
								$("#div-myacct-location,.li-child-email").css("display","none");
								$("#myacct-header-text").html(bratzHash.language.toplinks.myaccount);
								$(".li-parent-email").css("display","block");
								$("#first_name").val(obj.first_name);
								$("#last_name").val(obj.last_name);
								$("#username").val(obj.username);
								$("#parent-email-account").val(obj.parent_email);

								$("#input-" + obj.gender ).attr("checked","checked");
								$("#menu-mychildren, #menu-myactivities").css("display","none");

							}
							else if( obj.acct_type == "teen" ){
									$("#myacct-header-text").html(bratzHash.language.myacct.myacct_teenconsole);
									$(".li-parent-email").css("display","block");
									$("#first_name").val(obj.first_name);
									$("#last_name").val(obj.last_name);
									$("#username").val(obj.username);
									$("#input-" + obj.gender ).attr("checked","checked");
									$("#email").val( obj.email );
									buildCountry();
									buildState();
									$("#myacct-postal_code").val( obj.postal_code );

									$("#email-account").val(obj.email);
									$("#parent-email-account").val(obj.parent_email);
									$("#menu-mychildren").css("display" , "none");
							}
							else{
								$("#myacct-header-text").html(bratzHash.language.toplinks.myaccount);
							}

				$(".disabled").attr("readonly",true);

                                $(".menu-events").click(function(){
                                        $(".wrapper,.li-password-confirm").css("display" , "none");
                                        $("#div-"+this.id+"-wrapper,#div-myacct-menu").css({"display":"block","opacity":"1" , "filter":"alpha( opacity = 100 )"});

                                        $(".disabled").attr("readonly",false);

                                        ( this.id == "profile")? buildProfileSection() : $("#menu-edit,#div-all-info").css("display","none");
                                        ( this.id == "products")? buildAllProducts() : null;
                                        ( this.id == "children")? buildAllChildAccess() : null;
                                        ( this.id == "activities")? buildAllActivities() : null;

										  $("#menu-myprofile").removeClass('menu-active');
	                                      $("#menu-myproducts").removeClass('menu-active');
	                                      $("#menu-myscores").removeClass('menu-active');
	                                      $("#menu-mychildren").removeClass('menu-active');
	                                      $("#menu-myactivities").removeClass('menu-active');
	                                      $("#menu-wishlist").removeClass('menu-active');
											
                                       if(!$("#menu-my"+this.id).hasClass('menu-active')){
											$("#menu-my"+this.id).removeClass('menu-active');
											$("#menu-my"+this.id).addClass('menu-active');
										}
                                });

                                $("#menu-enable-edit").click(function(){
                                        $(".disabled").attr("readonly", false);
                                        $("#username,#email-account,#parent-email-account").attr("readonly", true);
										$(".li-password-confirm").css("display","block");
										passwordListener();
                                 });

                                $("#update-save").click( function(){
                                        getAllupdateElems();
                                });




							
						});

					});	
				} );
	
}

	else{
			$("#login").click( function(){
				$("#overlay-wrapper").css({ "display" : "block" }).animate({ "opacity" : ".76" ,  "height" : "1135px"} , 1500 , function(){
					$("#logon-wrapper").css({ "display" : "block" , "opacity" : "1" });
				});		
			} );
		}
	
}

function buildProfileSection(){
$("#menu-edit,#div-all-info").css("display","block");
$(".disabled").attr("readonly",true);
}

function passwordListener(){
	$("#password").click( function(){ 
		if( this.value == "******" ){
			this.value = "";
		}
	}).blur( function(){ 
		if( this.value == "" ){
			this.value = "******";
		}
	});
}

var countryReady = false;

var regValidateObj = { 
	json_send : { } ,
	badwords : null ,

	checkDate : function(){
		$("#btn-next").click( function(){ 
				
			if( not_real_page == true ){
				var dateVal = bratzHash.language.registration.reg_yyyymmdd;
			}
			else{
				var dateVal = "yyyy-mm-dd";
			}
			if($("#dialog-date").val() != dateVal){
					if( regValidateObj.badwords != null ){
					regValidateObj.getAccount_type( $("#dialog-date").val());
					regValidateObj.hideElem();
					regValidateObj.expandBuilt();
					}
					else{
					
					var loadbadwordsurl = ( not_real_page == true ) ? "?request=loadbadwords" : base+"index.php?request=loadbadwords";
					
					$.post(loadbadwordsurl,{},function( http ){ regValidateObj.badwords = eval( "(" + http + ")" ); });
					regValidateObj.getAccount_type($("#dialog-date").val());
					regValidateObj.hideElem();
					regValidateObj.expandBuilt();
					}
				}
				
				else{
					alert(bratzHash.language.errors.errorcode2);
				}
		});

        }
	, 
	cookieMachine : function( dob , type ){
		var d = new Date();
		d.setTime(d.getTime()+(60*60*400));
		var expire = "; expires="+d.toGMTString();
		document.cookie = "coppaCookie=true;"+expire+"; path=/";
		document.cookie = "dob="+ dob +";"+expire+"; path=/";
		document.cookie = "acct_type="+ type +";"+expire+"; path=/";
	}
	,
	getAccount_type: function( dob ){
	 var expl =  dob.split("-");	
	 var today = new Date(), // today date object
          birthday = new Date( expl[0] , (expl[1] - 1) , (expl[2] - 1) ), // birthday date object
          todayYear = today.getFullYear(), // today year
          todayMonth = today.getMonth(), // today month
          todayDay = today.getDate(), // today day of month
          birthdayYear = birthday.getFullYear(), // birthday year
          birthdayMonth = birthday.getMonth(), // birthday month
          birthdayDay = birthday.getDate(), // birthday day of month
         // calculate age
         	age = (todayMonth == birthdayMonth && todayDay > birthdayDay) ? 
               	     todayYear - birthdayYear : (todayMonth > birthdayMonth) ? 
                     todayYear - birthdayYear : todayYear - birthdayYear-1;

		if( age > 17 ){
			regValidateObj.json_send.acct_type = "parent";
		}
		else if( age <= 17 && age > 12 ){
			regValidateObj.json_send.acct_type = "teen";
		 }
		else{
			regValidateObj.json_send.acct_type = "child";
			regValidateObj.cookieMachine( dob , "child" );
		}

	}
	,
	hideElem : function(){ 
			if( regValidateObj.json_send.acct_type == "child" ){
				$("#user-optins,#user-location-signup,.li-child-email").css("display","none");
				$(".li-parent-email").css("display","block");
			}
			else if( regValidateObj.json_send.acct_type == "parent" ){
				$("#user-optins,#user-location-signup,.li-child-email").css("display","block");
                                $(".li-parent-email").css("display","none");
				if( countryReady == false ){
					regValidateObj.countrybuild();
				}
				countryReady = true;
			}
			else{ 
			        $("#user-optins,#user-location-signup,.li-child-email").css("display","block");
				if( countryReady == false ){
                                	regValidateObj.countrybuild();
				}
                                countryReady = true;
			}
	}
	,
	expandBuilt : function(){
		$("#dialog-content , #btn-next").css("display" , "none");
			$("#overlay-dialog").animate({ "width" : "705px" , "height" : "335px" } , 2000 , function(){
				$("#dialog-content-2").css({"display" : "block" , "height" : "250px" });
				
				if( not_real_page == true ){
					$("#btn-next").css("display" , "block").attr("id","reg-save").html(bratzHash.language.registration.reg_next);
				}
				else{
					$("#btn-next").css("display" , "block").attr("id","reg-save").html("Next");
				}
				
				$("#dialog-title").html(bratzHash.language.registration.reg_step2);
				regValidateObj.allElems();
		} );
        }
	,
	allElems : function(){
		$("#reg-save").click( function( evt ){
				evt.stopImmediatePropagation();

				if( regValidateObj.json_send.acct_type == "parent" ){
					regValidateObj.parentAcct();
				}
				else if( regValidateObj.json_send.acct_type == "teen" ){
					regValidateObj.teenAcct();
				}
				else{
					regValidateObj.childAcct();
				}

		})
	}
	,
	countrybuild : function(){ 
	var obj = bratzHash.countryList;
        var stringCountry = "<option id=\"0\">" + bratzHash.language.registration.selectone + "</option>";
        for( x in obj ){
                stringCountry += "<option id=\""+ obj[x]["country_id"] +"\" value=\""+ obj[x]["country_id"] +"\" >"+ obj[x]["local_name"] + "</option>";
        }

        $("#reg-signup-country").html( stringCountry ).change( function(){
                        getBuildState2( this.options[ this.selectedIndex ].id );
         });

	}
	,
	elem : function( obj ){

	} 
	,
	parentAcct : function(){
		var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
		var alpha = /^([a-zA-Z])+$/;
		var arr = new Array();
		var json_send = {};

		if( $("#reg-signup-first_name").val() == "" || alpha.test( $("#reg-signup-first_name").val() ) == false ){
			$("#reg-signup-first_name").css("border","1px solid red");	
			arr[0] = false;
		}

		else{
			$("#reg-signup-first_name").css("border","1px solid #CFCFCF");	
			json_send.first_name = "first_name," +  $("#reg-signup-first_name").val(); 
		}

		if( $("#reg-signup-username") ){
			var arr_bad = regValidateObj.badwords;
			if( $("#reg-signup-username").val() == "" ){
					$("#reg-signup-username").css("border","1px solid red");	
					arr[1] = false;
			}
			else {

			for( x in arr_bad ){
				if( arr_bad[x]  == $("#reg-signup-username").val() ){ 
					$("#reg-signup-username").css("border","1px solid red");	
					arr[1] = false;
					break;
				}		
				else{
					$("#reg-signup-username").css("border","1px solid #CFCFCF");	
				}
			} 

			( arr[1] == false ) ? null : json_send.username = "username," + $("#reg-signup-username").val();

			}
		}

		if( $("#reg-signup-password").val() == "" ){
			$("#reg-signup-password").css("border","1px solid red");	
			arr[2] = false;
		}
		else{
			$("#reg-signup-password").css("border","1px solid #CFCFCF");	
			json_send.password = "password," +  $("#reg-signup-password").val(); 
		}

		if( filter.test( $("#reg-signup-email").val() ) ){
			$("#reg-signup-email").css("border","1px solid #CFCFCF");	
			json_send.email = "email," +  $("#reg-signup-email").val(); 
		}
		else{
			$("#reg-signup-email").css("border","1px solid red");	
			arr[3] = false;
		}

		if( $("#reg-signup-country").val() != bratzHash.language.registration.selectone){
			$("#reg-signup-country").css("border","1px solid #CFCFCF");	
			json_send.country = "country_id," +  $("#reg-signup-country").val(); 
		}
		else{
			$("#reg-signup-country").css("border","1px solid red");	
			arr[4] = false;
		}

		if( $("#reg-signup-state").val() != bratzHash.language.registration.selectone){
			$("#reg-signup-state").css("border","1px solid #CFCFCF");	
			json_send.state = "state_id," +  $("#reg-signup-state").val(); 
		}
		else{
			$("#reg-signup-state").css("border","1px solid red");	
			arr[5] = false;
		}

		if( $("#reg-signup-zip").val() != "" ){
			$("#reg-signup-zip").css("border","1px solid #CFCFCF");	
			json_send.zip = "postal_code," +  $("#reg-signup-zip").val(); 
		 }
		else{
			$("#reg-signup-zip").css("border","1px solid red");	
			arr[6] = false;
		 }

		if( $("#reg-signup-last_name").val() == "" || alpha.test( $("#reg-signup-last_name").val() ) == false ){
			$("#reg-signup-last_name").css("border","1px solid red");	
			arr[7] = false;
		}

		else{
			$("#reg-signup-last_name").css("border","1px solid #CFCFCF");	
			json_send.last_name = "last_name," +  $("#reg-signup-last_name").val(); 
		}

		if( $(".input-gender")  ){
			if( $("#reg-signup-f").attr("checked") ){
				json_send.gender = "gender,f";
			 }
			if( $("#reg-signup-m").attr("checked") == true ){
				json_send.gender = "gender,m";
			}
		}

		/*if( bratzvib ){
                        json_send.referred = "referred,1";
                }*/

		json_send.parent_email = "parent_email," + $("#reg-signup-email").val(); 
		json_send.acct_type = "acct_type,parent";
		json_send.option_1 = ( $("#option_1").attr("checked") == true )? "optins_1,brands,1" : "optins_1,brands,0";
		json_send.option_2 = ( $("#option_2").attr("checked") == true )? "optins_2,other_brands,1" : "optins_2,other_brands,0";
		json_send.option_3 = "optins_3,website_id,3";
		json_send.option_4 = "optins_4,email_my_child,1";
		json_send.dob = "dob," + $("#dialog-date").val(); 

		if( arr.length == 0 ){
			
			var registerurl = ( not_real_page == true ) ? "?request=register" : base+"index.php?request=register";
			
			$.post(registerurl, json_send , function( http ){
				if( http != "" ){
					var returnObj = eval( "(" + http  + ")" );
					if( returnObj["error"] ){
							//alert( returnObj["error"] );						
							alert(bratzHash.language.errors[ "errorcode" + returnObj["error"] ]);
					}
					else{ 
						setTimeout( function(){
						$("#overlay-dialog").css({ "background" : "none" , "border" : "none" });
						$("#dialog-header,#dialog-content-2,#dialog-bottom").css("display", "none");
						$("#dialog-content-2").css("display","none");
						$("#dialog-reg-complete").css({ "display" : "block","background-color" : "#D5B1D1" });
						
						$("#span-reg-complete-username").html(bratzHash.language.registration.reg_complete_username + $("#reg-signup-username").val() );
                        $("#span-reg-complete-password").html(bratzHash.language.registration.reg_complete_password + $("#reg-signup-password").val() );

						$("#complete-btn-close, #reg-complete-close").click( function(){
							window.location = "";
						 });
						} , 1000 );
					}
				}
			});
		}	

	}
	,
	teenAcct : function(){
		var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
		var alpha = /^([a-zA-Z])+$/;
		var arr = new Array();
		var json_send = {};

		if( $("#reg-signup-first_name").val() == "" || alpha.test( $("#reg-signup-first_name").val() ) == false ){
			$("#reg-signup-first_name").css("border","1px solid red");	
			arr[0] = false;
		}
		else{
			$("#reg-signup-first_name").css("border","1px solid #CFCFCF");	
			json_send.first_name = "first_name," +  $("#reg-signup-first_name").val(); 
		}

		if( $("#reg-signup-username") ){
			var arr_bad = regValidateObj.badwords;
			if( $("#reg-signup-username").val() == "" ){
					$("#reg-signup-username").css("border","1px solid red");	
					arr[1] = false;
			}
			else {

			for( x in arr_bad ){
				if( arr_bad[x]  == $("#reg-signup-username").val() ){ 
					$("#reg-signup-username").css("border","1px solid red");	
					arr[1] = false;
					break;
				}		
				else{
					$("#reg-signup-username").css("border","1px solid #CFCFCF");	
				}
			} 

			( arr[1] == false ) ? null : json_send.username = "username," + $("#reg-signup-username").val();

			}
		}

		if( $("#reg-signup-password").val() == "" ){
			$("#reg-signup-password").css("border","1px solid red");	
			arr[2] = false;
		}
		else{
			$("#reg-signup-password").css("border","1px solid #CFCFCF");	
			json_send.password = "password," +  $("#reg-signup-password").val(); 
		}

		if( filter.test( $("#reg-signup-parent_email").val() ) ){
			$("#reg-signup-parent_email").css("border","1px solid #CFCFCF");	
			json_send.parent_email = "parent_email," +  $("#reg-signup-parent_email").val(); 
		}
		else{
			$("#reg-signup-parent_email").css("border","1px solid red");	
			arr[3] = false;
		}

		if( filter.test( $("#reg-signup-email").val() ) ){
			$("#reg-signup-email").css("border","1px solid #CFCFCF");	
			json_send.email = "email," +  $("#reg-signup-email").val(); 
		}
		else{
			$("#reg-signup-email").css("border","1px solid red");	
			arr[4] = false;
		}

		if( $("#reg-signup-country").val() != bratzHash.language.registration.selectone){
			$("#reg-signup-country").css("border","1px solid #CFCFCF");	
			json_send.country = "country_id," +  $("#reg-signup-country").val(); 
		}
		else{
			$("#reg-signup-country").css("border","1px solid red");	
			arr[5] = false;
		}

		if( $("#reg-signup-state").val() != bratzHash.language.registration.selectone){
			$("#reg-signup-state").css("border","1px solid #CFCFCF");	
			json_send.state = "state_id," +  $("#reg-signup-state").val(); 
		}
		else{
			$("#reg-signup-state").css("border","1px solid red");	
			arr[6] = false;
		}

		if( $("#reg-signup-zip").val() != "" ){
			$("#reg-signup-zip").css("border","1px solid #CFCFCF");	
			json_send.zip = "postal_code," +  $("#reg-signup-zip").val(); 
		 }
		else{
			$("#reg-signup-zip").css("border","1px solid red");	
			arr[7] = false;
		 }

		if( $("#reg-signup-last_name").val() == "" || alpha.test( $("#reg-signup-last_name").val() ) == false ){
			$("#reg-signup-last_name").css("border","1px solid red");	
			arr[8] = false;
		}
		else{
			$("#reg-signup-last_name").css("border","1px solid #CFCFCF");	
			json_send.last_name = "last_name," +  $("#reg-signup-last_name").val(); 
		}

		if( $(".input-gender")  ){
                        if( $("#reg-signup-f").attr("checked") ){
                                json_send.gender = "gender,f";
                         }
                        if( $("#reg-signup-m").attr("checked") == true ){
                                json_send.gender = "gender,m";
                        }
                }

		/*if( bratzvib ){
                        json_send.referred = "referred,1";
                }*/


		json_send.acct_type = "acct_type,teen";
		json_send.option_1 = ( $("#option_1").attr("checked") == true )? "optins_1,brands,1" : "optins_1,brands,0";
		json_send.option_2 = ( $("#option_2").attr("checked") == true )? "optins_2,other_brands,1" : "optins_2,other_brands,0";
		json_send.option_3 = "optins_1,website_id,3";
		json_send.dob = "dob," + $("#dialog-date").val(); 

		if( arr.length == 0 ){
			if( jQuery.trim( $("#reg-signup-email").val() ) == jQuery.trim( $("#reg-signup-parent_email").val() ) ){
				alert(bratzHash.language.registration.sameEmail);
			 }
			else{
			$.post("?request=register", json_send , function( http ){
				if( http != "" ){
					var returnObj = eval( "(" + http  + ")" );
					if( returnObj["error"] ){
							//alert( returnObj["error"] );						
							alert(bratzHash.language.errors[ "errorcode" + returnObj["error"] ]);
					}
					 else{     
						setTimeout( function(){
                                                $("#overlay-dialog").css({ "background" : "none" , "border" : "none" });
                                                $("#dialog-header,#dialog-content-2,#dialog-bottom").css("display", "none");
						$("#dialog-content-2").css("display", "none");
						$("#dialog-reg-complete").css("display","block","background-color","#CFCFCF");

						$("#span-reg-complete-username").html(bratzHash.language.registration.reg_complete_username + $("#reg-signup-username").val() );
                         $("#span-reg-complete-password").html(bratzHash.language.registration.reg_complete_password + $("#reg-signup-password").val() );

                                                $("#complete-btn-close, #reg-complete-close").click( function(){ 
                                                        window.location = "";
                                                 });
						 } , 1000 );
                                        }


				}
			});
			}
		}	
	 }
	,
	childAcct : function(){
		var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
		var alpha = /^([a-zA-Z])+$/;
		var arr = new Array();
		var json_send = {};

		if( $("#reg-signup-first_name").val() == "" || alpha.test( $("#reg-signup-first_name").val() ) == false ){
			$("#reg-signup-first_name").css("border","1px solid #9F004A");	
			arr[0] = false;
		}
		else{
			$("#reg-signup-first_name").css("border","1px solid #CFCFCF");	
			json_send.first_name = "first_name," +  $("#reg-signup-first_name").val(); 
		}

		if( $("#reg-signup-username") ){
			var arr_bad = regValidateObj.badwords;
			if( $("#reg-signup-username").val() == "" ){
					$("#reg-signup-username").css("border","1px solid #9F004A");	
					arr[1] = false;
			}
			else {


			for( x in arr_bad ){
				if( arr_bad[x]  == $("#reg-signup-username").val() ){ 
					$("#reg-signup-username").css("border","1px solid #9F004A");	
					arr[1] = false;
					break;
				}		
				else{
					$("#reg-signup-username").css("border","1px solid #CFCFCF");	
				}
			} 

			( arr[1] == false ) ? null : json_send.username = "username," + $("#reg-signup-username").val();

			}
		}

		if( $("#reg-signup-password").val() == "" ){
			$("#reg-signup-password").css("border","1px solid #9F004A");	
			arr[2] = false;
		}
		else{
			$("#reg-signup-password").css("border","1px solid #CFCFCF");	
			json_send.password = "password," +  $("#reg-signup-password").val(); 
		}

		if( filter.test( $("#reg-signup-parent_email").val() ) ){
			$("#reg-signup-parent_email").css("border","1px solid #CFCFCF");	
			json_send.parent_email = "parent_email," +  $("#reg-signup-parent_email").val(); 
		}
		else{
			$("#reg-signup-parent_email").css("border","1px solid #9F004A");	
			arr[3] = false;
		}

		if( $("#reg-signup-last_name").val() == "" || alpha.test( $("#reg-signup-last_name").val() ) == false ){
			$("#reg-signup-last_name").css("border","1px solid red");	
			arr[4] = false;
		}
		else{
			$("#reg-signup-last_name").css("border","1px solid #CFCFCF");	
			json_send.last_name = "last_name," +  $("#reg-signup-last_name").val(); 
		}

		if( $(".input-gender")  ){
                        if( $("#reg-signup-f").attr("checked") ){
                                json_send.gender = "gender,f";
                         }
                        if( $("#reg-signup-m").attr("checked") == true ){
                                json_send.gender = "gender,m";
                        }
                }

		json_send.acct_type = "acct_type,child";
		json_send.dob = "dob," + $("#dialog-date").val(); 

		/*if( bratzvib ){
			json_send.referred = "referred,1";
		}*/

		if( arr.length == 0 ){
			
			var registerurl = ( not_real_page == true ) ? "?request=register" : base+"index.php?request=register";
			
			$.post(registerurl, json_send , function( http ){
				if( http != "" ){
					var returnObj = eval( "(" + http  + ")" );
					if( returnObj["error"] ){
							//alert( returnObj["error"] );						
							alert(bratzHash.language.errors[ "errorcode" + returnObj["error"] ]);
					}
					 else{     
						setTimeout( function(){
                                                $("#overlay-dialog").css({ "background" : "none" , "border" : "none" });
                                                $("#dialog-header,#dialog-content-2,#dialog-bottom").css("display", "none");
						$("#dialog-content-2").css("display", "none");
						$("#dialog-reg-complete").css("display","block","background-color","#CFCFCF");



						$("#span-reg-complete-username").html(bratzHash.language.registration.reg_complete_username + $("#reg-signup-username").val() );
                                                $("#span-reg-complete-password").html(bratzHash.language.registration.reg_complete_password + $("#reg-signup-password").val() );

                                                $("#complete-btn-close , #reg-complete-close").click( function(){ 
                                                        window.location = "";
                                                 });
						} , 1000 );
                                        }

				}
			});
		}	
	
	}

}

function showDiv(pass){
		 if (document.getElementById(pass)) { 
		 var obj = document.getElementById(pass); 
		 obj.style.display = (obj.style.display=='block')?'none':'block'; 
		 } 
		 return false; 

}


function  GoogleListener(){
	//	objGoogleAEventAttach[ page ]();			
}

function enableCalendar(){

	if( $__( $( "#calendar" ) ) ){
                $("#calendar").click( function(){
                        $("#dialog-calendar").datepicker( {
                                                 onSelect: function(dateText, inst) { $("#dialog-date").val(dateText); $( "#dialog-calendar" ).datepicker( "destroy" ); },
                                                 changeMonth: true ,
                                                 changeYear: true ,
                                                 yearRange: "1900:2011" ,
                                                 dateFormat : "yy-mm-dd"
	                  } );
		} );
		
	}

}

var objGoogleAEventAttach = {

	promos : function(){
	},

	downloads : function(){

			$(".google-a-icon").click( function(){ } );
			$(".google-a-wallpaper").click( function(){ } );
			$(".google-a-screensaver").click( function(){ } );
	},

	bittymeet : function(){ 

		if( page == "bittymeet" ){
			objCallEventTracker( new Object() , 4 );	
		}

	},

	blogs : function(){ 

	},

	catalog : function(){ 

	},

	wishlist : function(){ 

	}

}

function objCallEventTracker( obj , id ){
	alert( obj );
	alert( id );
}

function setMuteCookie(){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+50);
	document.cookie="volOff=0;expires="+exdate.toGMTString() + ";";
}

function setCookie( name , value ){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+50);
	document.cookie="" + name + "=" + value + ";expires="+exdate.toGMTString() + ";";
}

function removeMuteCookie(){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()-50);
	document.cookie="volOff=1;expires="+exdate.toGMTString() + ";" + ";";
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}


function deleteCookie( name ){
	var expdate = new Date();
	expdate.setTime(expdate.getTime() - 1);
	return	document.cookie = name += "=; expires=" + expdate.toGMTString();
}

$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  }
});

function goHome(){
	window.location = "http://www.bratz.com/?section=bratzhomepage";
}


function closeIframe(){ 
	goHome();
	$("#iframe-rock,#div-rock-iframe-wrapper, #div-x-close-wrapper").css("display","none");
}


