﻿
//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;

var popupStatus = 0;

//loading popup with jQuery magic!
module_pos_id=0;
function loadPopup(mod_id){
	module_pos_id=mod_id;
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup" + mod_id).css({
			"opacity": "0.7"
		});
		$("#backgroundPopup" + mod_id).fadeIn("slow");
		$("#popupContact" + mod_id).fadeIn("slow");
		popupStatus = 1;
	}
}


function setLandingPageBanners() {
	if(document.location.href.indexOf("premium/")>0){ document.getElementById("dynamic_class").className = "premium_wrapper";}
	if(document.location.href.indexOf("cms/")>0){ document.getElementById("dynamic_class").className = "cms_wrapper";}
        if(document.location.href.indexOf("enterprise/")>0){ document.getElementById("dynamic_class").className = "shop_enter_wrapper";}
	if(document.location.href.indexOf("replicator/")>0){ document.getElementById("dynamic_class").className = "replicator_wrapper";}
        if(document.location.href.indexOf("portal")>0){ document.getElementById("dynamic_class").className = "portal_wrapper";}
        if(document.location.href.indexOf("tasks/")>0){ document.getElementById("dynamic_class").className = "task_wrapper";}
        if(document.location.href.indexOf("book_enterprise/")>0){ document.getElementById("dynamic_class").className = "book_enter_wrapper";}
        if(document.location.href.indexOf("book_standard/")>0){ document.getElementById("dynamic_class").className = "book_stand_wrapper";}

}

//disabling popup with jQuery magic!
function disablePopup(mod_id){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup" + mod_id).fadeOut("slow");
		$("#popupContact" + mod_id).fadeOut("slow");
		// Customized by mani 
		$("#video").attr({src:"null"});
		popupStatus = 0;
	}
}

function populateIFrameContent(posId){
	var IFrameID = 'iframe' + posId;
	var DivID = 'popupContact' + posId;
	var CloseButtonid = 'popupContactClose' + posId;
	var imgWidth = 600;

	var myIFrame = document.getElementById(IFrameID);
	var content = myIFrame.contentWindow.document.body.innerHTML; 
	content += '<div class="popupClose" id="'+CloseButtonid+'" onclick="javascript:disablePopup('+posId+')"></div>';
        document.getElementById(DivID).innerHTML = content;
        var imgArray = myIFrame.contentWindow.document.body.getElementsByTagName("img");
	if(imgArray.length > 0)
		imgWidth = imgArray[0].width;
	document.getElementById(DivID).style.width = imgWidth + "px";

	centerPopup(posId, imgWidth); //centering with css
	loadPopup(posId); //load popup
}

function populateIFrameContent123(posId){
var IFrameID = 'iframe' + posId;
    var DivID = 'popupContact' + posId;
var CloseButtonid = 'popupContactClose' + posId;
var imgWidth = 600;
var myIFrame = document.getElementById(IFrameID);
var content = myIFrame.contentWindow.document.body.innerHTML; 
content += '<div class="popupClose" id="'+CloseButtonid+'" onclick="javascript:disablePopup('+posId+')"></div>';
    document.getElementById(DivID).innerHTML = content;

    var imgArray = myIFrame.contentWindow.document.body.getElementsByTagName("img");
    var browserName = navigator.userAgent;

/*var imgObj1 = new Image();
imgObj1.src = imgArray[0].src;
alert(imgObj1.width);*/

if(imgArray.length > 0){
        if(browserName.indexOf('MSIE') > 0) {
            var imgObj1 = new Image();
            imgObj1.src = imgArray[0].src;
        if(imgObj1.width > imgWidth)
            imgWidth = imgObj1.width;
        }
        else {
        if(imgArray[0].width > imgWidth)
            imgWidth = imgArray[0].width;
        }
}
document.getElementById(DivID).style.width = imgWidth + "px";
centerPopup(posId, imgWidth); //centering with css
loadPopup(posId); //load popup
}

