

function inputupdate(formid,ourid,checkval){
var txt=eval("document.forms['"+formid+"']."+ourid+".value");
	if(txt==checkval){
	eval("document.forms['"+formid+"']."+ourid+".value = \"\"");
	}
}


function menucolor(id,col){
x=document.getElementById(id);
x.style.background=col;
}


function calc_total(cost,quantity){
amount=cost*quantity;
alert(amount);
}


function update_total(inid){
special_quantity=eval("document.cart_quantity.special_quantity_"+inid);
special_price=eval("document.cart_quantity.special_price_"+inid);
the_special_quantity=0;

	if(special_quantity){
	the_special_quantity=parseInt(special_quantity.value,10);
	the_special_price=parseFloat(special_price.value,10);
	}

outputid="total_"+inid;
var selectBox=document.cart_quantity.elements[0];
samount=selectBox.options[selectBox.selectedIndex].text;
option_special=(samount.lastIndexOf("SPECIAL OFFER BUY "));

	if(option_special>-1){
	the_special_quantity_end=(samount.indexOf(" ",(option_special+18)));
	the_special_quantity=parseInt(samount.substring((option_special+18),the_special_quantity_end));
	option_special=(samount.lastIndexOf("FOR ONLY £"));
	the_special_price_end=(samount.indexOf(" ",(option_special+10)));
	the_special_price=parseFloat(samount.substring((option_special+10),the_special_price_end));
	}

cutstart=(samount.lastIndexOf("("))+2;
cutend=samount.length-1;
samount=samount.substring(cutstart,cutend);
samount=parseFloat(samount,10);
var selectBox=document.cart_quantity.cart_quantity;
syear=selectBox.options[selectBox.selectedIndex].value;

	if(the_special_quantity>0){
	outtotal=(syear%the_special_quantity)*samount;
	outtotal+=(Math.floor((syear/the_special_quantity))*the_special_price);
	outtotal=outtotal.toFixed(2);
	}else{
	outtotal=(samount*syear).toFixed(2);
	}

document.getElementById(outputid).innerHTML="Total: &pound;"+(outtotal);
}


function update_named_total(inid,formid){
special_quantity=eval("document."+formid+".special_quantity_"+inid);
special_price=eval("document."+formid+".special_price_"+inid);
the_special_quantity=0;

	if(special_quantity){
	the_special_quantity=parseInt(special_quantity.value,10);
	the_special_price=parseFloat(special_price.value,10);
	}

outputid="total_"+inid;
var selectBox=eval("document."+formid+".elements[0]");
samount=selectBox.options[selectBox.selectedIndex].text;
option_special=(samount.lastIndexOf("SPECIAL OFFER BUY "));

	if(option_special>-1){
	the_special_quantity_end=(samount.indexOf(" ",(option_special+18)));
	the_special_quantity=parseInt(samount.substring((option_special+18),the_special_quantity_end));
	option_special=(samount.lastIndexOf("FOR ONLY £"));
	the_special_price_end=(samount.indexOf(" ",(option_special+10)));
	the_special_price=parseFloat(samount.substring((option_special+10),the_special_price_end));
	}

cutstart=(samount.lastIndexOf("("))+2;
cutend=samount.length-1;
samount=samount.substring(cutstart,cutend);
samount=parseFloat(samount,10);
var selectBox=eval("document."+formid+".cart_quantity");
syear=selectBox.options[selectBox.selectedIndex].value;

	if(the_special_quantity>0){
	outtotal=(syear%the_special_quantity)*samount;
	outtotal+=(Math.floor((syear/the_special_quantity))*the_special_price);
	outtotal=outtotal.toFixed(2);
	}else{
	outtotal=(samount*syear).toFixed(2);
	}

document.getElementById(outputid).innerHTML="Total: &pound;"+(outtotal);
}


function update_matrix_total(inid,formid){
inid="-"+inid +"-";
update(inid);
}

var opacity=0;
var display=1;


function updatetext(){
display++;
	if(display==total){
	display=0;
	}
y=document.getElementById("cosstick");
y.innerHTML=contents[display];
var t=setTimeout("fadein()",7000);
}


