var logo_obj=new Object();
var a=new Object();
var url="";
var currPos = 0;

function ShowLittle(num)
{
	if(num == 1)
	{
		document.getElementById('showhide1').style.display = "block";
	}
	else
	{
		document.getElementById('showhide1').style.display = "none";
	}
}
function ShowBig(num)
{
	if(num == 1)
	{
		document.getElementById('showhide2').style.display = "block";
	}
	else
	{
		document.getElementById('showhide2').style.display = "none";
	}
}
function ShowKids(num)
{
	if(num == 1)
	{
		document.getElementById('showhide3').style.display = "block";
	}
	else
	{
		document.getElementById('showhide3').style.display = "none";
	}
}



//ADDED BY POB
//There is a second common.js used on the family site, including it here for simplicity sake.

// date drop down selection boxes
function DateDropDownGenerator(n)
{
	var d=new Date();
	this.name = "dd";
	this.day = '';
	this.month = '';	
	this.year = '';
	this.lblDay = '';
	this.lblMonth = '';
	this.lblYear = '';	
	this.InsertDayDropDown=function(){document.write("<select class=\"dropdownDay\" name=\""+this.name+"_day\"><option value=\"\">"+this.lblDay+"</option>");for(var i=1;i<=31;i++){document.write("<option value=\""+i+"\""+((i==this.day)?"selected":"")+">"+i+"</option>");}document.write("</select>");}
	this.InsertMonthDropDown=function(){var months=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");document.write("<select class=\"dropdownMonth\" name=\""+this.name+"_month\"><option value=\"\">"+this.lblMonth+"</option>");for(var i=0;i<months.length; i++){document.write("<option value=\"" + (i+1) + "\""+(((i+1)==this.month)?"selected":"")+">" + months[i] + "</option>");}document.write("</select>");}
	this.InsertYearDropDown=function(){document.write("<select class=\"dropdownYear\" name=\""+this.name+"_year\"><option value=\"\">"+this.lblYear+"</option>");for(var i=d.getFullYear();i>=d.getFullYear()-100;i--){document.write("<option value=\""+i+"\""+((i==this.year)?"selected":"")+">"+i+"</option>");}document.write("</select>");}
	this.Generate=function(){this.InsertDayDropDown();this.InsertMonthDropDown();this.InsertYearDropDown();}
}

//
// select the a value from dropdown list and focus a textbox
//
function FocusTextboxFromDropdown(which, target) {
	if (which.selectedIndex != 0) {
		target.focus();
	}
}

function SelectDropDownByValue(e, val) {
	for (var i=0; i<e.options.length; i++) {
		if (e.options[i].value == val)
			e.options[i].selected = true;
	}
}

function SelectDropDownByText(e, val) {
	for (var i=0; i<e.options.length; i++) {
		if (e.options[i].text == val)
			e.options[i].selected = true;
	}
}

function TickAll(e, target) {
	for (i=0; i<target.length; i++) {
		target[i].checked=e.checked;
	}
}

function CreateChildElements(i, childName, d, m, y) {
	with (document) {
		write('<tr id="childDetails'+i+'" class="hidden">\n'); 
		write('<td><input name="ChildName'+i+'" size="20" maxlength="50" value="'+childName+'" /></td>');
		write('<td>');	
		var childDOB = 'ChildDOB'+i;						
		var ddg = new DateDropDownGenerator();
		ddg.name = childDOB;
		ddg.Generate();
		SelectDropDownByValue(document.subform[childDOB+'_day'], d);
		SelectDropDownByValue(document.subform[childDOB+'_month'], m);
		SelectDropDownByValue(document.subform[childDOB+'_year'], y);											  
		write('</td>');
		write('<td>&nbsp;</td>');
		write('</tr>');
	}				
}
function ShowHideChildren(n) {
	e = document.getElementById('childHeader');
	if (n>0)
		e.className = 'visible';
	else
		e.className = 'hidden';
		
	for (var i=1; i<=10; i++) {
		e = document.getElementById('childDetails'+i);
		if (i<=n)
			e.className = 'visible';
		else
			e.className = 'hidden';
	}
}

function ShowHideById(id, flag, n) {
	if (n == null) {
		e = document.getElementById(id);
		e.className = flag;
	} else {
		for (var i=0; i<n; i++) {
			e = document.getElementById(id+i);
			e.className = flag;
		}
	}
}

function LoadInFrame() {
	var framePage = 'index.html'
	if (top.location == self.location) { window.location = framePage +'?page='+ window.location.pathname + escape(window.location.search) }
}






























