﻿$(document).ready(function() {     
    $('a.clueTip').cluetip({
        width:300,
        // settings for when hoverIntent plugin is used
        hoverIntent: {    
            sensitivity: 3,
            interval: 50,
            timeout: 300
        }, 
        showTitle: false
    });
    
    $('a.clueTip').click(function(){
        var href = $(this).attr('href');
        window.location = href;
    });
    
    //Edit Advert Dialog
    $('#dialogEditAdvert').dialog({
        autoOpen: false,
        modal: true,
        width: 420,
        height: 420,
        closeText: 'Close',
        resizable: false
    });

    // Dialog Link
    $('.aEditAdvert').click(function(){
        var src = $(this).attr("href");
        $('iframe#frameEditAdvert').attr("src",src);    
        $('#dialogEditAdvert').dialog('open');
        return false;
    });

    //Preview Invite Message Dialog    
    $('#dialogPreviewInviteMessage').dialog({
        autoOpen: false,
        modal: true,
        width: 700,
        height: 520,
        closeText: 'Close',
        buttons: {
            "Close": function() { 
                $(this).dialog("close"); 
            } 
        },
        resizable: false
    });

    // Dialog Link
    $('#aPreviewInviteMessage').click(function(){
        var src = $(this).attr("href");
        $('iframe#framePreviewInviteMessage').attr("src",src);    
        $('#dialogPreviewInviteMessage').dialog('open');
        return false;
    });

    //Reply message dialog
    $('#dialogReplyMessage').dialog({
        autoOpen: false,
        modal: true,
        width: 450,
        height: 260,
        closeText: 'Close',
        resizable: false
    });

    $('a.aReplyMessage').click(function(){
        var src = $(this).attr("href");
        $('iframe#frameReplyMessage').attr("src",src);    
        $('#dialogReplyMessage').dialog('open');
        return false;
    });
    
    //Change password dialog
    $('#dialogChangePassword').dialog({
        autoOpen: false,
        modal: true,
        width: 420,
        height: 250,
        closeText: 'Close',
        resizable: false
    });

    $('#aChangePassword').click(function(){
        var src = $(this).attr("href");
        $('iframe#frameChangePassword').attr("src",src);    
        $('#dialogChangePassword').dialog('open');
        return false;
    });

    //Add SharedLink Dialog
    $('#shareLinkDialog').dialog({
        autoOpen: false,
        modal: true,
        width: 400,
        height: 230,
        closeText: 'Close',
        resizable: false
    });

    $('#aShareLink').click(function(){
        var src = $(this).attr("href");
        $('iframe#frameShareLink').attr("src",src);    
        $('#shareLinkDialog').dialog('open');
        return false;
    });

    //Delete Shared Link Confirm Dialog
    $('#sharedLinkConfirmDeleteDialog').dialog({
        autoOpen: false,
        modal: true,
        width: 400,
        height: 170,
        closeText: 'Close',
        resizable: false
    });

    $('a.aSharedLinkConfirmDelete').click(function(){
        var src = $(this).attr("href");
        $('iframe#frameSharedLinkConfirmDelete').attr("src",src);    
        $('#sharedLinkConfirmDeleteDialog').dialog('open');
        return false;
    });
    
    //Fee Translation Dialog
    $('#feedTranslationDialog').dialog({
        autoOpen: false,
        modal: true,
        width: 500,
        height: 300,
        closeText: 'Close',
        resizable: false
    });

    $('a#aFeedTranslation').click(function(){
        var src = $(this).attr("href");
        $('iframe#frameFeedTranslation').attr("src",src);    
        $('#feedTranslationDialog').dialog('open');
        return false;
    });

    //Send Message Dialog
    $('#sendMessageDialog').dialog({
        autoOpen: false,
        modal: true,
        width: 500,
        height: 280,
        closeText: 'Close',
        resizable: false
    });

    $('#aSendMessage').click(function(){
        var src = $(this).attr("href");
        $('iframe#frameSendMessage').attr("src",src);    
        $('#sendMessageDialog').dialog('open');
        return false;
    });

    //Contact us dialog
    $('#dialogContactUs').dialog({
        autoOpen: false,
        modal: true,
        width: 530,
        height: 440,
        closeText: 'Close',
        resizable: false
    });

    $('.aContactUs').click(function(){
        var src = $(this).attr("href");
        $('iframe#frameContactUs').attr("src",src);    
        $('#dialogContactUs').dialog('open');
        return false;
    });

    //Terms of use dialog
    $('#dialogTermsOfUse').dialog({
        autoOpen: false,
        modal: true,
        width: 675,
        height: 450,
        closeText: 'Close',
        resizable: false
    });

    $('.aTermsOfUse').click(function(){
        var src = $(this).attr("href");
        $('iframe#frameTermsOfUse').attr("src",src);    
        $('#dialogTermsOfUse').dialog('open');
        return false;
    });

    //MiniProfile Dialog
    $('#dialogMiniProfile').dialog({
        autoOpen: false,
        modal: true,
        width: 400,
        height: 280,
        closeText: 'Close',
//        buttons: {
//            "Close": function() { 
//                $(this).dialog("close"); 
//            } 
//        },
        resizable: false
    });

    $('.aMiniProfile').click(function(){
        var src = $(this).attr("rel");
        $('iframe#frameMiniProfile').attr("src",src);    
        $('#dialogMiniProfile').dialog('open');
        return false;
    });
    
    //Forgot password dialog
    $('#dialogForgotPassword').dialog({
        autoOpen: false,
        modal: true,
        width: 400,
        height: 220,
        closeText: 'Close',
        resizable: false
    });

    // Dialog Link
    $('#aForgotPassword').click(function(){
        var src = $(this).attr("href");
        $('iframe#frameForgotPassword').attr("src",src);    
        $('#dialogForgotPassword').dialog('open');
        return false;
    });    
});    