function getIFrameContent(IFrameID, DivID, CloseButtonid){
	var myIFrame = document.getElementById(IFrameID);
	var content = myIFrame.contentWindow.document.body.innerHTML; 
	content += '<div class="popupClose" id="' + CloseButtonid + '"></div>';
	document.getElementById(DivID).innerHTML = content;
}



//centering popup
function centerPopup(mod_id, imgWidth) {
	//request data for centering
	imgWidth = imgWidth + 'px';
	// Set width
	$("#popupContact" + mod_id).css({
		"width": imgWidth
	});

	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact" + mod_id).height();
	var popupWidth = $("#popupContact" + mod_id).width();

	//centering
	$("#popupContact" + mod_id).css({
	  //"position": "absolute",
	  "width": imgWidth,
	  "top": windowHeight/2-popupHeight/2,
	  "left": windowWidth/2-popupWidth/2
	});

	 //only need force for IE6
	$("#backgroundPopup" + mod_id).css({
	  "height": windowHeight
	});
}

//Press Escape event!
$(document).keypress(function(e){
	if(e.keyCode==27 && popupStatus==1){
		disablePopup(module_pos_id);
	}
});



// #########  JS for validation ####################   //

function assign_news_letter_1(id,value,name,reg,req) {
	this.uid=id;this.value=value;this.name=name;this.regexp=reg;this.required=req;
}

var news_letter_1= new Array(); 
news_letter_1[news_letter_1.length]= new assign_news_letter_1('email','','field_1','^(.+)@(.+)$','True'); 

function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		alert("Invalid E-mail ID");
		return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("Invalid E-mail ID");
		return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID");
		return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID");
		return false;
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID");
		return false;
	}
	if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID");
		return false;
	}
	if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID");
		return false;
	}
	return true;
}

function ValidateForm(){
	var emailID=document.getElementById('news_letter_field_1');

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID. value="";
		emailID.focus();
		return false;
	}
	return true;
}

function clearField(obj){
	obj.value='';
}


function cleartxt(obj, txtvalue) {
	if(obj.value == txtvalue)
		obj.value = "";
}

function searchFocus() {
	document.frmSearch.search.focus();
}

function formSubmit(inputName,orderby,order) {
	document.getElementById(inputName).value=orderby;

	if(order){
		document.getElementById('n_sort').value = order;
	}

	//document.getElementById("submit").click();
	document.forms.frmSearch.submit();
	//alert(document.getElementById("frmSearch").action);
}

function callclear() {
	document.getElementById('currentpage').value='';
}

function ValidateUserForm(formId,missingText,passwordText,incorrectText) {
	if (validateRegForm(formId, missingText,'', incorrectText,'','') )  {
		document.forms.registrationform.submit();
 	       //return false;
	    }
	else
	     return false;
}

function ValidatecontactForm(formId,missingText,passwordText,incorrectText) {
	if (validateForm(formId, missingText,'', incorrectText,'','') )  {
		document.forms.registrationform.submit();
 	        return true;
	    }
	else
	     return false;
}

function validateRegForm(formId, missingText, passwordText, incorrectText, expiredText, singleChar) {

    if (!missingText)
        missingText = "";

    if (!passwordText)
        passwordText = "";

    if (!incorrectText)
        incorrectText = "";

    if (!expiredText)
        expiredText = "";

    if (!singleChar) {
        singleChar = "";
    }

    var form = document.getElementById(formId);
    var inputs = form.getElementsByTagName("input");
    var textareas = form.getElementsByTagName("textarea");
    var selects = form.getElementsByTagName("select");

    var validatedInputs = validateElements(inputs, missingText, passwordText, incorrectText, expiredText, singleChar);
    var validatedTextareas = validateElements(textareas, missingText, passwordText, incorrectText, expiredText, singleChar);
    var validatedSelects = validateElements(selects, missingText, passwordText, incorrectText, expiredText, singleChar);
    var validateSubscription = validateProdCheckbox();

    return (validatedInputs && validatedTextareas && validatedSelects && validateSubscription);

}
function validateForm(formId, missingText, passwordText, incorrectText, expiredText, singleChar) {

    if (!missingText)
        missingText = "";

    if (!passwordText)
        passwordText = "";

    if (!incorrectText)
        incorrectText = "";

    if (!expiredText)
        expiredText = "";

    if (!singleChar) {
        singleChar = "";
    }

    var form = document.getElementById(formId);
    var inputs = form.getElementsByTagName("input");
    var textareas = form.getElementsByTagName("textarea");
    var selects = form.getElementsByTagName("select");

    var validatedInputs = validateElements(inputs, missingText, passwordText, incorrectText, expiredText, singleChar);
    var validatedTextareas = validateElements(textareas, missingText, passwordText, incorrectText, expiredText, singleChar);
    var validatedSelects = validateElements(selects, missingText, passwordText, incorrectText, expiredText, singleChar);

    return (validatedInputs && validatedTextareas && validatedSelects);

}

