﻿// JScript File
var imageid = 1;
function gonextimg(mode, imgt) {
    var imgTag = document.getElementById(imgt);
    imageid = imageid + mode;
    if (imageid > 5)
        imageid = 1;
    if (imageid < 1)
        imageid = 5;
    if (imgTag != null) {
        imgTag.src = "./images/rotateimage/" + imageid.toString() + ".jpg";
    }
}

function tellafriend(Code,page) {
    if (Code != '') {
    switch(page)
    {
        case "t":
            window.open("tellafriend.aspx?ev=" + Code + "&", '_tella', 'height=230,width=550,menubar=no,location=no,toolbar=no,statusbar=no');
            break;
        case "v":
            window.open("venuedetails.aspx?ev=" + Code + "&", '_tella', 'height=300,width=550,scrollbar=yes,menubar=no,location=no,toolbar=no,statusbar=yes');
            break;
        }
    }
}
function trim(str) {
    return str.replace(/^\s+|\s+$/, '');
}
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 DoTellSubmit() {

    var fname = document.getElementById('fName');
    var femail = document.getElementById('fEmail');
    var yName = document.getElementById('yName');
    var yEmail = document.getElementById('yEmail');

    if (fname != null && femail != null && yName != null && yEmail != null) {

        if (trim(fname.value) == "" || trim(yName.value) == "" || trim(femail.value) == "" || trim(yEmail.value) == "")
            alert("All Fields are mandatory !!");
        else {

            if (echeck(yEmail.value) == false) {
                yEmail.focus();
                return;
            }
            if (echeck(femail.value) == false) {
                femail.focus();
                return;
            }

            document.forms[0].submit();
        }

    }
}

function detectBrowser() {
    var browser = navigator.appName;
    var b_version = navigator.appVersion;
    var version = parseFloat(b_version);
    if (browser == "Netscape")
        return "NN";
    if (browser == "Microsoft Internet Explorer")
        return "IE";
}



function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        }
        while (obj = obj.offsetParent);
    }

    return [curleft, curtop];
}