function fadein(){
	if(opacity<11){
	value=(10-opacity);
	y=document.getElementById("cosstick");
	y.style.opacity=value/10;
	y.style.filter='alpha(opacity='+value*10+')';
	var t=setTimeout("fadein()",50);
	opacity++;
	}else{
	updatetext();
	fadeout();
	}
}


function fadeout(){
	if(opacity>-1){
	y=document.getElementById("cosstick");
	value=(10-opacity);
	y.style.opacity=value/10;
	y.style.filter='alpha(opacity='+value*10+')';
	opacity--;
	var t=setTimeout("fadeout()",50);
	}else{
	}
}


function wishlist(productsid){
x="i"+productsid+"-"+2;
scol=0;
ssize=0;

	if(selectBox=document.getElementById(x)){
	scol=selectBox.options[selectBox.selectedIndex].value;
	}

x="i"+productsid+"-"+1;

	if(selectBox=document.getElementById(x)){
	ssize=selectBox.options[selectBox.selectedIndex].value;
	}

window.location="http://technicare-dental.co.uk/wishlist-w-"+productsid+"{2}"+scol+"{1}"+ssize+".html";
}


function copyToBuffer(){
CopiedTxt=document.selection.createRange();
CopiedTxt.execCommand("Copy");
}


function hilight(inid){
x=document.getElementById(inid);
	if (x){
		if((x.style.backgroundColor=="#236686")||(x.style.backgroundColor=="rgb(35, 102, 134)")){
		}else{
		x.style.backgroundColor="#305a6d";
		x.style.border="1px outset #ffffff";
		}
	}
}


function restore(inid){
x=document.getElementById(inid);
	if (x){
		if((x.style.backgroundColor=="#236686")||(x.style.backgroundColor=="rgb(35, 102, 134)")){
		}else{
		x.style.backgroundColor="#31306d";
		x.style.border="1px inset #ffffff";
		}
	}
}


function update(inid){



prodid=inid.split("-");
productid=prodid[1];
matrixid="matrix"+productid;
var j=document.getElementById(matrixid).rows.length;
var c=document.getElementById(matrixid).rows[0].cells;
var totalc=c.length;

	if (inid.substr(0,1) == "i"){
		for(i=1; i<j; i++){
		var x=document.getElementById(matrixid).rows[i].cells;
			for(k=1; k<totalc; k++){
			z=document.getElementById(matrixid).rows[i].cells[k];
			zz=z.id;
			z.style.backgroundColor="#31306d";
			z.style.border="1px inset #ffffff";
			}
		}
	} else {

		for(i=1; i<j; i++){
		var x=document.getElementById(matrixid).rows[i].cells;
			for(k=1; k<totalc; k++){
			z=document.getElementById(matrixid).rows[i].cells[k];
			zz=z.id;
			zzz=document.getElementById(zz);
			zstring = zzz.style.border;
			spos =zstring.indexOf("outset", 0);

			if (spos > -1){
			tempid = zz;
			}


			}
		}
	}


	if (inid.substr(0,1) == "i"){
	x=document.getElementById(inid);
	x.style.backgroundColor="#236686";
	x.style.border="1px outset #ffffff";
	cost=(x.childNodes[1].attributes['value'].nodeValue);
	formid="form"+productid;
	form=document.getElementById(formid);
	var selectBox=form.cart_quantity;
	samount=selectBox.options[selectBox.selectedIndex].text;
	var y=form.products_matrix;
	y.value=inid;
	totalcost=(cost*samount).toFixed(2);
	totalid="total_"+productid;
	x=document.getElementById(totalid);
	x.innerHTML="Total: &pound;"+totalcost;
	} else {
	x=document.getElementById(tempid);
	x.style.backgroundColor="#236686";
	x.style.border="1px outset #ffffff";
	cost=(x.childNodes[1].attributes['value'].nodeValue);
	formid="form"+productid;
	form=document.getElementById(formid);
	var selectBox=form.cart_quantity;
	samount=selectBox.options[selectBox.selectedIndex].text;
	var y=form.products_matrix;
	y.value=tempid;
	totalcost=(cost*samount).toFixed(2);
	totalid="total_"+productid;
	x=document.getElementById(totalid);
	x.innerHTML="Total: &pound;"+totalcost;
	}
}
