﻿function InsertPixelCall() // For Gogle analytics
{
 
   document.getElementById("divCall").innerHTML="<img border=\"0\" width=\"1\" height=\"1\" src=\"http://tracking.sokrati.com/lead?client_id=56&product_category=link&item_identifier=clicktocall\" />";
   
}
function InsertPixelChat()// For Gogle analytics
{
  
   document.getElementById("divChat").innerHTML="<img border=\"0\" width=\"1\" height=\"1\" src=\"http://tracking.sokrati.com/lead?client_id=56&product_category=link&item_identifier=livechat\" />";
  
}





var ValidationYes = false;


//End Bday Cal date validation and age validation for registration, Edit my account, quick login,




function GetYear(id1, id2) { //id1-birth date id2 //age to be calcuated in this function

    var objDate = new Date();
    objDate.setHours(00, 00, 00, 00);
    var exp = /(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12][0-9]|3[01])\/(?:19|20\d{2})/;

    if (!exp.test(document.getElementById(id1).value)) {
        alert("Please enter valid Date");
        document.getElementById(id1).focus();
        document.getElementById(id1).value = "";
        document.getElementById(id2).value = "";
        document.getElementById(id1).focus();
        return;
    }

    var objstr = document.getElementById(id1).value.split('/');
    var objCheckDate = new Date();
    objCheckDate.setHours(00, 00, 00, 00);
    objCheckDate.setDate(parseInt(objstr[1]));
    objCheckDate.setMonth(parseInt(objstr[0]) - 1);
    objCheckDate.setFullYear(parseInt(objstr[2]));
    if (document.getElementById(id1).value != "" || document.getElementById(id1).value != " " || !isNaN(parseInt(document.getElementById(id1).value.split('/')[2]))) {


        if ((objDate.getFullYear() - parseInt(objstr[2])) >= 0 && (objDate >= objCheckDate)) {
            document.getElementById(id2).value = (objDate.getFullYear() - parseInt(objstr[2]));
        }
        else {
            alert("Please enter BirthDay less than Today's Date");

            document.getElementById(id1).value = "";
            document.getElementById(id2).value = "";
            document.getElementById(id1).focus();
        }
    }

}

function ValidateBirthDay(id1) {

    var objDate = new Date();
    objDate.setHours(00, 00, 00, 00);
    var exp = /(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12][0-9]|3[01])\/(?:19|20\d{2})/;
    if (!exp.test(document.getElementById(id1).value)) {
        alert("Please enter valid Date");
        document.getElementById(id1).focus();
        return;
    }

    if (document.getElementById(id1).value != "" || document.getElementById(id1).value != " " || !isNaN(parseInt(document.getElementById(id1).value.split('/')[2]))) {
        var objstr = document.getElementById(id1).value.split('/');
        var objCheckDate = new Date();
        objCheckDate.setDate(parseInt(objstr[1]));
        objCheckDate.setMonth(parseInt(objstr[0]) - 1);
        objCheckDate.setFullYear(parseInt(objstr[2]));
        objCheckDate.setHours(00, 00, 00, 00);
        if (objDate < objCheckDate) {
            alert("Please enter BirthDay less than Today's Date");

            document.getElementById(id1).value = "";

            document.getElementById(id1).focus();
        }
    }
    else {
        alert("Please enter proper date");

        document.getElementById(id1).value = "";

        document.getElementById(id1).focus();
    }

}




//End Bday Cal date validation and age validation for registration, Edit my account, quick login,

// Used For adding bookmark functionality
function addToBookMarks() {

    if (document.all)
        window.external.AddFavorite(location.href, document.title);

    else if (window.sidebar) window.sidebar.addPanel(document.title, location.href, '');
}
// Used For adding bookmark functionality ENDS





// Used On home page
function moveToPrevious() {
    new Effect.Move('imageBoxInside', { x: 180, y: 0, transition: Effect.Transitions.sinoidal });
}

function moveToNext() {
    new Effect.Move('imageBoxInside', { x: -180, y: 0, transition: Effect.Transitions.sinoidal });
}
// Used On home page ENDS




//For water mark on search on all pages
var Init = function() {

    if (document.getElementById("ctl00_txtSearch") != null) {
        document.getElementById("ctl00_txtSearch").style.color = "Gray";
        watermark("ctl00_txtSearch", "Search VIP Events & Experiences");
    }

    if (document.getElementById("ctl00_txtSubscriberEmail") != null) {
        document.getElementById("ctl00_txtSubscriberEmail").style.color = "Gray";
        watermark("ctl00_txtSubscriberEmail", "Enter Your Email Address");
    }
}
if (window.addEventListener)
    window.addEventListener("load", Init, false)