function validateElements(inputs, missingText, passwordText, incorrectText, expiredText, singleChar) {

    var validated = true;

    for (var i = 0; i < inputs.length; i++) {
        var currInput = inputs[i];
        var parent = currInput.parentNode;
        var label;
        var missing;
        var smallText;

        // Start: Life specific change - Trim off the value of input box and all space from customer number
        if (currInput.type == "text") {
			currInput.value = trim(currInput.value);
        }
        if (currInput.id == "field_101" || currInput.id == "customerno" || currInput.id == "field_1224"  ) {
			currInput.value = TrimAll(currInput.value);
        }
        // End: Life specific change

        var checkEmail = (currInput.className.indexOf("email") > -1 && !validateEmail(currInput.value));
        var checkAlphabet = (currInput.className.indexOf("alphabet") > -1 && !validateAlphabet(currInput.value));
        var checkAlphanumeric = (currInput.className.indexOf("alphanumeric") > -1 && !validateAlphaNumerics(currInput.value));
        var checkNumerics = (currInput.className.indexOf("number") > -1 && !validateNumerics(currInput.value));
        var checkEmailConfirm = (currInput.className.indexOf("cmail_") > -1 && !validateEmailConfirm(currInput.value, currInput.className));
        var checkPassword = (currInput.className.indexOf("password_") > -1 && !validatePassword(currInput.value, currInput.className));
        var checkSelectList = (currInput.className.indexOf("select") > -1 && !validateSelect(currInput));
        var checkSingle = (currInput.className.indexOf("single") > -1 && !validateSingle(currInput.value));
        var checkPhone = (currInput.className.indexOf("phoneno") > -1 && !validatePhoneno(currInput.value));

        if (currInput.className.indexOf("validate") > -1 || currInput.className.indexOf("required") > -1) {

            currInput.className = currInput.className.replace("required", "validate");

            label = parent.getElementsByTagName("label")[0];

            if (label != null) {

                var origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML;
                label.innerHTML = origLabel;
                label.className = label.className.replace(" error", "").replace("error", "");
            }

            if (trim(currInput.value) == "" || checkEmail || checkPassword || checkEmailConfirm || checkSelectList || checkAlphabet || checkAlphanumeric || checkNumerics || checkSingle || checkPhone) {
                validated = false;
                currInput.className = currInput.className.replace("validate", "required");

                label = parent.getElementsByTagName("label")[0];

                if (label) {
                    var origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML;

                    var errorLabel = "";
                    label.setAttribute("orig", origLabel);

                    if (trim(currInput.value) == "") {
                        //errorLabel = missingText + " " + origLabel.replace(" *", "").toLowerCase();
			errorLabel = origLabel.replace(" *", "")+" " + missingText;
                    } else if (checkPassword || checkEmailConfirm) {
                        errorLabel = passwordText;
                    } else if (checkEmail || checkAlphabet || checkAlphanumeric || checkNumerics || checkPhone) {
                        errorLabel = origLabel.replace(" *", "") + " " + incorrectText;
                    } else if (checkCEXP) {
                        errorLabel = expiredText;
                    } else if (checkSingle) {
                        errorLabel = origLabel.replace(" *", "") + " " + singleChar;
                    } else if (checkSelectList) {
                        errorLabel = missingText + " " + origLabel.replace(" *", "").toLowerCase();
                    }

                    label.innerHTML = errorLabel;

                    if (label.className == "") {
                        label.className = "error";
                    } else {
                        label.className += " error";
                    }
                }
            }

        } else if ((currInput.className.indexOf("optional") > -1 || currInput.className.indexOf("incorrect") > -1) && trim(currInput.value) != "") {

            currInput.className = currInput.className.replace("incorrect", "optional");

            label = parent.getElementsByTagName("label")[0];

            if (label) {
                var origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML;

                label.innerHTML = origLabel;
                label.className = label.className.replace(" error", "").replace("error", "");

                if (checkEmail || checkPassword || checkEmailConfirm || checkAlphabet || checkAlphanumeric || checkNumerics || checkSingle || checkPhone) {
                    validated = false;
                    currInput.className = currInput.className.replace("optional", "incorrect");

                    label = parent.getElementsByTagName("label")[0];
                    origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML;

                    errorLabel = "";

                    label.setAttribute("orig", origLabel);

                    if (incorrectText == "") {
                        incorrectText = missingText;
                    }

                    if (checkSSN || checkCCN || checkCVC || checkAlphabet || checkAlphanumeric || checkNumerics || checkPostal || checkPhone || checkCustomerNumber) {
                        errorLabel = origLabel.replace(" *", "") + " " + incorrectText;
                    } else if (checkCEXP) {
                        errorLabel = expiredText;
                    } else if (checkSingle) {
                        errorLabel = origLabel.replace(" *", "") + " " + singleChar;
                    } else {
                        errorLabel = missingText + " " + origLabel.replace(" *", "").toLowerCase();
                    }

                    label.innerHTML = errorLabel;

                    if (label.className == "") {
                        label.className = "error";
                    } else {
                        label.className += " error";
                    }
                }
            }
        }
       
    }
    return validated;
}

