function addToCart(prodId, action){
if(action != 2 && action != 3){
shopDiv = document.getElementById('shoppingCartContent');
shopDiv.innerHTML = 'Loading data ....please wait';
faderDiv(100);
}
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'addToCart';
ajaxVar.vars['prodId'] = prodId;
ajaxVar.vars['case'] = action;
ajaxVar.fnVars['showLeftBasket'] = '1';
ajaxVar.gotoFunction = 'ShowCart';
ajaxVar.AjaxPostSQL();
}
function viewCart(){
shopDiv = document.getElementById('shoppingCartContent');
shopDiv.innerHTML = 'Loading data ....please wait';
faderDiv(100);
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'addToCart';
ajaxVar.gotoFunction = 'ShowCart';
ajaxVar.AjaxPostSQL();
}
function ShowCart(dataArr, fnVars){
shopDiv = document.getElementById('shoppingCartContent');
if(dataArr == 'empty'){
shopDiv.innerHTML = "
Your shopping basket is currently empty.
";
if(document.getElementById('basketinfo')){
document.getElementById('basketinfo').innerHTML = "Your shopping basket is currently empty.
";
document.getElementById('checklink').style.visibility = 'hidden';
document.getElementById('checklink').style.display = 'none';
}
}else{
var conArr = dataArr.split('##**##');
shopDiv.innerHTML = conArr[0];
if(document.getElementById('basketinfo')){
document.getElementById('basketinfo').innerHTML = conArr[1];
document.getElementById('checklink').style.visibility = 'visible';
document.getElementById('checklink').style.display = 'block';
}
}
shopDiv.style.visibility = 'visible';
shopDiv.style.display = 'block';
if(document.getElementById('shopCont') ){
leftItem();
}
}
function showCartBox(){
opacity('cartBox', 0, 100, 100);
}
function leftItem(){
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'removeProduct';
ajaxVar.gotoFunction = 'ShowLeftCart';
ajaxVar.AjaxPostSQL();
}
function removeProduct(prodId){
if(confirm('Are you sure you want to delete this item?')){
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'addToCart';
ajaxVar.vars['prodId'] = prodId;
ajaxVar.vars['case'] = 4;
ajaxVar.gotoFunction = 'ShowCart';
ajaxVar.AjaxPostSQL();
}else{
return false;
}
}
function faderDiv(extraHeight){
var bodyObj = document.getElementsByTagName('body')[0];
var faderDiv = document.createElement('div');
faderDiv.style.position = 'absolute';
faderDiv.id = 'fader';
if(bodyObj.offsetWidth == screen.width){
var bodyWidth = (bodyObj.offsetWidth - 21);
}else{
var bodyWidth = bodyObj.offsetWidth;
}
faderDiv.style.width = bodyWidth + 'px';
faderDiv.style.height = bodyObj.offsetHeight + extraHeight +'px';
faderDiv.style.zIndex = 10;
faderDiv.style.left = 0;
faderDiv.innerHTML = ' ';
bodyObj.insertBefore(faderDiv, bodyObj.firstChild);
changeOpac(0, 'fader');
faderDiv.style.backgroundColor = '#c4baa5';
faderDiv.onclick = function(e){
closeCartBox();
};
changeOpac(0, 'cartBox');
var cartDiv = document.getElementById('cartBox');
cartDiv.className = 'visiblediv';
var cartLeft = (bodyObj.offsetWidth - 550) / 2;
cartDiv.style.left = cartLeft + 'px';
var topUrl = location.href.split('#');
location.href = topUrl[0] + '#bodyStart';
opacity('fader', 0, 80, 500, 'showCartBox');
}
function changeOpac(opacity, id, gotoFunction) {
var object = document.getElementById(id).style;
object.opacity = (opacity / 100);
object.MozOpacity = (opacity / 100);
object.KhtmlOpacity = (opacity / 100);
object.filter = "alpha(opacity=" + opacity + ")";
if(gotoFunction) { eval(gotoFunction + '()'); }
}
function opacity(id, opacStart, opacEnd, millisec, gotoFunction) {
var speed = Math.round(millisec / 100);
var timer = 0;
var sendFunction = '';
if(opacStart > opacEnd) {
for(i = opacStart; i >= opacEnd; i--) {
if(i == opacEnd && gotoFunction){
sendFunction = gotoFunction;
}
setTimeout("changeOpac(" + i + ",'" + id + "','" + sendFunction + "')",(timer * speed));
timer++;
}
}else if(opacStart < opacEnd) {
for(i = opacStart; i <= opacEnd; i++) {
if(i == opacEnd && gotoFunction){
sendFunction = gotoFunction;
}
setTimeout("changeOpac(" + i + ",'" + id + "','" + sendFunction + "')",(timer * speed));
timer++;
}
}
}
function closeCartBox(){
var cartDiv = document.getElementById('cartBox');
cartDiv.className = 'hiddendiv';
var faderDiv = document.getElementById('fader');
faderDiv.parentNode.removeChild(faderDiv);
}
function removeItem(prodId){
if(confirm('Are you sure you want to delete this item?')){
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'removeProduct';
ajaxVar.vars['prodId'] = prodId;
ajaxVar.gotoFunction = 'ShowLeftCart';
ajaxVar.AjaxPostSQL();
}else{
return false;
}
}
function ShowLeftCart(dataArr, fnVars){
shopDiv = document.getElementById('shopCont');
if(dataArr == 'empty'){
document.getElementById('save').disabled = true;
shopDiv.innerHTML = "Your shopping basket is currently empty.
";
}else{
shopDiv.innerHTML = dataArr;
}
}
function selectProdType(prodTypeId){
document.frmProd.submit();
}
function selectValues(){
document.frmProd.submit();
}