function ShowCart(dataArr, fnVars){
if(dataArr == 0){
var TotCnt = 0;
}else{
var TotCnt = dataArr.split('||--||');
}
hideBasketDiv();
var tbl = document.createElement("table");
tbl.id = 'cartListing';
tbl.width = 780;
//tbl.border = 1;
var tblBody = document.createElement("tbody");
if(TotCnt.length>0){
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.colSpan = "5";
cell.className = 'imgCursor tright';
var urlValue = location.href;
if(urlValue.indexOf("checkoutDetails.php") > 0){
cell.innerHTML = ' ';
}else{
cell.innerHTML = ' ';
}
row.appendChild(cell);
tblBody.appendChild(row);
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.width = 80;
cell.innerHTML = ' ';
row.appendChild(cell);
var cell = document.createElement("td");
cell.width = 230;
cell.className = 'cartHead';
cell.innerHTML = 'Product';
row.appendChild(cell);
var cell = document.createElement("td");
cell.width = 130;
cell.innerHTML = ' ';
row.appendChild(cell);
var cell = document.createElement("td");
cell.width = 250;
cell.className = 'cartHead txtAlign';
cell.innerHTML = 'Quantity';
row.appendChild(cell);
var cell = document.createElement("td");
cell.className = 'cartHead tright';
cell.innerHTML = 'Total';
row.appendChild(cell);
tblBody.appendChild(row);
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.innerHTML = ' ';
cell.width = 95;
row.appendChild(cell);
var cell = document.createElement("td");
cell.colSpan = "4";
cell.innerHTML = '
';
row.appendChild(cell);
tblBody.appendChild(row);
var grdTotal = 0;
document.getElementById('prodTotalCnt').innerHTML = (TotCnt.length -1);
for(var i=0;i<(TotCnt.length -1);i++){
var cartVar = TotCnt[i].split('||++||');
var ProdId = cartVar[0] + '_' + cartVar[4] + '_' + cartVar[5];
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.width = 80;
cell.height =105;
cell.innerHTML = '';
row.appendChild(cell);
var cell = document.createElement("td");
cell.width = 230;
cell.className = 'boldtext';
cell.innerHTML = cartVar[7] +'
' + cartVar[6] +'';
row.appendChild(cell);
var cell = document.createElement("td");
cell.className = 'paddtd';
cell.innerHTML = "";
row.appendChild(cell);
var cell = document.createElement("td");
cell.className = 'txtAlign';
cell.width = 250;
var subTbl = document.createElement("table");
subTbl.width = 250;
subTbl.style.textAlign = 'center';
var subtblBody = document.createElement("tbody");
var subrow = document.createElement("tr");
var subcell = document.createElement("td");
subcell.width = 70;
subrow.appendChild(subcell);
var subcell = document.createElement("td");
var minusImg = document.createElement('img');
minusImg.id = "minus"+ ProdId;
minusImg.src = 'proimages/minus.png';
minusImg.className = 'pointerCur minusImg';
minusImg.alt = 'Decrement quantity';
minusImg.title = 'Decrement quantity';
minusImg.onclick = function(e){
reduceQuantity(this.id,this);
};
subcell.appendChild(minusImg);
subrow.appendChild(subcell);
var subcell = document.createElement("td");
var textBox = document.createElement('input');
textBox.type = 'text';
textBox.style.width = '30px';
textBox.className = 'txtClass';
textBox.readOnly = true;
textBox.id = 'quantity_'+ ProdId;
textBox.name = 'quantity_'+ ProdId;
textBox.value = cartVar[2];
subcell.appendChild(textBox);
subrow.appendChild(subcell);
var subcell = document.createElement("td");
var plusImg = document.createElement('img');
plusImg.id = "plus"+ ProdId;
plusImg.src = 'proimages/plus.png';
plusImg.className = 'pointerCur plusImg';
plusImg.alt = 'Increment quantity';
plusImg.title = 'Increment quantity';
plusImg.onclick = function(e){
addQuantity(this.id);
};
subcell.appendChild(plusImg);
subrow.appendChild(subcell);
var subcell = document.createElement("td");
subcell.width = 70;
subrow.appendChild(subcell);
subtblBody.appendChild(subrow);
subTbl.appendChild(subtblBody);
cell.appendChild(subTbl);
row.appendChild(cell);
var cell = document.createElement("td");
cell.className = 'boldtext cartWidth tright';
cell.id = 'total_'+ProdId;
cell.innerHTML = "£"+ (ThousandSeparator(2,cartVar[1] * cartVar[2])) + '
';
row.appendChild(cell);
grdTotal = grdTotal + (cartVar[1] * cartVar[2]);
tblBody.appendChild(row);
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.colSpan = "5";
cell.width = 772;
cell.innerHTML = '
';
row.appendChild(cell);
tblBody.appendChild(row);
}
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.colSpan = "4";
cell.innerHTML = ' ';
row.appendChild(cell);
var cell = document.createElement("td");
var divObj = document.createElement("div");
divObj.id = 'grandTotal';
divObj.innerHTML = '£'+ThousandSeparator(2,grdTotal);
divObj.className = 'boldtext totSize tright';
cell.appendChild(divObj);
row.appendChild(cell);
tblBody.appendChild(row);
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.colSpan = "5";
cell.className = 'imgCursor tright';
cell.innerHTML = ' ';
row.appendChild(cell);
tblBody.appendChild(row);
}else{
document.getElementById('prodTotalCnt').innerHTML = 0;
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.className = 'errorClass';
cell.innerHTML = 'There are currently no items in your shopping basket';
row.appendChild(cell);
tblBody.appendChild(row);
}
tbl.appendChild(tblBody);
shopDiv = document.getElementById('shoppingCartContent');
shopDiv.innerHTML = '';
shopDiv.appendChild(tbl);
var cartLength = TotCnt.length -1;
if(cartLength > 2){
var extraHeight = 100 * parseInt(cartLength-3,10);
}else{
var extraHeight = 0;
}
}
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 = '#8c7a71';
faderDiv.onclick = function(e){
closeCartBox();
};
changeOpac(0, 'cartBox');
var cartDiv = document.getElementById('cartBox');
cartDiv.className = 'visiblediv';
var cartLeft = (bodyObj.offsetWidth - 830) / 2;
cartDiv.style.left = cartLeft + 'px';
var topUrl = location.href.split('#');
location.href = topUrl[0] + '#bodyStart';
opacity('fader', 0, 80, 500, 'showCartBox');
}
function removeProduct(prodId,divObj){
// var question = confirm("Are you sure you want to delete this product?")
// if (question){
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'removeProduct';
ajaxVar.vars['prodId'] = prodId;
ajaxVar.fnVars['divObj'] = divObj;
ajaxVar.gotoFunction = 'ShowRecentCart';
ajaxVar.AjaxPostSQL();
// }
}
function ShowRecentCart(dataArr, fnVars){
if(dataArr != 0){
var conArr = dataArr.split('#**#');
var rowKey = fnVars['divObj'].parentNode.parentNode.parentNode.rowIndex;
document.getElementById('cartListing').deleteRow(rowKey);
document.getElementById('cartListing').deleteRow(rowKey);
document.getElementById('grandTotal').innerHTML = '£'+ conArr[0];
document.getElementById('prodTotalCnt').innerHTML = conArr[1];
}else{
document.getElementById('prodTotalCnt').innerHTML = 0;
document.getElementById('cartListing').className = 'hiddendiv';
var divObj = document.createElement('div');
divObj.innerHTML = "There are currently no items in your shopping basket
";
shopDiv = document.getElementById('shoppingCartContent');
shopDiv.appendChild(divObj);
}
}
function ShowRecentCartData(dataArr, fnVars){
if(dataArr != 0){
var conArr = dataArr.split('#**#');
var rowKey = fnVars['divObj'].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.rowIndex;
document.getElementById('cartListing').deleteRow(rowKey);
document.getElementById('cartListing').deleteRow(rowKey);
document.getElementById('grandTotal').innerHTML = '£'+ conArr[0];
document.getElementById('prodTotalCnt').innerHTML = conArr[1];
}else{
document.getElementById('prodTotalCnt').innerHTML = 0;
document.getElementById('cartListing').className = 'hiddendiv';
var divObj = document.createElement('div');
divObj.innerHTML = "There are currently no items in your shopping basket
";
shopDiv = document.getElementById('shoppingCartContent');
shopDiv.appendChild(divObj);
}
}
function addQuantity(prodId){
var prodId = prodId.replace('plus','');
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'IncrementQuantity';
ajaxVar.vars['prodId'] = prodId;
ajaxVar.fnVars['prodId'] = prodId;
ajaxVar.gotoFunction = 'ChangeTotal';
ajaxVar.AjaxPostSQL();
}
function ChangeTotal(dataArr, fnVars){
var amtArr = dataArr.split('||**||');
document.getElementById('total_'+ fnVars['prodId']).innerHTML = '£'+ ThousandSeparator(2,amtArr[0]) +'
';
document.getElementById('quantity_'+ fnVars['prodId']).value = amtArr[1];
document.getElementById('grandTotal').innerHTML = '£'+ ThousandSeparator(2,amtArr[2]);
}
function reduceQuantity(prodId, divObj){
var prodId = prodId.replace('minus','');
var totQty = (document.getElementById('quantity_'+ prodId).value - 1);
if(totQty == 0){
//alert('Quantity cannot be less then 1');
//remove the product
var question = confirm("Are you sure you want to remove this product?");
if (question){
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'removeProduct';
ajaxVar.vars['prodId'] = prodId;
ajaxVar.fnVars['divObj'] = divObj;
ajaxVar.gotoFunction = 'ShowRecentCartData';
ajaxVar.AjaxPostSQL();
}
}else{
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'decrementQuantity';
ajaxVar.vars['prodId'] = prodId;
ajaxVar.fnVars['prodId'] = prodId;
ajaxVar.gotoFunction = 'ChangeTotal';
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'] = 'CartString';
ajaxVar.gotoFunction = 'ShowCart';
ajaxVar.AjaxPostSQL();
}
function showCartBox(){
opacity('cartBox', 0, 100, 100);
}
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);
var loaderDiv = document.getElementById('loader');
loaderDiv.className = 'hiddendiv';
var urlValue = location.href;
if(urlValue.indexOf("checkoutDetails.php") > 0){
showDetail();
}
}
function checkContentData(formN,objId,prodId,VarId){ //we need to get pass all the f
var ChkMand = inlineValidformNew(objId);
if(ChkMand == false){
return false;
}
var frmObj = eval("document." + formN);
var fnObj = eval("frmObj." + "first_name_" + objId );
var surObj = eval("frmObj." + "surname_" + objId );
var addObj = eval("frmObj." + "address_" + objId );
var pcObj = eval("frmObj." + "postcode_" + objId );
var telObj = eval("frmObj." + "telephone_" + objId );
var emailObj = eval("frmObj." + "email_" + objId );
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'sendQueryEmail';
ajaxVar.vars['mem_firstname'] = (fnObj)? fnObj.value : "";
ajaxVar.vars['mem_surname'] = (surObj)? surObj.value : "";
if (prodId > 0){
ajaxVar.vars['prodId'] = prodId;
}
if (VarId > 0){
ajaxVar.vars['VarId'] = VarId ;
}
ajaxVar.vars['mem_address'] = (addObj)? addObj.value : "";
ajaxVar.vars['mem_postcode'] = (pcObj)? pcObj.value : "";
ajaxVar.vars['mem_phone'] = (telObj)? telObj.value : "";
ajaxVar.vars['mem_email'] = (emailObj)? emailObj.value : "";
ajaxVar.fnVars['counter'] = objId;
ajaxVar.fnVars['formName'] = formN;
ajaxVar.gotoFunction = 'submitFrm';
ajaxVar.AjaxPostSQL();
}
function submitFrm(data,fnVars){
hideHelpDiv("sizeConId_" + fnVars['counter'] ,fnVars['counter']);
}
function addToCart(prodId, VarId, counter){
if(document.getElementById('var_size_'+ counter)){
if(document.getElementById('var_size_'+ counter).value == 0){
var errMsg;
if(document.getElementById('var_size_'+ counter).getAttribute('message')){
errMsg = document.getElementById('var_size_'+ counter).getAttribute('message');
}
document.getElementById('var_size_'+ counter).style.border = "1px solid #4C2E1B";
document.getElementById('var_size_'+ counter).focus();
removeInlineMessage();
showMessage(errMsg,parseInt(findPosX(document.getElementById('var_size_'+ counter)) + document.getElementById('var_size_'+ counter).offsetWidth),findPosY(document.getElementById('var_size_'+ counter)));
return false;
}
}
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['varId'] = VarId;
ajaxVar.fnVars['counter'] = counter;
if(document.getElementById('var_size_'+ counter)){
ajaxVar.vars['ringSize'] = document.getElementById('var_size_'+ counter).value;
}
ajaxVar.gotoFunction = 'ShowCart';
ajaxVar.AjaxPostSQL();
}
function formatUnits(str){
str = parseFloat(str) * 100;
str = Math.round(str) / 100;
return str.toFixed(2);
}
function showDetail(){
location.href = '/checkoutDetails.php';
}
function ThousandSeparator(decimalDigits,Value){
// Separator Length. Here this is thousand separator
var separatorLength = 3;
var OriginalValue=Value;
var TempValue = "" + OriginalValue;
var NewValue = "";
// Store digits after decimal
var pStr;
// store digits before decimal
var dStr;
// Add decimal point if it is not there
if (TempValue.indexOf(".")==-1){TempValue+="."}
dStr=TempValue.substr(0,TempValue.indexOf("."));
pStr=TempValue.substr(TempValue.indexOf("."))
// Add "0" for remaining digits after decimal point
while (pStr.length-1< decimalDigits){pStr+="0"}
if(pStr =='.') pStr ='';
if(dStr.length > separatorLength){
// Logic of separation
while( dStr.length > separatorLength){
NewValue = "," + dStr.substr(dStr.length - separatorLength) + NewValue;
dStr = dStr.substr(0,dStr.length - separatorLength);
}
NewValue = dStr + NewValue;
}else{
NewValue = dStr;
}
// Add decimal part
NewValue = NewValue + pStr;
// Show Final value
return(NewValue);
}
function ShowDivTag(){
var text = document.getElementById('mainImageCaption').value;
var divObj = document.getElementById('showTitleId');
divObj.style.visibility = 'visible';
divObj.style.display = 'block';
if(text.length>35){
text = text.substring(0,30);
text = text + " ..."
}
document.getElementById('titleContent').innerHTML = text;
}
function RemoveDivTag(){
var divObj = document.getElementById('showTitleId');
divObj.style.visibility = 'hidden';
divObj.style.display = 'none';
document.getElementById('titleContent').innerHTML = '';
}
function showVariantDetails(imageId){
var divObj = document.getElementById('basketDetailsId');
divObj.innerHTML = 'Loading data ...please wait';
divObj.style.height = '150px';
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'showVariantShop';
ajaxVar.vars['productId'] = document.getElementById('productId').value;
ajaxVar.vars['imageId'] = imageId;
ajaxVar.fnVars['productId'] = document.getElementById('productId').value;
ajaxVar.gotoFunction = 'showVariant';
ajaxVar.AjaxPostSQL();
}
function showVariantDetailsWishlist(imageId, productId){
var divObj = document.getElementById('basketDetailsId_' + productId);
divObj.innerHTML = 'Loading data ...please wait';
//divObj.style.height = '60px';
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'showVariantShop';
ajaxVar.vars['productId'] = productId;
ajaxVar.vars['imageId'] = imageId;
ajaxVar.fnVars['productId'] = productId;
ajaxVar.gotoFunction = 'showVariantWishList';
ajaxVar.AjaxPostSQL();
}
function showVariantWishList(dataArr, fnVars){
var varArr = dataArr.split('||**||');
if(varArr[0] == 'one'){
var divOthObj = document.getElementById('basketDetailsId_'+ fnVars['productId']);
divOthObj.style.height = '27px';
divOthObj.innerHTML = '';
addToCart(fnVars['productId'],varArr[1]);
}else if(varArr[0] != 'no'){
var tableContent = varArr[0];
var intIndexOfMatch = tableContent.indexOf( "##EQUAL##" );
// Loop over the string value replacing out each matching
// substring.
while (intIndexOfMatch != -1){
// Relace out the current instance.
tableContent = tableContent.replace( "##EQUAL##", "=" )
// Get the index of any next matching substring.
intIndexOfMatch = tableContent.indexOf( "##EQUAL##" );
}
var divObjImg = document.getElementById('baskettempId_'+ fnVars['productId']);
var divObj = document.getElementById('basketinfoId_'+ fnVars['productId']);
if(divObj.className == 'basketDiv'){
var topvalue = divObjImg.offsetTop - 27;
}else{
var topvalue = divObjImg.offsetTop - 20;
}
var LeftObj = document.getElementById('mainTable').offsetLeft + divObj.parentNode.offsetLeft;
divObj.innerHTML = "";
divObj.style.visibility = 'visible';
divObj.style.display = 'block';
divObj.className = 'basketDiv';
divObj.style.left = LeftObj;
divObj.style.top = topvalue + 'px';
divObj.innerHTML = tableContent;
var divOthObj = document.getElementById('basketDetailsId_'+ fnVars['productId']);
divOthObj.style.height = '27px';
divOthObj.innerHTML = '';
}else{
var divOthObj = document.getElementById('basketDetailsId_'+ fnVars['productId']);
divOthObj.style.height = '27px';
divOthObj.innerHTML = '';
alert('No variant has been defined for selected product');
return false;
}
}
function addSingleProduct(imageId){
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'getVarData';
ajaxVar.vars['productId'] = document.getElementById('productId').value;
ajaxVar.vars['imageId'] = imageId;
ajaxVar.fnVars['productId'] = document.getElementById('productId').value;
ajaxVar.gotoFunction = 'AddSingleVariant';
ajaxVar.AjaxPostSQL();
}
function addSingleProductWishList(imageId, productId){
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'getVarData';
ajaxVar.vars['productId'] = productId;
ajaxVar.vars['imageId'] = imageId;
ajaxVar.fnVars['productId'] = productId;
ajaxVar.gotoFunction = 'AddSingleVariant';
ajaxVar.AjaxPostSQL();
}
function AddSingleVariant(dataArr, fnVars){
var VarDatArr = dataArr.split('#**#');
addToCart(VarDatArr[0],VarDatArr[1],'0');
}
function showContactForm(){
var divObj = document.getElementById('basketDetailsId');
divObj.innerHTML = 'Loading data ...please wait';
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'showEmailFriendForm';
ajaxVar.vars['productId'] = document.getElementById('productId').value;
ajaxVar.fnVars['productId'] =document.getElementById('productId').value;
ajaxVar.gotoFunction = 'showEmailFrdForm';
ajaxVar.AjaxPostSQL();
}
function showEmailFrdForm(dataArr, fnVars){
var divObjOth = document.getElementById('basketDetailsId');
divObjOth.innerHTML = 'Loading data ...please wait';
var divObj = document.getElementById('basketinfoId');
var LeftObj = document.getElementById('mainTable').offsetLeft + divObj.parentNode.offsetLeft;
divObj.innerHTML = "";
divObj.style.visibility = 'visible';
divObj.style.display = 'block';
divObj.className = 'basketDiv';
divObj.style.left = LeftObj + 'px';
divObj.style.top = '209px';
//we need to call the php script here
var tableContent = dataArr;
var intIndexOfMatch = tableContent.indexOf( "##EQUAL##" );
// Loop over the string value replacing out each matching
// substring.
while (intIndexOfMatch != -1){
// Relace out the current instance.
tableContent = tableContent.replace( "##EQUAL##", "=" )
// Get the index of any next matching substring.
intIndexOfMatch = tableContent.indexOf( "##EQUAL##" );
}
divObj.innerHTML = tableContent;
divObjOth.style.height = '27px';
divObjOth.innerHTML = '';
}
function showVariant(dataArr, fnVars){
var varArr = dataArr.split('||**||');
if(varArr[0] == 'one'){
var divOthObj = document.getElementById('basketDetailsId');
divOthObj.style.height = '27px';
divOthObj.innerHTML = '';
addToCart(fnVars['productId'],varArr[1]);
}else if(varArr[0] != 'no'){
var tableContent = varArr[0];
var intIndexOfMatch = tableContent.indexOf( "##EQUAL##" );
// Loop over the string value replacing out each matching
// substring.
while (intIndexOfMatch != -1){
// Relace out the current instance.
tableContent = tableContent.replace( "##EQUAL##", "=" )
// Get the index of any next matching substring.
intIndexOfMatch = tableContent.indexOf( "##EQUAL##" );
}
var divObj = document.getElementById('basketinfoId');
var LeftObj = document.getElementById('mainTable').offsetLeft + divObj.parentNode.offsetLeft;
divObj.innerHTML = "";
divObj.style.visibility = 'visible';
divObj.style.display = 'block';
divObj.className = 'basketDiv';
divObj.style.left = LeftObj;
divObj.style.top = '209px';
divObj.innerHTML = tableContent;
//alert(tableContent);
var divOthObj = document.getElementById('basketDetailsId');
divOthObj.style.height = '27px';
divOthObj.innerHTML = '';
}else{
var divOthObj = document.getElementById('basketDetailsId');
divOthObj.style.height = '27px';
divOthObj.innerHTML = '';
alert('No variant has been defined for selected product');
return false;
//addToCart(fnVars['productId'],'0');
}
}
function hideBasketDiv(divid){
if(divid){
divobj = document.getElementById('basketinfoId_'+ divid);
if(!(divobj)){
divobj = document.getElementById('basketinfoId');
}
}else{
divobj = document.getElementById('basketinfoId');
}
if(divobj){
divobj.style.visibility = 'hidden';
divobj.style.display = 'none';
}
var bodyObj = document.getElementsByTagName("body")[0];
var divObj = document.getElementById('inlineMsg');
if(divObj){
bodyObj.removeChild(divObj);
}
}
function showProdBg(objId){
var divObj = document.getElementById('prod_'+ objId);
var imgObj = document.getElementById('prodImg_'+ objId);
var basObj = document.getElementById('addBas_'+ objId);
divObj.style.backgroundColor = '#dbdbdb';
imgObj.src = "images/overBas.gif";
basObj.style.visibility = "visible";
basObj.style.display = "block";
}
function normalProdBg(objId){
var divObj = document.getElementById('prod_'+ objId);
var imgObj = document.getElementById('prodImg_'+ objId);
var basObj = document.getElementById('addBas_'+ objId);
divObj.style.backgroundColor = '#ffffff';
imgObj.src = "images/basNor.gif";
basObj.style.visibility = "hidden";
basObj.style.display = "none";
}
function showBasketImage(){
var divObj = document.getElementById('basketDetailsId');
divObj.innerHTML = "";
divObj.innerHTML = '';
}
function ShowShippingDetails(){
frmObj = document.frmDetails;
divObj = document.getElementById('shippingAddDiv');
if(frmObj.copyBilling.checked == false){
divObj.className = 'visiblediv';
}else{
divObj.className = 'hiddendiv';
var bodyObj = document.getElementsByTagName("body")[0];
var divObj = document.getElementById('inlineMsg');
if(divObj){
bodyObj.removeChild(divObj);
}
}
}
function changeImage(obj){
obj.src = "images/cartover.jpg";
}
function orgiImage(obj){
obj.src = "images/removeImg.jpg";
}
function submitInfo(frmName){
var ChkMand = inlineValidform(frmName);
if(ChkMand == true){
var frmObj = document.prodContact;
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'InsertContent';
ajaxVar.vars['mem_firstname'] = frmObj.mem_firstname.value;
ajaxVar.vars['mem_surname'] = frmObj.mem_surname.value;
ajaxVar.vars['mem_email'] = frmObj.mem_email.value;
ajaxVar.vars['mem_phone'] = frmObj.mem_phone.value;
ajaxVar.vars['prodId'] = frmObj.prodId.value;
ajaxVar.fnVars['prodId'] = frmObj.prodId.value;
ajaxVar.gotoFunction = 'ShowSuccMessage';
ajaxVar.AjaxPostSQL();
}
}
function submitInfoWish(frmName, prodId){
var ChkMand = inlineValidform(frmName);
if(ChkMand == true){
var frmObj = eval('document.prodContact_'+ prodId);
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'InsertContent';
ajaxVar.vars['mem_firstname'] = frmObj.mem_firstname.value;
ajaxVar.vars['mem_surname'] = frmObj.mem_surname.value;
ajaxVar.vars['mem_email'] = frmObj.mem_email.value;
ajaxVar.vars['mem_phone'] = frmObj.mem_phone.value;
ajaxVar.vars['prodId'] = frmObj.prodId.value;
ajaxVar.fnVars['prodId'] = frmObj.prodId.value;
ajaxVar.gotoFunction = 'ShowSuccMessage';
ajaxVar.AjaxPostSQL();
}
}
function ShowSuccMessage(dataArr, fnVars){
if(dataArr == 1){
var bodyObj = document.getElementsByTagName("body")[0];
var divObj = document.getElementById('inlineMsg');
if(divObj){
bodyObj.removeChild(divObj);
}
successMessageProduct(fnVars['prodId']);
//hideBasketDiv(fnVars['prodId']);
//alert('Your details have been emailed successfully');
}
}
function successMessageProduct(prodId){
if(prodId){
var divObj = document.getElementById('basketinfoId_'+ prodId);
var divObjImg = document.getElementById('baskettempId_'+ prodId);
if(!divObj){
var divObj = document.getElementById('basketinfoId');
}
}else{
var divObj = document.getElementById('basketinfoId');
}
if(divObjImg){
if(divObj.className == 'basketDiv'){
var topvalue = divObjImg.offsetTop - 27;
}else{
var topvalue = divObjImg.offsetTop - 20;
}
}else{
var topvalue = 209;
}
var LeftObj = document.getElementById('mainTable').offsetLeft + divObj.parentNode.offsetLeft;
divObj.innerHTML = "";
divObj.style.visibility = 'visible';
divObj.style.display = 'block';
divObj.className = 'basketDiv';
divObj.style.left = LeftObj;
divObj.style.top = topvalue + 'px';
var tbl = document.createElement("table");
tbl.id = 'contcontent';
tbl.width = 412;
tbl.cellPadding = 0;
tbl.cellSpacing = 0;
var tblBody = document.createElement("tbody");
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.innerHTML = '';
row.appendChild(cell);
var cell = document.createElement("td");
cell.className = 'bastopBorder basBg';
cell.innerHTML = '';
row.appendChild(cell);
var cell = document.createElement("td");
cell.className = 'bastopBorder basBg';
cell.innerHTML = '';
row.appendChild(cell);
var cell = document.createElement("td");
cell.innerHTML = '';
row.appendChild(cell);
tblBody.appendChild(row);
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.className = 'basBg lbasBorder rbasBorder txtInfoPad';
cell.colSpan = 4;
cell.innerHTML = 'Unfortunately we do not sell this item through our online shop. Please send us your details and we will contact you about buying this item.';
row.appendChild(cell);
tblBody.appendChild(row);
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.className = 'basBg lbasBorder rbasBorder txtInfoPad';
cell.style.color = '#ff0000';
cell.colSpan = 4;
cell.innerHTML = 'Your details have been emailed successfully';
row.appendChild(cell);
tblBody.appendChild(row);
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.innerHTML = '';
row.appendChild(cell);
var cell = document.createElement("td");
cell.className = 'basbotBorder basBg';
cell.colSpan =2;
cell.innerHTML = '';
row.appendChild(cell);
var cell = document.createElement("td");
cell.innerHTML = '';
row.appendChild(cell);
tblBody.appendChild(row);
tbl.appendChild(tblBody);
divObj.appendChild(tbl);
}
function display_prices(pricecopy){
var privesDiv = document.getElementById('variant_prices');
if (privesDiv){
privesDiv.innerHTML = pricecopy;
privesDiv.style.visibility = 'visible';
privesDiv.style.display = 'block';
}
}
function display_pricesBlank(){
var privesDiv = document.getElementById('variant_prices');
if (privesDiv){
privesDiv.innerHTML = '';
privesDiv.style.visibility = 'hidden';
privesDiv.style.display = 'block';
}
}
function checkVariant(imgId){
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'checkVariantAvail';
ajaxVar.vars['imageId'] = imgId;
ajaxVar.gotoFunction = 'showCartButton';
ajaxVar.AjaxPostSQL();
}
function showCartButton(dataArr, fnVars){
var cartDivId = document.getElementById('basketDetailsId');
if(dataArr == 1){ //variants are available
cartDivId.style.visibility = 'visible';
cartDivId.style.display = 'block';
}else{
cartDivId.style.visibility = 'hidden';
cartDivId.style.display = 'none';
}
}
function showEmailForm(){
var divObjOth = document.getElementById('emaildetailscontent');
divObjOth.innerHTML = 'Loading data ...please wait';
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'showEmailForm';
ajaxVar.vars['productId'] = document.getElementById('productId').value;;
ajaxVar.fnVars['productId'] = document.getElementById('productId').value;;
ajaxVar.gotoFunction = 'showEmlForm';
ajaxVar.AjaxPostSQL();
}
function showEmlForm(dataArr, fnVars){
var divObjOth = document.getElementById('emaildetailscontent');
divObjOth.innerHTML = 'Loading data ...please wait';
var divObj = document.getElementById('emailinfoId');
var LeftObj = document.getElementById('mainTable').offsetLeft + divObj.parentNode.offsetLeft;
divObj.innerHTML = "";
divObj.style.visibility = 'visible';
divObj.style.display = 'block';
divObj.className = 'basketDiv';
divObj.style.left = LeftObj + 'px';
divObj.style.top = '179px';
//we need to call the php script here
var tableContent = dataArr;
var intIndexOfMatch = tableContent.indexOf( "##EQUAL##" );
// Loop over the string value replacing out each matching
// substring.
while (intIndexOfMatch != -1){
// Relace out the current instance.
tableContent = tableContent.replace( "##EQUAL##", "=" )
// Get the index of any next matching substring.
intIndexOfMatch = tableContent.indexOf( "##EQUAL##" );
}
//alert(tableContent);
divObj.innerHTML = tableContent;
divObjOth.style.height = '27px';
divObjOth.innerHTML = '';
}
function submitEmailInfo(frmName){
var ChkMand = inlineValidform(frmName);
if(ChkMand == true){
var frmObj = document.prodemailfriend;
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'InsertEmailContent';
ajaxVar.vars['your_name'] = frmObj.your_name.value;
ajaxVar.vars['your_email'] = frmObj.your_email.value;
ajaxVar.vars['friend_name'] = frmObj.friend_name.value;
ajaxVar.vars['friend_email'] = frmObj.friend_email.value;
ajaxVar.vars['message'] = frmObj.message.value;
ajaxVar.vars['prodId'] = frmObj.prodId.value;
ajaxVar.gotoFunction = 'ShowSuccMessageEmail';
ajaxVar.AjaxPostSQL();
}
}
function ShowSuccMessageEmail(dataArr, fnVars){
if(dataArr == 1){
var bodyObj = document.getElementsByTagName("body")[0];
var divObj = document.getElementById('inlineMsg');
if(divObj){
bodyObj.removeChild(divObj);
}
var divObj = document.getElementById('emailinfoId');
var LeftObj = document.getElementById('mainTable').offsetLeft + divObj.parentNode.offsetLeft;
divObj.innerHTML = "";
divObj.style.visibility = 'visible';
divObj.style.display = 'block';
divObj.className = 'basketDiv';
divObj.style.left = LeftObj;
divObj.style.top = '179px';
var tbl = document.createElement("table");
tbl.id = 'contcontent';
tbl.width = 412;
tbl.cellPadding = 0;
tbl.cellSpacing = 0;
var tblBody = document.createElement("tbody");
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.innerHTML = '';
row.appendChild(cell);
var cell = document.createElement("td");
cell.className = 'bastopBorder basBg';
cell.width = '382';
cell.innerHTML = '';
row.appendChild(cell);
var cell = document.createElement("td");
cell.className = 'bastopBorder basBg';
cell.innerHTML = '';
row.appendChild(cell);
var cell = document.createElement("td");
cell.innerHTML = '';
row.appendChild(cell);
tblBody.appendChild(row);
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.className = 'basBg lbasBorder rbasBorder txtInfoPad';
cell.colSpan = 4;
cell.innerHTML = ' ';
row.appendChild(cell);
tblBody.appendChild(row);
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.className = 'basBg lbasBorder rbasBorder txtInfoPad errclr';
cell.colSpan = 4;
cell.innerHTML = 'An email has been send to your friend email address with the product link.';
row.appendChild(cell);
tblBody.appendChild(row);
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.className = 'basBg lbasBorder rbasBorder txtInfoPad';
cell.colSpan = 4;
cell.innerHTML = ' ';
row.appendChild(cell);
tblBody.appendChild(row);
var row = document.createElement("tr");
var cell = document.createElement("td");
cell.innerHTML = '';
row.appendChild(cell);
var cell = document.createElement("td");
cell.className = 'basbotBorder basBg';
cell.colSpan =2;
cell.innerHTML = '';
row.appendChild(cell);
var cell = document.createElement("td");
cell.innerHTML = '';
row.appendChild(cell);
tblBody.appendChild(row);
tbl.appendChild(tblBody);
divObj.appendChild(tbl);
}
}
function hideEmailDiv(){
divobj = document.getElementById('emailinfoId');
if(divobj){
divobj.style.visibility = 'hidden';
divobj.style.display = 'none';
}
var bodyObj = document.getElementsByTagName("body")[0];
var divObj = document.getElementById('inlineMsg');
if(divObj){
bodyObj.removeChild(divObj);
}
}
function showContactFormWishList(productId){
var divObj = document.getElementById('basketDetailsId_'+productId);
divObj.innerHTML = 'Loading data ...please wait';
var ajaxVar = new ajaxVars();
ajaxVar.vars['action'] = "runFunction";
ajaxVar.vars['func'] = 'showOrderForm';
ajaxVar.vars['productId'] = productId;
ajaxVar.fnVars['productId'] = productId;
ajaxVar.gotoFunction = 'showConWishForm';
ajaxVar.AjaxPostSQL();
}
function showConWishForm(dataArr, fnVars){
var divObj = document.getElementById('basketinfoId_'+ fnVars['productId']);
var divObjImg = document.getElementById('baskettempId_'+ fnVars['productId']);
if(divObj.className == 'basketDiv'){
var topvalue = divObjImg.offsetTop - 27;
}else{
var topvalue = divObjImg.offsetTop - 20;
}
var LeftObj = document.getElementById('mainTable').offsetLeft + divObj.parentNode.offsetLeft;
divObj.innerHTML = "";
divObj.style.visibility = 'visible';
divObj.style.display = 'block';
divObj.className = 'basketDiv';
divObj.style.left = LeftObj + 'px';
divObj.style.top = topvalue + 'px';
//we need to call the php script here
var tableContent = dataArr;
var intIndexOfMatch = tableContent.indexOf( "##EQUAL##" );
// Loop over the string value replacing out each matching
// substring.
while (intIndexOfMatch != -1){
// Relace out the current instance.
tableContent = tableContent.replace( "##EQUAL##", "=" )
// Get the index of any next matching substring.
intIndexOfMatch = tableContent.indexOf( "##EQUAL##" );
}
//alert(tableContent);
divObj.innerHTML = tableContent;
var divOthObj = document.getElementById('basketDetailsId_'+fnVars['productId']);
divOthObj.style.height = '27px';
divOthObj.innerHTML = '';
}