// JavaScript Document
function hide_label(objid){	
	document.getElementById(objid).style.display='none'
}


function showdetail() {
    document.getElementById("basket_flying").style.display = "block";
    document.getElementById("basket_flying").style.right = "0px";
    document.getElementById("basket_flying").style.top = "-75px";
}
function hidedetail() {
    document.getElementById("basket_flying").style.display = "none"
}

function selectTab(tabname) {
    if (tabname == "returns") {
        document.getElementById("tab_returns").className = "selected"
        document.getElementById("tab_delivery").className = ""
        document.getElementById("info_returns").style.display = "block"
        document.getElementById("info_delivery").style.display = "none"
    }
    else {
        document.getElementById("tab_returns").className = ""
        document.getElementById("tab_delivery").className = "selected"
        document.getElementById("info_returns").style.display = "none"
        document.getElementById("info_delivery").style.display = "block"
    }
}

function verifyEmail(vemail) {
    var status = false;
    var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
    if (vemail.search(emailRegEx) == -1) {

    }
    else {

        status = true;
    }
    return status;
}

function IsNumeric(strString)
//  check for valid numeric strings	
{
    var strValidChars = "0123456789";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++) {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1) {
            blnResult = false;
        }
    }
    return blnResult;
}

function EmailFriendSubmit() {
    var strError
    strError = ""
    if (document.frm_emailfriend.sender_name.value == "") {
        strError = strError + "<br />Sender's name is required.</li>"
    }
    if (verifyEmail(document.frm_emailfriend.sender_email.value) == false) {
        //alert(0)
        strError = strError + "<br />Senders email is invalid format.</li>"
    }
    if (document.frm_emailfriend.friend_name.value == "") {
        strError = strError + "<br />Friend's name is required."

    }
    if (verifyEmail(document.frm_emailfriend.friend_email.value) == false) {
        //alert(0)
        strError = strError + "<br />Friend's email is invalid format."
    }
    if (strError != "") {
        document.getElementById("frm_error").innerHTML = strError
        return false
    }
    else {
        return true
    }
}

function ShoppingSubmit() {

    if (IsNumeric(tmpQuantity = document.frm_shopping.basket_product.value) == false) {
        alert("Please select product size.")
        return false
    }
    if (IsNumeric(tmpQuantity = document.frm_shopping.basket_quantity.value) == false) {
        alert("The quantity is invalid.")
        return false
    }
}

function ShoppingSum(vprice) {
    var vtotal
    var vqty
    vqty = document.frm_shopping.basket_quantity.value
    vtotal = vprice * vqty
    document.getElementById("shopping_sum").innerHTML = "&pound;" + vtotal.toFixed(2)
}

function showimage(type) {
try
  {

    document.getElementById("sc").style.zIndex = "68"
    document.getElementById("sc1").style.zIndex = "68"
    document.getElementById("sc2").style.zIndex = "68"
    document.getElementById("sc3").style.zIndex = "68"
  }	
catch(err)
  {
  //Handle errors here
  }
    document.getElementById("sc" + type).style.zIndex = "69"

}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}
function ShowWelcomeBack() {
    //alert("xx")
    var lastLogin = getCookie("prevname")
    //alert(lastLogin)
    if (lastLogin != "") {
        document.getElementById("welcome_back").style.display = "block"
        document.getElementById("welcome_back").innerHTML = "Welcome back <strong>" + lastLogin + "</strong>."
    }
}

//Make Uppercase
function makeUppercase(ctrl) {
 
    var t = ctrl.value;

    ctrl.value = t.toUpperCase();

}