function openPopup(url, parameters) {
	window.open(url, "LevisPopup", parameters);
}

function openMinimalPopup(url, parameters) {
	parameters += "status=0,toolbar=0,location=0,menubar=0";
	openPopup(url, parameters);
}

function getOSName(){
	var OSName = "";
	if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
	if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
	if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
	if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
	return OSName;
}

// Called by the accessories section
function openPhones(){
    window.location = "http://www.modelabs.com/levis/";
}

function changeSection(browserTitle, sectionName) {	
  if(browserTitle != "") {
	document.title = browserTitle;
  }
  window.location.hash = "#" + sectionName;
}


function getDomain() {
	return window.location.host;
}

/* open media */
function openMakingOffBlue() {	
	window.location = "http://" + getDomain() + "/" + languageCode + "_" + countryCode + "/media-center.html#home/making-of-blue";
}
function openMakingOffLEJ() {	
	window.location = "http://" + getDomain() + "/" + languageCode + "_" + countryCode + "/media-center.html#home/LEJ_BOY_HD";
}
function openMakingOffRedTab() {	
	window.location = "http://" + getDomain() + "/" + languageCode + "_" + countryCode + "/media-center.html#home/REDTAB_GUYS_HD";
}
function openMakingOffLVC() {	
	window.location = "http://" + getDomain() + "/" + languageCode + "_" + countryCode + "/media-center.html#home/LVC_HD1";
}

/* renvois l'url de base en cours */
function getBaseUrl(){
	var currentUrl
	var aUrl
	currentUrl=document.location.href;
	aUrl = currentUrl.split("#");	
	return aUrl[0];	
}
function getBaseParams(){
	var currentUrl
	var aUrl
	currentUrl=document.location.href;
	aUrl = currentUrl.split("#");	
	return aUrl[1];	
}
function getUrlSection(){
	var currentUrl
	var aUrl
	var aParams
	currentUrl=document.location.href;
	aUrl = currentUrl.split("#");
	if(aUrl.length>1){	
		aParams = aUrl[1].split("/");	
		return aParams[0];
	}else{
		return undefined;
	}	
}
function getUrlInternalName(){
	var currentUrl
	var aUrl
	var aParams
	currentUrl=document.location.href;
	aUrl = currentUrl.split("#");
	if(aUrl.length>1){	
		aParams = aUrl[1].split("/");	
		return aParams[1];
	}else{
		return undefined;
	}	
}
function setUrl(section, internalName, displayName){
	var url
	url = getBaseUrl() + "#" + section;
	if (internalName != undefined){
		url += "/"+internalName;
	}
	document.location.href = url;
	document.title = "Levi - " + section.toUpperCase() + " - " + displayName.toUpperCase();
}

function getUrlParam(name)
{ 
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
	var regexS = "[\\?&]"+name+"=([^&#]*)"; 
	var regex = new RegExp( regexS ); 
	var results = regex.exec( window.location.href ); 
	if( results == null )    return ""; 
	else return results[1];
}


// Communication between the main Flashes and the sound player in the header
function SoundPlayer_doAction( idAction, pValue, pTime ) {
    document.getElementById("flashmain").doCommand( idAction, pValue, pTime );
}

function SoundPlayer_update( listXml, pStartPlaying ) {
    document.getElementById("flashmain").updateList( listXml, pStartPlaying );
}

// Navigation methods
function windowOpener(windowUri, windowWidth, windowHeight, windowOptions)
{	
    var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;

    var newWindow = window.open(windowUri, '', 'resizable=0,width=' + windowWidth + 
        ',height=' + windowHeight + 
        ',left=' + centerWidth + 
        ',top=' + centerHeight +
		',' + windowOptions);

	if (newWindow) newWindow.focus(); 
}

function navigateToShop(productCode) {
	var destination;
	if (productCode == null)
		destination = "http://shop.eu.levi.com";
	else
		destination = "http://shop.eu.levi.com/-/" + productCode + "/-?lang=" + languageCode + "&country=" + countryCode;
	window.location = destination;
}

function navigateToStoreLocator(productCode) {
	// The product code is currently ignored
	window.location = "http://shop.eu.levi.com/storelocator?lang=" + languageCode + "&country=" + countryCode;
}

function navigateToBlueShop() {
	window.location = "http://shop.eu.levi.com/search/blue?pg=1";
}

function navigateToRedtabShop() {
	window.location = "http://shop.eu.levi.com/search/red-tab?pg=1";
}

function navigateToLejShop() {
	window.location = "http://shop.eu.levi.com/search/Levis-Engineered-Jeans?pg=1";
}

function navigateToVintageShop() {
	window.location = "http://shop.eu.levi.com/search/Levi%27s-vintage-clothing?pg=1";
}

function navigateToRedtab() {
	window.location = "http://eu.levi.com/" + languageCode + "_" + countryCode + "/levis_collections/levis-jeans.html";
}

function getContest()
{ 
	return true;
}

