
jQuery.noConflict();
function showsend() {
    jQuery("[id$='txtUrl']").val(document.location.href);
    jQuery("#divSendToFriend").modal({
        opacity: 80,
        overlayCss: { backgroundColor: "Gray" }, overlayClose: true
    });

}
function toggleview(element1) {

    element1 = document.getElementById(element1);

    if (element1.style.display == 'block' || element1.style.display == '') {
        element1.style.display = 'none';
        jQuery("[id$='" + element1.id + "minusanchor']").hide();
     
        jQuery("[id$='" + element1.id + "plusanchor']").show();
    }
    else {
        element1.style.display = 'block';
        jQuery("[id$='" + element1.id + "minusanchor']").show();
        jQuery("[id$='" + element1.id + "plusanchor']").hide();
    }


}
function CreateBookmarkLink() {
    //title = "Webpage Title"; 
    // Blogger - Replace with <$BlogItemTitle$> 
    // MovableType - Replace with <$MTEntryTitle$>

    // url = "Webpage URL";
    // Blogger - Replace with <$BlogItemPermalinkURL$> 
    // MovableType - Replace with <$MTEntryPermalink$>
    // WordPress - <?php bloginfo('url'); ?>

    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(document.title, document.location.href, "");


    } else if (window.external) { // IE Favorite
        window.external.AddFavorite(document.referrer, document.title);
    }
    else if (window.opera && window.print) { // Opera Hotlist
        return true;
    }
}

// if (window.external) {
//  document.write('<a href = "javascript:CreateBookmarkLink()");">Add to Favorites</a>'); 
//  } else  if (window.sidebar) {document.write('<a href = "javascript:CreateBookmarkLink()");">Bookmark Page</a>'); 
// } else if (window.opera && window.print) { document.write('<a href ="javascript:CreateBookmarkLink()");">Add Bookmark</a>');
// } 

function addToFavorites() {
    if (window.external) {
        window.external.AddFavorite(document.location.href, document.title)
    } else {
        alert("Sorry! Your browser doesn't support this function.");
    }
}



jQuery(function(jQuery) {
    //borrowed from jQuery easing plugin
    //http://gsgd.co.uk/sandbox/jquery.easing.php

    String.prototype.endsWith = function(str) { return (this.match(str + "$") == str) }
    String.prototype.trim = function() { return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, "")) }
    jQuery.easing.backout = function(x, t, b, c, d) {
        var s = 1.70158;
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
    };

    jQuery('#screen').scrollShow({
        view: '#view',
        content: '#images',
        easing: 'backout',
        wrappers: 'link,crop',
        navigators: 'a[id]',
        navigationMode: 'sr',
        circular: true,
        start: 0
    });

    jQuery(".Newsmove").jCarouselLite({
        vertical: true,
        visible: 1,
        btnNext: ".next",
        btnPrev: ".prev",
        auto: 5000,
        speed: 2000
    });

    AdjustMenu();
    jQuery("[id$='plusanchor']").hide();
    AC_FL_RunContent = 0;
    jQuery("[id$='btnSend']").click(function() { sendtofriend(); return false; });
    //jQuery("#btnCancelSend").click(function() { $.modal.close(); return false; });
    jQuery("#aTwitter").click(function() { window.open("http://twitter.com/home?status=" + document.location.href); });
    //jQuery("#aBookmark").attr("onmousedown","CreateBookmarkLink()");
    jQuery("#aprint").click(function() { PrintDiv("LeftSideIner"); });
    jQuery("#aBookmark").click(function() { CreateBookmarkLink(); });
    jQuery("#aTell").click(function() { showsend(); return false; });
    jQuery("#aBlogger").click(function() { window.open("http://www.addthis.com/bookmark.php?v=250&winname=addthis&pub=AddThis&source=men-250&lng=en&s=blogger&url=" + document.location.href); });
    jQuery("#afacebook").click(function() { window.open("http://www.facebook.com/sharer.php?u=" + document.location.href); });


});
//function showpop() {
//    jQuery("#disablePage").removeClass('hide');
//jQuery("#disablePage").toggleClass('show');

//}
//function clickButton(e, buttonid) {

//    var evt = e ? e : window.event;

//    var bt = document.getElementById(buttonid);

//    if (bt) {

//        if (evt.keyCode == 13) {

//            bt.click();

//            return false;

//        }

//    }

//}
function AdjustMenu() {
   //jQuery("#nav  li.top:last .top_link ").parent().find("span").attr("style", "background:none !important"); //.parent().parent().find("ul").attr("style", "width:170px !important").find("li").attr("style", "width:140px !important").find("a").attr("style", "width:140px !important");

}
function sendtofriend() {
    ///////////sdaffffffffffffffffffffffffffffffffffffff

    var from = jQuery("[id$='txtFrom']").val();
    var to = jQuery("[id$='txtTo']").val();
    var url = jQuery("[id$='txtUrl']").val();

    if (validateSend(from, to)) PageMethods.Send(from, to, url, function(result) { if (result == 1) { alert("sent Successfully"); jQuery.modal.close(); } else { alert("unable to communicate to the mail server"); jQuery.modal.close(); } });
}

function validateSend(from, to) {

    // alert(from);
    var flag = true;
    if (from == "" || from == undefined) { jQuery("[id$='SpanFrom']").show(); flag = false; } else { jQuery("[id$='SpanFrom']").hide(); }
    if (to == "" || to == undefined) { jQuery("[id$='SpanToEmail']").hide(); jQuery("[id$='SpanTo']").show(); flag = false; }
    else if (echeck(to) == false) { jQuery("[id$='SpanTo']").hide(); jQuery("[id$='SpanToEmail']").show(); flag = false; }
    else { jQuery("[id$='SpanToEmail']").hide(); jQuery("[id$='SpanTo']").hide(); }
    return flag;
}
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
}


   

