﻿// JScript File

//Global Variables
var gstrImg = "ctl00_ContentPlaceHolder1_";
var gstrTxt = "ctl00_ContentPlaceHolder1_";
//var gstrTxt = "ctl00$ContentPlaceHolder1$";

//Sets cursor to hand for mouseover
function mouseOverToHand(item)
{
    item.style.cursor= 'pointer';
}

//document.getElementById(id); 
function disp(ctl,tf)
{
    var obj = document.getElementById(ctl)
    if (tf == 't') {
        obj.style.display = "inline-block";
    } else {
        obj.style.display = "none";
    }
}

//Toggle Visibility
function dispHandle(obj) 
{
    if (obj.style.display == "none") {
        obj.style.display = "block";
    } else {
        obj.style.display = "none";
    }
}

//ImageSelect Returns Image    
function returnImage(img) 
{
    var qs = new Querystring();
    var iID = qs.get("ID");
    var imgPrev = window.opener.document.getElementById(gstrImg + "imgPrev"+iID);
    var imgVal = window.opener.document.getElementById(gstrTxt + "txtImageValue"+iID);
        imgPrev.src = img.src;
        imgVal.value = img.src;
        imgPrev.style.width = img.width;
        imgPrev.style.height = img.height;
        window.close();
}

//ImageSelect Returns No Image
function returnNoImage()
{
    var qs = new Querystring()
    var iID = qs.get("ID")
        window.opener.document.getElementById(gstrImg + "imgPrev"+iID).src = '';
        window.opener.document.getElementById(gstrTxt + "txtImageValue"+iID).value = '';
        window.close();
}

//QueryString Constructor
function Querystring_get(key, default_) {
    if (default_ == null) default_ = null;
	
    var value=this.params[key]
    if (value==null) value=default_;
	
    return value
} 

//Parses Query String
function Querystring(qs) {
    this.params = new Object()
    this.get=Querystring_get
	
    if (qs == null)
        qs=location.search.substring(1,location.search.length)

    if (qs.length == 0) return

    qs = qs.replace(/\+/g, ' ')
    var args = qs.split('&') // parse out name/value pairs separated via &
	
    for (var i=0;i<args.length;i++) {
        var value;
        var pair = args[i].split('=')
        var name = unescape(pair[0])

        if (pair.length == 2)
	        value = unescape(pair[1])
        else
	        value = name
		
        this.params[name] = value
    }
}

//Opens Popup Window. Size based on type requested
function popupWindow(type,id,pageId)
{
    var ht;
    var wd;

    switch (type) {
        case "Image":
            ht = 500;
            wd = 700;
            break;
        case "Upload":
            ht = 400;
            wd = 540;
            break;
        case "BucketEdit":
            ht = 460;
            wd = 640;
            break; 
        case "ContentEdit":
            ht = 500;
            wd = 640;
            break;                        
        case "ContentPhoto":
            ht = 320;
            wd = 440;
            break; 
        case "FileUpload":
            ht = 180;
            wd = 340;
            break; 
        case "FileEdit":
            ht = 320;
            wd = 440;
            break;     
        case "PhotoEdit":
            ht = 500;
            wd = 440;
            break;   
        case "TrainingEdit":
            ht = 640;
            wd = 720;
            break;                                         
    }
    //window.showModalDialog("Select" + type + ".aspx?ID="+id,"","dialogHeight:"+ht+"px;dialogWidth:"+wd+"px;status:no")

    window.open('/Select' + type + '.aspx?ID='+id+'&pageId='+pageId,'_popup_'+type+'_'+id,'height='+ht+',width='+wd+',status=no,resizable=no,scrollbars=auto,toolbar=no,location=no,menubar=no')
}