function validateSingle(value) {
    if (value.length > 1)
        return true;
    else
        return false;
}

function validateSelect(objSelect) {
    if (objSelect.options[objSelect.selectedIndex].value == '0')
        return false;
    return true;
}

function validatePassword(value, compareValueObj) {
    var tmp1 = compareValueObj.replace("validate ", "");
    var tmp2 = tmp1.replace("required ", "");
    var compareValue = document.getElementById(tmp2.replace("password_", "")).value;

    if (value != compareValue)
        return false;
    else
        return true;
}

function validateEmail(src) {
	var regex = /([a-zA-Z0-9_-])+(\.{0,1})+([a-zA-Z0-9_-])+([\.][a-zA-Z0-9_-]+){0,1}@{1}([a-zA-Z0-9_-])+(\.{1})+([a-zA-Z0-9]{0,4})+(\.{0,1})+[a-zA-Z]{2,4}$/;

	if (regex.test(src))
		return true;
	else
		return false;
}

function validateEmailConfirm(value, compareValueObj) {
	var tmp1 = compareValueObj.replace("validate ", "");
	var tmp2 = tmp1.replace("required ", "");
	var compareValue = document.getElementById(tmp2.replace("cmail_", "")).value;

	if (value != compareValue)
		return false;
	else
		return true;
}

function validateName(str) {
    var reg = new RegExp("[\\[\\]{}%*`~^$#@&()|!=(0-9)]", "gi");
    if (reg.test(str))
        return false;
    return true;
}

function validateNumerics(src) {
    var allowed = /^-{0,1}\d+$/;

    if (allowed.test(src)) {
        return true;
    } else {
        return false;
    }
}

function validateAlphaNumerics(src) {
    var allowed = /[a-z0-9]/g;

    if (allowed.test(src)) {
        return true;
    } else {
        return false;
    }
}

