var frames=false;
var myDomain='http://www.nzflower.co.nz';
var myParent=myDomain+'/';
var myViewRL='';
if(frames&&self==top){
	var Url=self.location.href;
	var Pst=Url.lastIndexOf('/')+1;
	var Pnd=Url.lastIndexOf('.')+1;
	var Ext=Url.substring(Pnd,Pnd+3);
	if(Ext=='php'){
		var Pnm=Url.substring(Pst,Pnd)+Ext;
		if(Url.indexOf('/shop/')!=-1)Pnm='/shop/'+Pnm;
		document.write('<FORM action="'+myParent+'" method="post" name="redir"><INPUT name="PageName" type="hidden" value="'+Pnm+'"></FORM>');
		document.redir.submit();
	}else if(Url.indexOf('_borders')!=-1){
		window.top.location.href=myParent;
	}
}
var myPopup,myWindow;
var DC=document.cookie;
var today=new Date();
var expiry=new Date(today.getTime()+28*24*60*60*1000);
pageID=new Object();
pageID.pageName="BasketWindow";
function addItem(newItem,newPrice,qtyCtrl,newQty) {
	var tmpStr=document.getElementById(qtyCtrl).value;
//	The 10 specifies a base 10 radix
	if( newQty<=0 || isNaN(parseInt(newQty,10)) || newQty!=parseInt(newQty,10) ){	//	
		if(tmpStr==''){
			alert('Please enter a QUANTITY first!');
		}else if(newQty!=parseInt(newQty)){
			alert('Sorry ... but the input\n\n'+tmpStr+'\n\nis not a valid quantity!');
		}else if(tmpStr=='0'){	//	||tmpStr!=parseInt(tmpStr)
			alert('Please enter a VALID quantity!');
		}else{
			alert('The quantity\n\n'+tmpStr+'\n\nis NOT valid!');
		}
		document.getElementById(qtyCtrl).value="";
		document.getElementById(qtyCtrl).focus();
	}else{
		sameDay=document.cookie.indexOf('sameday');
		if(document.cookie.indexOf('|')!=-1&&(
//		New item IS sameday			& basket contains ORDINARY items
		(newItem.indexOf('sameday')!=-1&&sameDay==-1)
		||
//		New item is NOT sameday		and SAMEDAY items already exist
		(newItem.indexOf('sameday')==-1&&sameDay!=-1))){
			sd=alert('Sorry but if you want to use the SAME DAY service,\n'
			+'ONLY items from the SAME DAY page can be selected!\n\n'
			+'Please either remove the NON same day items,\n'
			+'or remove the SAME DAY items from your basket ...');
			showBasket();
		}else if(confirm('Add quantity '+newQty+' x '+newItem+' to your Shopping Basket? ')){
			index=document.cookie.indexOf('TheBasket');
			countbegin=(document.cookie.indexOf('=', index)+1);
			countend=document.cookie.indexOf(';', index);
			if(countend==-1){
				countend=document.cookie.length;
			}
			document.cookie='TheBasket='+document.cookie.substring(countbegin,countend)+'['+newItem+'|'+newPrice+'|1|'+newQty+'];expires=Friday, 1-Jan-2015 00:00:00 GMT';
			showBasket();
		}
	}
}
function buyItem(newItem,newPrice,newTax,newQty) {
//	Safeguard just in case buyItem hasn't been changed properly to addItem yet
	if(newTax!=parseInt(newTax,10)){ newTax=1; }
//	End safeguard
	if(newQty<=0){
		rc=alert('The product QUANTITY is invalid!');
	}else{
		sameDay=document.cookie.indexOf('sameday');
		if(document.cookie.indexOf('|')!=-1&&(
//		New item IS sameday			& basket contains ORDINARY items
		(newItem.indexOf('sameday')!=-1&&sameDay==-1)
		||
//		New item is NOT sameday		and SAMEDAY items already exist
		(newItem.indexOf('sameday')==-1&&sameDay!=-1))){
			sd=alert('Sorry but if you want to use the SAME DAY service,\n'
			+'ONLY items from the SAME DAY page can be selected!\n\n'
			+'Please either remove the NON same day items,\n'
			+'or remove the SAME DAY items from your basket ...');
			showBasket();
		}else if(confirm('Add quantity '+newQty+' x '+newItem+' to your Shopping Basket? ')){
			index=document.cookie.indexOf('TheBasket');
			countbegin=(document.cookie.indexOf('=', index)+1);
			countend=document.cookie.indexOf(';', index);
			if(countend==-1){
				countend=document.cookie.length;
			}
			document.cookie='TheBasket='+document.cookie.substring(countbegin,countend)+'['+newItem+'|'+newPrice+'|'+newTax+'|'+newQty+'];expires=Friday, 1-Jan-2015 00:00:00 GMT';
			showBasket();
		}
	}
}
function clearBasket(){
	if(confirm('Are you sure you want to CLEAR your basket?')){
		clrBskt=DC.indexOf('TheBasket');
		DC='TheBasket=.';
		self.location.href=self.location.href;
	}
}
function presentValue(value){
	if(value<=0.9999){ newPounds='0'; }
	else{ newPounds=parseInt(value); }
	dec='1';
	for(var i=1;i<=2;i++){ dec=dec+'0'; }
	if(value>0){ newPence=Math.round((value+.000008-newPounds)*(eval(dec))); }
	else{ newPence=0; }
	compstring='9';
	for(var i=1;i<=2-1;i++){
		if(eval(newPence)<=eval(compstring))newPence='0'+newPence;
		compstring=compstring+'9';
	}
	newString=newPounds+'.'+newPence+'';
	return(newString);
}
function removeItem(itemNo){
	if(confirm('Delete product number '+itemNo+' from your basket?')){
		newItemList=null;
		itemlist=0;
		for(var i=0;i<=fulllist.length;i++){
			if(fulllist.substring(i,i+1)=='['){
				itemstart=i+1;
			}else if(fulllist.substring(i,i+1)==']'){
				itemend=i;
				theitem=fulllist.substring(itemstart,itemend);
				itemlist=itemlist+1;
				if(itemlist!=itemNo){ newItemList=newItemList+'['+fulllist.substring(itemstart,itemend)+']'; }
			}
		}
		remvItem=DC.indexOf('TheBasket');
		DC='TheBasket='+newItemList+';expires=Friday, 1-Jan-2015 00:00:00 GMT';
		self.location.href=self.location.href;
	}
}
function showBasket(){
	if((window.navigator.appName.indexOf('Netscape')==-1)||(parseInt(window.navigator.appVersion)>=5)){
		if(myWindow&&!myWindow.closed){
			myWindow.history.go(0);
			myWindow.focus();
		}else{
			var Wide=screen.width-621;
			var High=screen.height-429;
			myWindow=window.open('/shop/basketmini.htm','BasketWindow','height=350,width=610,left='+Wide+',top='+High+',status=yes,toolbar=no,directories=no,menubar=no,location=no,scrollbars=yes,resizable=yes');
		}
	}else{
		window.top.location.href='/shop/basket.htm';
	}
}
function updateBasket(){
	newItemList=null;
	itemlist=0;
	for(var i=0;i<=fulllist.length;i++){
		if(fulllist.substring(i,i+1)=='['){
			thisitem=1;
			itemstart=i+1;
			fullstart=i+1;
		}else if(fulllist.substring(i,i+1)==']'){
			itemend=i;
			itemlist++;
			thiselement='quant'+itemlist;
			newItemList=newItemList+'['+field1+'|'+field2+'|'+field3+'|'+document.SubmitForm.elements[thiselement].value+']';
		}else if(fulllist.substring(i,i+1)=='|'){
			if(thisitem==1)field1=fulllist.substring(itemstart,i);
			if(thisitem==2)field2=fulllist.substring(itemstart,i);
			if(thisitem==3)field3=fulllist.substring(itemstart,i);
			thisitem++;
			itemstart=i+1;
		}
	}
	index=DC.indexOf('TheBasket');
	DC='TheBasket='+newItemList+';expires=Friday, 1-Jan-2015 00:00:00 GMT';
	self.location.href=self.location.href;
}
// Copyright (c) 2000 internet.com Corp. 
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran
function Launch(newURL,newName,newFeatures,orgName){
	var remote=open(newURL,newName,newFeatures);
	if(remote.opener==null)remote.opener=window;
	remote.opener.name=orgName;
	return remote;
}
function WinOpen(imgFile,wide,high){
	myViewRL=myDomain+'/gallery/imgviewer.php?image='+imgFile;
	if(myPopup&&!myPopup.closed){
		myPopup.location.href=myViewRL;
	}else{
		var winl,wint;
		if(!wide)wide=100;
		if(!high)high=100;
		if(navigator.appName.indexOf("Microsoft")>=0){
			winl=(screen.width-wide)/2;
			wint=(screen.height-high)/2;
		}else if((navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)>=3)){
			winl=(screen.availWidth-wide)/2;
			wint=(screen.availHeight-high)/2;
		}
		if(!winl)winl=0;
		if(!wint)wint=0;
		myRemote=Launch(myViewRL,'Viewer','channelmode=0,dependent=0,directories=0,fullscreen=0,height='+high+',left='+winl+',location=0,menubar=0,resizable=1,scrollbars=auto,status=1,toolbar=0,top='+wint+',width='+wide+'','myPopup');
	}
}
// Avoid IE4 error messages
if(window.focus)self.focus();