function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)

	if (str.indexOf(at)==-1) return false;
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	if (str.indexOf(at,(lat+1))!=-1) return false;
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
	if (str.indexOf(dot,(lat+2))==-1) return false;/*	*/
	if (str.indexOf(" ")!=-1) return false;

	return true;
} 


function validate_login(){
	var ret = true;
	var retMissing = "";
			
	if(document.getElementById("email").value.length <= 0 || !echeck(document.getElementById("email").value)){
		retMissing = retMissing + "email<br>";
		ret = false;
	}
	
	if(document.getElementById("password").value.length <= 0){
		retMissing = retMissing + "password<br>";
		ret = false;
	}
	
	if(!ret){
		document.getElementById("errormsg").innerHTML = "Oops! The following fields are either missing or invalid:<br>" + retMissing;
		document.getElementById("errormsg").style.display = "";
	} else {
		document.getElementById("errormsg").style.display = "none";
	}
	
	return ret;
}


function validate_password_request(){
	var ret = true;
	var retMissing = "";
	
	if(document.getElementById("name").value.length <= 0){
		retMissing = retMissing + "name<br>";
		ret = false;
	}
		
	if(document.getElementById("email").value.length <= 0 || !echeck(document.getElementById("email").value)){
		retMissing = retMissing + "email<br>";
		ret = false;
	}
	
	if(document.getElementById("company").value.length <= 0){
		retMissing = retMissing + "company<br>";
		ret = false;
	}
	
	if(!ret){
		document.getElementById("errormsg").innerHTML = "Oops! The following fields are either missing or invalid:<br>" + retMissing;
		document.getElementById("errormsg").style.display = "";
	} else {
		document.getElementById("errormsg").style.display = "none";
	}
	
	return ret;
}
































function showHideElements(eName){
	document.getElementById("smoothies").style.display = "none";
	document.getElementById("juicywaters").style.display = "none";
	document.getElementById("cartons").style.display = "none";
	document.getElementById("kids").style.display = "none";
	document.getElementById("recycling").style.display = "none";

	document.getElementById(eName).style.display = "";
}


/////////////////THIS BIT HANDLES THE ROLLOVERS !!!//////////////////
function logo_over(name)
{
	url = name;
	var tester=new Image();
	tester.onload=isGoodOver;
	tester.onerror=isBadOver;
    tester.src= "../images/staff/"+name+"_b.jpg";
}

function logo_out(name)
{	
	url = name;
	var tester=new Image();
	tester.onload=isGoodOut;
	tester.onerror=isBadOut;
    tester.src= "../images/staff/"+name+".jpg";
}


function isGoodOut() 
{   
    var o=new Object();
	o.out=new Image();
	o.out.src="../images/staff/"+url+".jpg";
	document[url].src=o.out.src;
}

function isBadOut() 
{
    var o=new Object();
	o.out=new Image();
	o.out.src="../images/staff/"+url+".jpg";
	document[url].src=o.out.src;
}

function isGoodOver() 
{   
    var o=new Object();
	o.over=new Image();
	o.over.src="../images/staff/"+url+"_b.jpg";	
	document[url].src=o.over.src;
}

function isBadOver() 
{
    var o=new Object();
	o.over=new Image();
	o.over.src="../images/staff/"+url+".jpg";	
	//o.over.src="../images/staff/noimage.jpg";	
	document[url].src=o.over.src;
}

///////////////// END OF THIS BIT HANDLES THE ROLLOVERS !!!//////////////////


// Popup Window (Centred)
function popup(url,winname,w,h,feat)
{
	if (!(isNaN(w) || isNaN(h)))
	{
		var x=parseInt((screen.width-w)/2);
		var y=parseInt((screen.height-h)/2);
		if (x<0)	x=0;
		if (y<0)	y=0;
		
		if (feat!=null && feat!="")
		{
			feat=","+feat;
		}
		else
		{
			feat="";
		}
		feat="left="+x+",top="+y+",width="+w+",height="+h+feat;
	}
	var win_obj=window.open(url,winname,feat);
	if (win_obj)
	{
		win_obj.focus();
	}
}


function doStuff(name)
{
	window.open("mailto:"+name+"@innocentdrinks.co.uk");
}

function doStuff2(name)
{
	window.open("mailto:"+name+"@innocentdrinks.be");
}

function doStuff3(name)
{
	window.open("mailto:"+name+"@innocentdrinks.fr");
}

function doStuff4(name)
{
	window.open("mailto:"+name+"@innocentdrinks.ie");
}

function doStuff5(name)
{
	window.open("mailto:"+name+"@innocentdrinks.nl");
}

function doStuff6(name)
{
	window.open("mailto:"+name+"@freshmarketing.co.uk");
}