function validateAlphabet(src) {
    var allowed = /[a-z]/g;

    if (allowed.test(src)) {
        return true;
    } else {
        return false;
    }
}

function validatePhoneno(src) {
    var allowed = /^[\+]?\d+\s?[-]?\d+\s?[-]?\d+\s?[-]?\d+\s?[-]?\d+\s?[-]?\d+\s?[-]?\d+$/;

    if (allowed.test(src)) {
        return true;
    } else {
        return false;
    }
}

function validateNumber(obj) {
    var allowed = /[^0-9]/g;

    var value = obj.value;

    obj.value = value.replace(allowed, '');
}

function trim(text) {

    return text.replace(/^\s*|\s*$/g, "");

}

function validateProdCheckbox() {
	var errorstate = 0;
	document.getElementById('additional_groups_errormsg').style.display="none";

	var subscription_container = document.getElementById('additional_groups');
	var subscription_checkboxer = subscription_container.getElementsByTagName('input');

	for(var i = 0;i< subscription_checkboxer.length; i++) {
		if(subscription_checkboxer[i].type == 'checkbox') {
			if(subscription_checkboxer[i].checked) {
				errorstate = 1;
				return true;
			}
		}
	}


	if(document.getElementById('additional_groups') != null && errorstate == 0) {
		document.getElementById('additional_groups_errormsg').style.display="block";
    		document.getElementById('additional_groups_errormsg').innerHTML = '<label class="error_check">Select the product below</label><br/>';
	}
	return false;
}



$(document).ready(function() {
	// Script for EC product div and support

        $("#hide_button").click(function(){
           $("#middle").slideUp("fast");
        });

        $("#show_button").click(function(){
           $("#middle").slideToggle("fast");
        });

        $("#show_icon").click(function(){
           $("#middle").slideToggle("fast");
        });

	// Script for left webtree subpage

        $("#more_button").click(function(){
           $("#more_button").hide("fast");	
	   $(".limit").show("fast");
           $("#hide_box").show("fast");	
	   $("#relative").removeClass("position");
           $("#more_button").hide("fast");	
        });

        $("#hide_box").click(function(){
	   $(".limit").hide("fast");
           $("#hide_box").hide("fast");	
	   $("#relative").addClass("position");
           $("#more_button").show("fast");	
        });

	// Fit the live chat and EC product box in view port
	/*$(window).scroll(function() {
		if(document.documentElement.scrollTop > 398)
			$("#covering_div").addClass("floating").removeClass("pinned-top");
		else
			$("#covering_div").addClass("pinned-top").removeClass("floating");
	});*/
});


//----------- Script added for ecbook check out steps : Start ---------------//

//****** For Thumbnail larger view in Configure page Start*****//
  $(document).ready(function(){
	    $('.interface_img').click(function(){
            $(".interface_popup_img", this).fadeIn("slow");
            $(".popup_bg").css({
			"opacity": "0.7"
		    });
    		$(".popup_bg").fadeIn("slow");
            AlignPopup();
            }, function() {
        });
        
        //Click out event!
    	$(".popup_bg").click(function(){
    		hidePopup();
    	});

    	$(".hidepopupnew").click(function(){
    		hidePopup();
    	});
    	
    	//Press Escape event!
    	$(document).keypress(function(e){
    		if(e.keyCode==27){
    			hidePopup();
    		}
    	});

	});

