// JavaScript Document


function newWindow(page) {
	
	window.open('popups/'+page+'.php', '_popup', 'width=300,height=500,scrollbars=1,resizable=1');
	
}

function insertEmail() {
	var p = document.getElementById('emailPara');
	p.innerHTML = 'E-mail: <a href="mailto:sales@swissvax.co.uk">sales@swissvax.co.uk</a>';
}

function removeItem(name) {
	var conf = confirm('Remove "'+name+'" from your basket?');
	if (conf) pageTracker._trackPageview('/basket/item_removed');
	
	return conf;
}

function togglePassword() {
	var field = document.getElementById('password');
	if (field.type=='text') {
		field.type='password';
	} else {
		field.type='text';	
	}
}

function useCode(code) {
	var url = 'libs/includes/ajax.php?action=promo&value='+code;	
	http.onreadystatechange=function() {
		if (http.readyState==4 && http.status==200) {
			pageTracker._trackPageview('/promo/code_accepted');
			alert(http.responseText);
			if ((http.responseText.indexOf('% discount') > -1) || (http.responseText.indexOf('Pounds off your order') > -1)) {
				updateBasket(code); 
			}
		} else if (http.status!=200) {
			alert('Error ' + http.status + ': ' + http.statusText);
		}
	}
	http.open("GET", url);
	http.send(null);
	return false;
}

function updateBasket(code) {
	
	window.location = 'index.php?page=checkout&code='+code+'&valid=1';
	
}

// EDIT THESE VALUES IF REQUIRED
var alertText = 'Are you sure you wish to perform this action' + "\n"; //DEFAULT TEXT DISPLAYED ON CONFIRM BUTTONS/LINKS WHEN NO ALT/TITLE
var newWindowLink = false; //OPEN EXTERNAL LINKS BY DEFAULT IN A NEW WINDOW (TRUE/FALSE)?


var woms = new Array(); //CREATE ARRAY OF FUNCTIONS TO LAUNCH ONLOAD

//ONLOAD MANAGER
function womOn(){
  window.onload = womGo;
}

function womGo(){
  for(var i = 0;i < woms.length;i++)
    eval(woms[i]);
}

function womAdd(func){
  woms[woms.length] = func;
}

function CreateBookmarkLink() {

	title = document.title;
	url = window.location.href;
	
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,"");
	} else if(window.external) {
		window.external.AddFavorite( url, title); 
	} else if(window.opera && window.print) {
		return true;
	}
	
}

function objToggle(obj) { 

	var obj = document.getElementById(obj);

	if(obj.style.display == "block") { 
		obj.style.display = "none";
	} else { 
		obj.style.display = "block";
	}

}
