﻿// JScript File

function ClearMessage()
{

    var message = $('#fileSavedIndication');
    if (message.length > 0)
    {
   
        if(message.html() != "")
            message.html("");
    }
      
    message = $('fileSavedIndication2');
    if (message != null)
    {
        if(message.innerHTML != "")
            message.innerHTML = "";
    }
      
    message = $('savedIndication');
    if (message != null)
    {
        if(message.innerHTML != "")
            message.innerHTML = "";
    }
}

function ShowCode(img, obj1, obj2)
{
    img.attr({src: "/Images/Collapse.png"});
    obj1.show("slow");
    obj2.hid("slow");
}

function HideCode(img, obj)
{
    img.attr({src: "/Images/Expand.png"});
    obj.hide("slow");
}


function ToggleCode(obj1, obj2)
{
    obj1.show();
    obj2.hide();
}

function ToggleMultiple(objArr)
{
    var arLen=objArr.length;

    if(arLen > 0)
    {
        objArr[0].show();
    
        for ( var i=1, len=arLen; i<len; ++i ){
            objArr[i].hide();
        }    
    }
}

function ToggleMultipleWithPreview(strHTML, objPreviewHolder, objArr)
{

    if (!strHTML || !objPreviewHolder)
    {
        //alert('We got a situation');
    }
    else
    {
        objPreviewHolder.html(strHTML); 
    }
    
    var arLen=objArr.length;

    if(arLen > 0)
    {
        objArr[0].show();
    
        for ( var i=1, len=arLen; i<len; ++i ){
            objArr[i].hide();
        }    
    }
}

function ShowFileExplorer()
{
    //$("#FullImageExplorerWrapper").show();
       
    var wnd = $find($('[id$=ExplorerWindow]:not([class*=Rad])').attr("id"));
    wnd.show();
    //alert(wnd.get_contentFrame().contentWindow.document.$find("test"));
    //var oExplorer = wnd.get_contentFrame().contentWindow.find("testID"); 
    
    //oExplorer.get_grid().repaint(); // Repaint the grid ; 
    
}

function ImageExplorerSelect(path)
{

    //alert(path);
    $('[id$=imgPreview]').attr("src", path);
    $('[id$=hidImage]').attr("value", path);
}

var ImageMaxHeight = 170;
var ImageMaxWidth = 400;
function getImageHeight(height, width) 
{
    var mult;

    if (height >= width || height > ImageMaxHeight)
    {
        return ImageMaxHeight;
    }
    else
    {
        mult = width / height;
        return ImageMaxWidth / mult;
    }
}

function getImageWidth(height, width)
{
    //alert('width ' + width + ' ' + height);
    var mult;
    if (width >= height && height < ImageMaxHeight)
    {
        return ImageMaxWidth;
    }
    else
    {
        mult = height / width;
        return ImageMaxHeight / mult;
    }
}