function changeOpac(opacity, obj) { obj.style.opacity = (opacity / 100); obj.style.MozOpacity = (opacity / 100); obj.style.KhtmlOpacity = (opacity / 100); obj.style.filter = "alpha(opacity=" + opacity + ")"; } function showHideDiv(id, status){ var divObj = document.getElementById(id); if(status) { divObj.style.visibility = "visible"; divObj.style.display = "block"; }else{ divObj.style.visibility = "hidden"; divObj.style.display = "none"; } } function checkNum(Obj){ if(isNaN(Obj.value)) { Obj.value = 20; } } function order(field, url){ url += "?"; url += "&order=" + field; location.href = url; } function changeOrder(idObj, move){ id = idObj.id.replace('a_', ''); var vals = id.split('_'); switch(move) { case "down": var nextOrder = parseInt(vals[vals.length - 1], 10); nextOrder++; var upperDivId = 'div_' + vals[0] + '_' + vals[1]; var lowerDivId = 'div_' + vals[0] + '_' + nextOrder; break; case "up": var prevOrder = parseInt(vals[vals.length - 1], 10); prevOrder--; var upperDivId = 'div_' + vals[0] + '_' + prevOrder; var lowerDivId = 'div_' + vals[0] + '_' + vals[1]; break; } var upperdivObj = document.getElementById(upperDivId); var lowerdivObj = document.getElementById(lowerDivId); if(upperdivObj) { var upperHTML = lowerdivObj.innerHTML;} if(lowerdivObj) { var lowerHTML = upperdivObj.innerHTML; } if(upperdivObj) { upperdivObj.innerHTML = upperHTML; } if(lowerdivObj) { lowerdivObj.innerHTML = lowerHTML; } } function openBrowse(check, divId) { divObj = document.getElementById('tbl_' + divId); fileObj = document.getElementById('imagefile_' + divId); if(check.checked) { divObj.style.visibility = "visible"; }else{ divObj.style.visibility = "hidden"; fileObj.value = ''; } } function changeOpac(opacity, obj) { obj.style.opacity = (opacity / 100); obj.style.MozOpacity = (opacity / 100); obj.style.KhtmlOpacity = (opacity / 100); obj.style.filter = "alpha(opacity=" + opacity + ")"; } function update_preview(obj, img_no, img_width, img_height) { // Delete off earlier cropping parameters. This is incase cropping values are saved // and then another image is uploaded store_coords(img_no, 1); div_obj = document.getElementById('previewimg_' + img_no); // Remove the old preview image if any if(div_obj.childNodes.length > 0) { div_obj.removeChild(div_obj.firstChild); } preview_img = new Image(); preview_img.src = obj.value; preview_img.name = "preview_image"; if (browser.isNS) preview_img.src = "file:///" + escape(preview_img.src.replace(/\\/g, "/")); org_width = preview_img.width; org_height = preview_img.height; // Check if image is smaller than prescribed width or height if(preview_img.width < img_width || preview_img.height < img_height) { return; } // find the ratio to understand we need to resize on width or height var previewratio = preview_img.width/preview_img.height; var imgratio = img_width/img_height; if (previewratio < imgratio) { // this means width is less derived_height = (img_width/preview_img.width)*preview_img.height; derived_height = parseInt(derived_height, 10); preview_img.height = derived_height; preview_img.style.height = derived_height; preview_img.width = img_width; preview_img.style.width = img_width; } else { // Get the derived width derived_width = (img_height/preview_img.height)*preview_img.width; derived_width = parseInt(derived_width, 10); preview_img.width = derived_width; preview_img.style.width = derived_width; preview_img.height = img_height; preview_img.style.height = img_height; } document.getElementById('previewtext_' + img_no).style.width = preview_img.width; // Set the scale factors vis-a-vis original and preview image. This is to scale the x and y positions before form submission document.getElementById('scalex_' + img_no).value = org_width/preview_img.width; document.getElementById('scaley_' + img_no).value = org_height/preview_img.height; // Make preview image visible document.getElementById('preview_' + img_no).style.visibility = "visible"; document.getElementById('preview_' + img_no).style.display = "block"; document.getElementById('previewimg_' + img_no).style.visibility = "visible"; document.getElementById('previewimg_' + img_no).style.display = "block"; div_obj.appendChild(preview_img); //div_obj.insertBefore(preview_img,div_obj.firstChild); // Make cropper tool visible. Put same image in cropper tool also div_obj = document.getElementById('cropbox_' + img_no); div_obj.style.visibility = "visible"; div_obj.style.display = "block"; div_obj.style.overflow = "hidden"; div_obj.innerHTML = ""; div_obj.style.left = findPosX(document.getElementById('previewimg_' + img_no)); div_obj.style.top = findPosY(document.getElementById('previewimg_' + img_no)); changeOpac(40, preview_img); } var browser = new Browser(); var dragObj = new Object(); var DivWidth = 380; var dragFlag = false; var dragStartFlag = false; function Browser() { var ua, s, i; this.isIE = false; this.isNS = false; this.version = null; ua = navigator.userAgent; s = "MSIE"; if ((i = ua.indexOf(s)) >= 0) { this.isIE = true; this.version = parseFloat(ua.substr(i + s.length)); return; } s = "Netscape6/"; if ((i = ua.indexOf(s)) >= 0) { this.isNS = true; this.version = parseFloat(ua.substr(i + s.length)); return; } s = "Gecko"; if ((i = ua.indexOf(s)) >= 0) { this.isNS = true; this.version = 6.1; return; } } function crop_dragStart(event, id) { current_image_crop_id = "previewimg" + id.substring(7,(id.length)); current_id = id.substring(7,(id.length)); if((dragStartFlag == false) && (dragFlag == false)) { dragStartFlag = true; var el; var x, y; if (id) { dragObj.elNode = document.getElementById(id); }else { if (browser.isIE) dragObj.elNode = window.event.srcElement; if (browser.isNS) dragObj.elNode = event.target; if (dragObj.elNode.nodeType == 3) dragObj.elNode = dragObj.elNode.parentNode; } if (browser.isIE) { x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft; y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop; } if (browser.isNS) { x = event.clientX + window.scrollX; y = event.clientY + window.scrollY; } dragObj.cursorStartX = x; dragObj.cursorStartY = y; dragObj.elStartLeft = parseInt(dragObj.elNode.style.left, 10); dragObj.elStartTop = parseInt(dragObj.elNode.style.top, 10); if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0; if (isNaN(dragObj.elStartTop)) dragObj.elStartTop = 0; dragObj.elNode.style.zIndex = ++dragObj.zIndex; if (browser.isIE) { document.attachEvent("onmousemove", crop_dragGo); document.attachEvent("onmouseup", crop_dragStop); window.event.cancelBubble = true; window.event.returnValue = false; } if (browser.isNS) { document.addEventListener("mousemove", crop_dragGo, true); document.addEventListener("mouseup", crop_dragStop, true); event.preventDefault(); } } } function crop_dragGo(event) { var x, y; if (browser.isIE) { x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft; y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop; } if (browser.isNS) { x = event.clientX + window.scrollX; y = event.clientY + window.scrollY; } var current_drag_point_x = (dragObj.elStartLeft + x - dragObj.cursorStartX); var current_preview_image_x = findPosX(document.getElementById(current_image_crop_id)); var current_drag_point_y = (dragObj.elStartTop + y - dragObj.cursorStartY); var current_preview_image_y = findPosY(document.getElementById(current_image_crop_id)); var current_preview_image_width = preview_img.width; //document.getElementById('updatemsg').innerHTML = (current_drag_point_x + ", " + current_preview_image_x + "," + current_preview_image_width); if ( current_drag_point_x < current_preview_image_x) { dragObj.elNode.style.left = current_preview_image_x + "px"; } else if (current_drag_point_x >= (current_preview_image_x + current_preview_image_width - dragObj.elNode.offsetWidth)) { dragObj.elNode.style.left = current_preview_image_x + current_preview_image_width - dragObj.elNode.offsetWidth; } else { dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px"; } if ((dragObj.elStartTop + y - dragObj.cursorStartY) <= findPosY(document.getElementById(current_image_crop_id))) { dragObj.elNode.style.top = findPosY(document.getElementById(current_image_crop_id)) + "px"; } else if ((dragObj.elStartTop + y - dragObj.cursorStartY) >= (findPosY(document.getElementById(current_image_crop_id)) + document.getElementById(current_image_crop_id).offsetHeight) - dragObj.elNode.offsetHeight) { dragObj.elNode.style.top = (findPosY(document.getElementById(current_image_crop_id)) + document.getElementById(current_image_crop_id).offsetHeight - dragObj.elNode.offsetHeight); } else { dragObj.elNode.style.top = (dragObj.elStartTop + y - dragObj.cursorStartY) + "px"; } img_obj = document.getElementById('crop_img'); cur_left = dragObj.elNode.style.left.replace("px", ""); cur_left = parseInt(cur_left, 10); cur_left = parseInt(current_preview_image_x) - cur_left; cur_top = dragObj.elNode.style.top.replace("px", ""); cur_top = parseInt(cur_top, 10); cur_top = parseInt(current_preview_image_y) - cur_top; img_obj.style.marginLeft = cur_left + "px"; img_obj.style.marginTop = cur_top + "px"; if (browser.isIE) { window.event.cancelBubble = true; window.event.returnValue = false; } if (browser.isNS) event.preventDefault(); } function crop_dragStop(event) { dragStartFlag = false; if (browser.isIE) { document.detachEvent("onmousemove", crop_dragGo); document.detachEvent("onmouseup", crop_dragStop); } if (browser.isNS) { document.removeEventListener("mousemove", crop_dragGo, true); document.removeEventListener("mouseup", crop_dragStop, true); } } function store_coords(ref_no, reset) { if(reset == 1) { document.getElementById('x_' + ref_no).value = ''; document.getElementById('y_' + ref_no).value = ''; return; } cropObj = document.getElementById('cropbox_' + ref_no); preObj = document.getElementById('previewimg_' + ref_no); x_position = (findPosX(cropObj) - findPosX(preObj))*document.getElementById('scalex_' + ref_no).value; y_position = (findPosY(cropObj) - findPosY(preObj) - 0)*document.getElementById('scaley_' + ref_no).value; document.getElementById('x_' + ref_no).value = parseInt(x_position, 10); document.getElementById('y_' + ref_no).value = parseInt(y_position, 10); hide_preview(ref_no); } function hide_preview(ref_no) { cropObj = document.getElementById('cropbox_' + ref_no); preObj = document.getElementById('preview_' + ref_no); // Close the preview window cropObj.style.visibility = "hidden"; cropObj.style.display = "none"; preObj.style.visibility = "hidden"; preObj.style.display = "none"; // reset the x and y co-ordinates to '' so that it does not crop } function unset_coords(ref_no) { document.getElementById('x_' + ref_no).value = ''; document.getElementById('y_' + ref_no).value = ''; hide_preview(ref_no); } function findPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft obj = obj.offsetParent; } } else if (obj.x) { curleft += obj.x; } return curleft; } function findPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curtop += obj.offsetTop obj = obj.offsetParent; } } else if (obj.y) { curtop += obj.y; } return curtop; } // function creates a tr object and sends it back function add_table_row(highlight, grid_type) { tr_obj = document.createElement("tr"); tr_obj.grid_type = grid_type; table_rows++; return tr_obj; } // function creates a tb object, fills the data and appends it to the tr object function add_table_cell(tr_obj, data, header_row, id, grid_type) { td_obj = document.createElement("td"); td_obj.height = 15; td_obj.id = id; td_obj.vAlign = 'top'; td_obj.style.fontSize = '11px'; td_obj.style.borderRight = '0.01cm solid #888888'; td_obj.style.borderBottom = '0.01cm solid #888888'; if(!header_row) { // Put double click only for non header rows if(grid_type.indexOf('project') >=0) { td_obj.ondblclick = function(evt) { var dummyObj = document.getElementById('dummy_' + id); dummyObj.style.visibility = "hidden"; dummyObj.style.display = "none"; view_stages(this.id); }; } } td_obj.innerHTML = data; tr_obj.appendChild(td_obj); return td_obj; } function general_grid(data,fnVars) { rec_id = new Array(); grid_obj=fnVars['grid_obj']; //id of the record is stored // Get table corresponding to the open form colheader = new Array("Product Name","Product Id","Price","Offer"); table_obj = document.getElementById(grid_obj); // Remove existing tbody entries. The assumption here is that if you remove the node tbody it will delete tr // and td as well. If not, then we first need to remove td, then tr and then tbody if(table_obj) { for(i=1;i=0){ newSrc = "/proimages/lessBtn.gif"; }else{ newSrc = "/proimages/moreBtn.gif"; } document.getElementById(imgId).src = newSrc; animatedcollapse.toggle(divid); } function ShowHelp(imgID, title, desc){ imgObj = document.getElementById(imgID); var divToolTipObj = document.getElementById('toolTipCont'); var topImg = document.getElementById('toolTipImgTop'); var bottomImg = document.getElementById('toolTipImgBottom'); var MainContObj = document.getElementById('eleCont'); var posX = findPosX(imgObj); var posY = findPosY(imgObj); if(parseInt(screen.width-posX) < 275){ document.getElementById('toolTipTable').width = (screen.width-posX - 75) + 'px'; topImg.width = (screen.width-posX - 75); bottomImg.width = (screen.width-posX - 75); }else{ document.getElementById('toolTipTable').style.width = "138px"; } divToolTipObj.style.visibility = 'visible'; divToolTipObj.style.display = 'block'; divToolTipObj.style.left = parseInt(posX + 38) + 'px' divToolTipObj.style.top = (posY - 8) + 'px' MainContObj.innerHTML = desc; } function HideHelp(div){ var divToolTipObj = document.getElementById('toolTipCont'); divToolTipObj.style.visibility = 'hidden'; divToolTipObj.style.display = 'none'; } function createHintTable(){ var divObj = document.getElementById('toolTipCont'); var tblObj = document.createElement('TABLE'); tblObj.cellSpacing="0"; tblObj.cellPadding="0"; tblObj.width="138"; tblObj.border="0"; tblObj.id="toolTipTable"; var tblBody = document.createElement('TBODY'); tblObj.appendChild(tblBody); //1st Row var rowObj = tblBody.insertRow(0); var colObj = rowObj.insertCell(0); colObj.width="5"; colObj.innerHTML = "\"\""; rowObj.appendChild(colObj); var colObj = rowObj.insertCell(1); colObj.width= "100%"; colObj.innerHTML = "\"\""; rowObj.appendChild(colObj); tblBody.appendChild(rowObj); //2nd row var rowObj = tblBody.insertRow(1); var colObj = rowObj.insertCell(0); colObj.vAlign="top" colObj.innerHTML = "\"\""; rowObj.appendChild(colObj); var colObj = rowObj.insertCell(1); colObj.width="100%"; colObj.valign = "top"; colObj.style.backgroundColor = '#5080c1'; var tmpStr = ""; tmpStr+= ""; tmpStr+= ""; tmpStr+= ""; tmpStr+= ""; tmpStr+= ""; tmpStr+= "
\"\"\"\"
"; colObj.innerHTML = tmpStr; rowObj.appendChild(colObj); tblBody.appendChild(rowObj); //3rd Row var rowObj = tblBody.insertRow(2); var colObj = rowObj.insertCell(0); colObj.width="5"; colObj.innerHTML = "\"\""; rowObj.appendChild(colObj); var colObj = rowObj.insertCell(1); colObj.width="100%"; colObj.innerHTML = "\"\""; rowObj.appendChild(colObj); tblBody.appendChild(rowObj); divObj.appendChild(tblObj); } function addDelItem(fnName,id){ var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'db_fetch_array'; ajaxVar.vars['sql_type'] = "select"; ajaxVar.vars['sql_what'] = "id,availability,price "; ajaxVar.vars['sql_from'] = "products"; ajaxVar.vars['sql_where'] = "id='" + id + "'"; ajaxVar.fnVars['id'] = id; ajaxVar.fnVars['fnName'] = fnName; ajaxVar.gotoFunction = 'checkAvailability'; ajaxVar.AjaxPostSQL(); } function checkAvailability(dataArr, fnVars){ var lessObj = document.getElementById('prodQty_' + fnVars['id']).innerHTML; var msgdiv = document.getElementById('itemMsg'); if(fnVars['fnName'] == "decItem"){ if(lessObj>1){ lessObj--; document.getElementById('prodQty_' + fnVars['id']).innerHTML = lessObj; document.getElementById('total_' + fnVars['id']).innerHTML = number_format((lessObj * dataArr['price']), 2); }else{ // alert("Already reached to 0."); msgdiv.innerHTML = "Already reached to 0."; } }else if(fnVars['fnName'] == "delItem"){ alert("Delete from the cart"); }else if(fnVars['fnName'] == "incItem"){ if(lessObj < dataArr['availability']){ lessObj++; document.getElementById('prodQty_' + fnVars['id']).innerHTML = lessObj; }else{ // alert("Already reached to max quantity."); msgdiv.innerHTML = "Already reached to max quantity."; } } var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = fnVars['fnName']; ajaxVar.vars["args"] = fnVars['id']; ajaxVar.gotoFunction = "showCart"; ajaxVar.AjaxPostSQL(); } function showCart(dataArr, fnVars){ // alert(fnVars); } function showDiv(divId){ var divCartObj = document.getElementById(divId); divCartObj.className = "showDiv"; } function number_format( number, decimals, dec_point, thousands_sep ) { var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals; var d = dec_point == undefined ? "." : dec_point; var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : ""; var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); } function showOfferCap(id){ var divObj = document.getElementById('offerCap'); if(id == 1){ divObj.innerHTML = "Offer percentage"; }else{ divObj.innerHTML = "Offer amount(£)"; } } function showLoginBox(divId){ var ajaxVar = new ajaxVars(); ajaxVar.vars["action"] = "runFunction"; ajaxVar.vars["func"] = "showLoginBox"; ajaxVar.fnVars['divId'] = divId; ajaxVar.gotoFunction = "dispLogin"; ajaxVar.AjaxPostSQL(); } function dispLogin(dataArr, fnVars){ var divId = fnVars['divId']; document.getElementById(divId).innerHTML = dataArr; } function checkLogin(){ var objVar = new getVars(); objVar.fieldN[0] = "uemail"; objVar.fieldV[0] = "Email "; objVar.fieldT[0] = "text"; objVar.fieldI[0] = "uemail"; objVar.fieldN[1] = "passwd"; objVar.fieldV[1] = "Password "; objVar.fieldT[1] = "text"; objVar.fieldI[1] = "passwd"; if(checkEmpty('loginFrm', objVar)){ return authenticate(); }else{ return false; } } function forgotPassBlock(){ var loginObj = document.getElementById('loginBox'); var forgotPassObj = document.getElementById('forgotPassBox'); loginObj.style.visibility = "hidden"; loginObj.style.display = "none"; forgotPassObj.style.visibility = "visible"; forgotPassObj.style.display = "block"; } function checkForgotPass(){ var frmObj = document.forgotPass; var errmsg = ""; if(frmObj.email.value==""){ errmsg += "Email\n"; }else if (!checkEmail(frmObj.email.value)){ errmsg += "Email (Invalid Email Id)\n"; } if(errmsg){ msg = "Following fields are empty or not entered correctly:"; alert(msg + '\n\n' + errmsg); }else{ sendmail(); } return false; } function sendmail(){ var frmObj = document.forgotPass; var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = "runFunction"; ajaxVar.vars['func'] = "forgot_password"; ajaxVar.vars['to'] = frmObj.email.value; ajaxVar.gotoFunction = 'showmailResponse'; ajaxVar.incModule = "ax/sendforgotPassEmail.php"; ajaxVar.AjaxPostSQL(); } function showmailResponse(data){ var divObj = document.getElementById('passerr'); divObj.innerHTML = data; } function closeforgotPassBlock(){ var loginObj = document.getElementById('loginBox'); var forgotPassObj = document.getElementById('forgotPassBox'); forgotPassObj.style.visibility='hidden'; forgotPassObj.style.display='none'; loginObj.style.visibility = "visible"; loginObj.style.display = "block"; return false; } function authenticate(){ var ajaxVar = new ajaxVars(); ajaxVar.vars["action"] = "runFunction"; ajaxVar.vars["func"] = "authenticate"; ajaxVar.vars['uemail'] = document.getElementById('uemail').value; ajaxVar.vars['passwd'] = document.getElementById('passwd').value; ajaxVar.vars['remember'] = (document.getElementById('remember').checked==true)? 1:0; ajaxVar.gotoFunction = "authResult"; ajaxVar.AjaxPostSQL(); } function authResult(data){ var newData = data.split('###'); if(newData[0]=='cookie' && newData[1]){ createCookie('cookie_flogin_id',"",-1); createCookie('cookie_flogin_id',newData[1],'30'); location.href = '/logged-in/'; }else if(newData[0]=='Success'){ location.href = '/logged-in/'; }else{ var errDiv = document.getElementById('autherr'); errDiv.innerHTML = newData[0]; } } function logout(){ var ajaxVar = new ajaxVars(); ajaxVar.vars["action"] = "runFunction"; ajaxVar.vars["func"] = "logoutUser"; ajaxVar.gotoFunction = "successLogout"; ajaxVar.AjaxPostSQL(); } function successLogout(){ // showLoginBox('logContainer'); location.href = '/registration/'; } function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(3600)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function adjustDataBox(key,no){ var maxHeight=0; for(var i=1;i<=no;i++){ var divObj = document.getElementById(key+i); if(divObj.offsetHeight > maxHeight){ maxHeight = divObj.offsetHeight; } } for(var i=1;i<=no;i++){ var divObj = document.getElementById(key+i); divObj.style.height = maxHeight + 'px'; } } function questionDiv(index,value){ var divObj = document.getElementById('qDiv'); var userType = document.getElementById('user_type_hidden').value; divObj.className = divObj.className.replace(/hideDiv/g,'showDiv'); var nodeList = divObj.getElementsByTagName('DIV')[0].getElementsByTagName('DIV'); var iLen = nodeList.length; var textObj = document.getElementById('user_answer'); if(userType!=value){ if(!textObj.oldVal){ textObj.oldVal = textObj.value; } textObj.value = ""; }else{ if(textObj.oldVal){ textObj.value = textObj.oldVal; } } for(var i=0;i