function AlignPopup(){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $(".interface_popup_img").height();
	var popupWidth = $(".interface_popup_img").width();
	//centering
	$(".interface_popup_img").css({
		//"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6	
	$(".popup_bg").css({
		"height": windowHeight
	});	
}

function hidePopup(){
		$(".popup_bg").fadeOut("slow");
		$(".interface_popup_img").fadeOut("slow");	
}
//****** For Thumbnail larger view in Configure page End *****//


/* ################ Start:latest validation js ################ */
function ValidateUserRegForm(formId,missingText,passwordText,incorrectText) {
	if (validateEcbookRegForm(formId, missingText,'', incorrectText,'',''))  {
		document.forms.ecbookregistrationformNew.submit();
	}
	else{
	    return false;
	}
}

/*function validatelength(){
    alert(document.getElementById("field_100").length);
    if(document.getElementById("field_100").value.length <= 4){        
        document.getElementById("pword_lenght").className = "form_error_length";
        return false;
    }
    else{
        return true;
    }
}*/

function validateEcbookRegForm(formId, missingText, passwordText, incorrectText, expiredText, singleChar) {

    var passwordText = "Passwords do not match";
	var singleChar = "must be greater than one";
	var sixChar = "must be more than six character";

    
    if (!missingText)
        missingText = "";

    if (!passwordText)
        passwordText = "";

    if (!incorrectText)
        incorrectText = "";

    if (!expiredText)
        expiredText = "";

    if (!singleChar) {
        singleChar = "";
    }

    var form = document.getElementById(formId);
    var inputs = form.getElementsByTagName("input");
    var textareas = form.getElementsByTagName("textarea");
    var selects = form.getElementsByTagName("select");



    var validatedInputs = validateElementsNew(inputs, missingText, passwordText, incorrectText, expiredText, singleChar);
    var validatedTextareas = validateElementsNew(textareas, missingText, passwordText, incorrectText, expiredText, singleChar);
    var validatedSelects = validateElementsNew(selects, missingText, passwordText, incorrectText, expiredText, singleChar);
    //var validateSubscription = validateProdCheckbox();
    return (validatedInputs && validatedTextareas && validatedSelects);
}

function validateElementsNew(inputs, missingText, passwordText, incorrectText, expiredText, singleChar) {



    var validated = true;



    for (var i = 0; i < inputs.length; i++) {

        var currInput = inputs[i];

        var parent = currInput.parentNode;

        var label;

        var missing;

        var smallText;



        // Start: Life specific change - Trim off the value of input box and all space from customer number

        if (currInput.type == "text") {

			currInput.value = trim(currInput.value);

        }

        if (currInput.id == "field_101" || currInput.id == "customerno" || currInput.id == "field_1224"  ) {

			currInput.value = TrimAll(currInput.value);

        }

        // End: Life specific change



        var checkEmail = (currInput.className.indexOf("email") > -1 && !validateEmail(currInput.value));

        var checkAlphabet = (currInput.className.indexOf("alphabet") > -1 && !validateAlphabet(currInput.value));

        var checkAlphanumeric = (currInput.className.indexOf("alphanumeric") > -1 && !validateAlphaNumerics(currInput.value));

        var checkNumerics = (currInput.className.indexOf("number") > -1 && !validateNumerics(currInput.value));

        var checkEmailConfirm = (currInput.className.indexOf("cmail_") > -1 && !validateEmailConfirm(currInput.value, currInput.className));

        var checkPassword = (currInput.className.indexOf("password_") > -1 && !validatePassword(currInput.value, currInput.className));

        var checkSelectList = (currInput.className.indexOf("select") > -1 && !validateSelect(currInput));

        var checkSingle = (currInput.className.indexOf("single") > -1 && !validateSingle(currInput.value));

        var checkPhone = (currInput.className.indexOf("phoneno") > -1 && !validatePhoneno(currInput.value));



        if (currInput.className.indexOf("validate") > -1 || currInput.className.indexOf("required") > -1) {



            currInput.className = currInput.className.replace("required", "validate");



            label = parent.getElementsByTagName("label")[0];



            if (label != null) {



                var origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML;

                label.innerHTML = origLabel;

                label.className = label.className.replace(" error", "").replace("error", "");

            }



            if (trim(currInput.value) == "" || checkEmail || checkPassword || checkEmailConfirm || checkSelectList || checkAlphabet || checkAlphanumeric || checkNumerics || checkSingle || checkPhone) {

                validated = false;

                currInput.className = currInput.className.replace("validate", "required");



                label = parent.getElementsByTagName("label")[0];



                if (label) {

                    var origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML;



                    var errorLabel = "";

                    label.setAttribute("orig", origLabel);



                    if (trim(currInput.value) == "") {

                        //errorLabel = missingText + " " + origLabel.replace(" *", "").toLowerCase();

			errorLabel = origLabel.replace(" *", "")+" " + missingText;

                    } else if (checkPassword || checkEmailConfirm) {

                        errorLabel = passwordText;

                    } else if (checkEmail || checkAlphabet || checkAlphanumeric || checkNumerics || checkPhone) {

                        errorLabel = origLabel.replace(" *", "") + " " + incorrectText;

                    } else if (checkCEXP) {

                        errorLabel = expiredText;

                    } else if (checkSingle) {

                        errorLabel = origLabel.replace(" *", "") + " " + singleChar;

                    } else if (checkSelectList) {

                        errorLabel = missingText + " " + origLabel.replace(" *", "").toLowerCase();

                    }



                    label.innerHTML = errorLabel;



                    if (label.className == "") {

                        label.className = "error";

                    } else {

                        label.className += " error";

                    }

                }

            }



        } else if ((currInput.className.indexOf("optional") > -1 || currInput.className.indexOf("incorrect") > -1) && trim(currInput.value) != "") {
            currInput.className = currInput.className.replace("incorrect", "optional");
            label = parent.getElementsByTagName("label")[0];
            if (label) {
                var origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML;
                label.innerHTML = origLabel;
                label.className = label.className.replace(" error", "").replace("error", "");
                if (checkEmail || checkPassword || checkEmailConfirm || checkAlphabet || checkAlphanumeric || checkNumerics || checkSingle || checkPhone) {
                    validated = false;
                    currInput.className = currInput.className.replace("optional", "incorrect");
                    label = parent.getElementsByTagName("label")[0];
                    origLabel = (label.getAttribute("orig") != null && label.getAttribute("orig") != "") ? label.getAttribute("orig") : label.innerHTML;
                    errorLabel = "";
                    label.setAttribute("orig", origLabel);
                    if (incorrectText == "") {
                        incorrectText = missingText;
                    }
                    if (checkSSN || checkCCN || checkCVC || checkAlphabet || checkAlphanumeric || checkNumerics || checkPostal || checkPhone || checkCustomerNumber) {
                        errorLabel = origLabel.replace(" *", "") + " " + incorrectText;
                    } else if (checkCEXP) {
                        errorLabel = expiredText;
                    } else if (checkSingle) {
                        errorLabel = origLabel.replace(" *", "") + " " + singleChar;
                    } else {
                        errorLabel = missingText + " " + origLabel.replace(" *", "").toLowerCase();
                    }
                    label.innerHTML = errorLabel;
                    if (label.className == "") {
                        label.className = "error";
                    } else {
                        label.className += " error";
                    }
                }
            }
        }     
    }
    return validated;
}

/* ################ End:latest validation js ################ */


/* ################ Srart:Remove product ################ */
               function removeProducts(id)
               {
                    var userid = '<xsl:value-of select="$userId"/>'
                    var test = document.getElementById('qnt').value;
                        //alert("GUID : " + test);
                    var loc = window.location.href;
                    //alert("GUID : " + loc);
                    var loc1 = loc.split("?");
                    //alert("GUID : " + loc1);
                    window.location.href=loc1[0]+'?removeproduct='+id;
                    window.location.href=loc1[0]+'?addproduct='+id;
                    //alert(loc1[0]);
                    if(userid.length > 0)
                    {
                         window.location.href='/en/ec_store/publish/';
                    }else{
                        window.location. href='/en/ec_store/sign_in/';
                    }
                    return true;
               }
/* ################ End:Remove product ################ */               

/* Puplication page scroll : Start */
function scrollWin(id){
var newid = id
$('html, body').animate({
scrollTop: $("#"+newid).offset().top - 50
}, 500);
}

/* Puplication page scroll : End*/


//----------- Script added for ecbook check out steps : End ---------------//     