else if (window.attachEvent)
    window.attachEvent("onload", Init)
else if (document.getElementById)
    window.onload = Init;
//For water mark on search on all pages ENDS



// The mouseover effect on the homepage and inner pages


dropdowncontent.init("searchlink1", "right-bottom", 300, "mouseover")

dropdowncontent.init("searchlink2", "right-bottom", 300, "mouseover")

dropdowncontent.init("searchlink4", "right-bottom", 300, "mouseover")

// The mouseover effect on the homepage and inner pages ENDS

//Video Section Event detail page

function setTabs(ID) {
    if (ID == "divVideo") {
        document.getElementById("divVideo").style.visibility = "visible";
        document.getElementById("divPhoto").style.visibility = "hidden";
        document.getElementById("hover-1").className = "active";
        document.getElementById("hover-2").className = "";
    }
    else if (ID == "divPhoto") {
        document.getElementById("divVideo").style.visibility = "hidden";
        document.getElementById("divPhoto").style.visibility = "visible";
        document.getElementById("hover-2").className = "active";
        document.getElementById("hover-1").className = "";
    }
}

//Video Section Event detail page ENDS
//function to validate CC Expiry Date
function ValidateSubmit() {
    if (ValidationYes) {

        var objDate = new Date();

        var objType = "";
        if (document.getElementById("ctl00_CPHMiddle_chklistCardType").value == "1") {
            objType = "AmEx";
        }
        else if (document.getElementById("ctl00_CPHMiddle_chklistCardType").value == "2") {
            objType = "Disc";
        }
        else if (document.getElementById("ctl00_CPHMiddle_chklistCardType").value == "3") {
            objType = "MC";
        }

        else {
            objType = "Visa";
        }

        if (!isValidCreditCard(objType, document.getElementById("ctl00_CPHMiddle_txtCardNumber").value)) {
            alert("Please enter Valid Credit Card Number");
            document.getElementById("ctl00_CPHMiddle_txtCardNumber").focus();
            return false;
        }
        if (parseInt(document.getElementById("ctl00_CPHMiddle_ddlExpMonth").value) < (objDate.getMonth() + 1) && parseInt(document.getElementById("ctl00_CPHMiddle_ddlExpYear").value) == (objDate.getFullYear())) {
            alert("Please enter Valid Expiry Date");
            document.getElementById("ctl00_CPHMiddle_ddlExpMonth").focus();
            return false;

        }
        if (!document.getElementById("ctl00_CPHMiddle_CheckTerms").checked) {

            alert("Please check the Terms and Conditions to mark your acceptance of all terms and conditions");
            document.getElementById("ctl00_CPHMiddle_CheckTerms").focus();
            return false;
        }

        return true;
    }
    else {
        return true;
    }
}

function isValidCreditCard(type, ccnum) {
    if (type == "Visa") {
        // Visa: length 16, prefix 4, dashes optional.
        var re = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
    } else if (type == "MC") {
        // Mastercard: length 16, prefix 51-55, dashes optional.
        var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
    } else if (type == "Disc") {
        // Discover: length 16, prefix 6011, dashes optional.
        var re = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
    } else if (type == "AmEx") {
        // American Express: length 15, prefix 34 or 37.
        var re = /^3[4,7]\d{13}$/;
    } else if (type == "Diners") {
        // Diners: length 14, prefix 30, 36, or 38.
        var re = /^3[0,6,8]\d{12}$/;
    }
    if (!re.test(ccnum)) return false;
   
    // Remove all dashes for the checksum checks to eliminate negative numbers
    ccnum = ccnum.split("-").join("");
    // Checksum ("Mod 10")
    // Add even digits in even length strings or odd digits in odd length strings.
    var checksum = 0;
    for (var i = (2 - (ccnum.length % 2)); i <= ccnum.length; i += 2) {
        checksum += parseInt(ccnum.charAt(i - 1));
    }
    // Analyze odd digits in even length strings or even digits in odd length strings.
    for (var i = (ccnum.length % 2) + 1; i < ccnum.length; i += 2) {
        var digit = parseInt(ccnum.charAt(i - 1)) * 2;
        if (digit < 10) { checksum += digit; } else { checksum += (digit - 9); }
    }
    if ((checksum % 10) == 0) return true; else return false;
}



