

var newWindow;

function fLinks(x) { //popping up a new window... and re-using/bring to front if already active
	if (!newWindow || newWindow.closed) {
			newWindow = window.open(x,"subwind");
		} else {
		//window is already open, so bring it to the front
			newWindow.location.href = x;
			newWindow.focus();
		}
}

function showHide(numOfItems,myID) {
	var noOfStories = numOfItems; //number of stories
	
	for (i=0; i<noOfStories; i++) { //reset all items
		document.getElementById('ans'+i).style.display = "none";
	}

	document.getElementById('ans'+myID).style.display = "block"; //show selected item

}

function showHide2(numOfItems,myID) {
	var noOfStories = numOfItems; //number of stories
	
	for (i=0; i<noOfStories; i++) { //reset all items
		document.getElementById('ans'+i).style.display = "none";
		document.getElementById('h'+i).className = "";
	}

	document.getElementById('ans'+myID).style.display = "block"; //show selected item
	document.getElementById('h'+myID).className = "hilit";

}
	
	
	


function fCustomLinks(URL,w,h,doscroll,domenubar) { //popping up a new window... and re-using/bring to front if already active

	if (newWindow) {
		newWindow.close();
	}
	
	newWindow = window.open(URL, 'popwin', 'toolbar=0,scrollbars=' + doscroll + ',location=0,statusbar=0,menubar=' + domenubar + ',resizable=0,width=' + w + ',height=' + h);
	newWindow.focus();
}


function customPopup(URL,w,h) {
	window.open(URL, 'popwin', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + w + ',height=' + h);
}

function roll(imageName,imageSrc) {	//used for image rollovers
	document.images[imageName].src = imageSrc.src
}

function leaveGSK(url) { //promoting the landing page text
	if (confirm("You are now leaving www.showyourstyle.co.uk and moving to a website that is not controlled by GlaxoSmithKline.\nGlaxoSmithKline does not endorse or recommend this website, the information it contains or any products or services that it may offer.")) {
		window.location = url;
	}
}

function leaveSite(url) { //promoting the landing page text
	if (confirm("Your are now leaving GSK's PLUS website.\nPlease check the terms and conditions of any other GSK website that you link to.")) {
		window.location = url;
	}
}




//COOKIES
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function createRequestObject() {
	
	// use this way:
  //FORM_DATA = createRequestObject();
  // Retrieve information with 'FORM_DATA [ key ] = value'.
  
  
  FORM_DATA = new Object();
    // The Object ("Array") where our data will be stored.
  separator = ',';
    // The token used to separate data from multi-select inputs
  query = '' + this.location;
  qu = query
    // Get the current URL so we can parse out the data.
    // Adding a null-string '' forces an implicit type cast
    // from property to string, for NS2 compatibility.
  query = query.substring((query.indexOf('?')) + 1);
    // Keep everything after the question mark '?'.
  if (query.length < 1) { return false; }  // Perhaps we got some bad data?
  keypairs = new Object();
  numKP = 1;
    // Local vars used to store and keep track of name/value pairs
    // as we parse them back into a usable form.
  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;
      // Split the query string at each '&', storing the left-hand side
      // of the split in a new keypairs[] holder, and chopping the query
      // so that it gets the value of the right-hand string.
  }
  keypairs[numKP] = query;
    // Store what's left in the query string as the final keypairs[] data.<
  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
      // Left of '=' is name.
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
      // Right of '=' is value.
    while (keyValue.indexOf('+') > -1) {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
        // Replace each '+' in data string with a space.
    }
    keyValue = unescape(keyValue);
      // Unescape non-alphanumerics
    if (FORM_DATA[keyName]) {
      FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
        // Object already exists, it is probably a multi-select input,
        // and we need to generate a separator-delimited string
        // by appending to what we already have stored.
    } else {
      FORM_DATA[keyName] = keyValue;
        // Normal case: name gets value.
    }
  }
  return FORM_DATA;
}

 function hilit(id) {
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

