﻿// Jscript

$(document).ready(function(){});

var dotnetprefix = "ctl00_ContentPlaceHolder1_";

function ConfirmBox(url,msg){
	        var conf = confirm(msg + "\n" + url); 
	        if(conf){
		        window.location.href = url; 
	        }
        }


function ImgSrcToggle(id,opensrc,closesrc) {
    var curr = $("#"+id).attr("src");
    
    if (curr==opensrc) {
        $("#"+id).attr("src",closesrc);
        //$("#naviparent").show();
    } else {
        $("#"+id).attr("src",opensrc);
    }
}

function toggleCheckBoxes(startswith,chktotal) {
    var b;
    var sbool = $("#"+ startswith.toString() + 'All').attr("checked");    
    for (b=1;b<=chktotal;b++) {
        if (sbool==true) {
            $("#"+ startswith.toString() + b.toString()).attr("checked",true);
        } else {
            $("#"+ startswith.toString() + b.toString()).attr("checked",false);
        }
    }
}

function toggleAllOption(startswith,index,chktotal) { 
    // should you select all and then deselect one of the other options
    // the select all check box needs to be deselected
    var that;
    var blAllOptionsChecked = true;
    var isItChecked;
    
    for (b=1;b<=chktotal;b++) {
        isItChecked = $("#"+ startswith.toString() + b.toString()).attr("checked");
        if (isItChecked==false) {
            blAllOptionsChecked = false;
        }
    }
    
    that = $("#"+ startswith.toString() + index.toString()).attr("checked");
    
    if (that==false&&blAllOptionsChecked==false) {
        $("#"+ startswith.toString() + 'All').attr("checked",false);
    
    } else if (blAllOptionsChecked==true) {
        $("#"+ startswith.toString() + 'All').attr("checked",true);  
        toggleCheckBoxes(startswith,chktotal);
        
    }
        
}


function toggleFade(objid) {
    var sty = $("#"+objid).attr("style");
    
    if (sty.indexOf('none')>0) {
        $("#"+objid).fadeIn();
    } else {
        $("#"+objid).fadeOut();
    }
    
    //alert($("#"+objid).attr("style"));
    
}

function Highlight(obj) {
    $(obj).attr("style","cursor:hand;background:#cccccc;");
}

function UnHighlight (obj,color) {
    $(obj).attr("style","background:"+color);
}

function AnimateDiv(divid,fromNum,toNum,axis) {
    var currheight = $("#"+divid).height();
    var currwidth = $("#"+divid).width();
    
    //alert(navigator.userAgent);
    
    if (axis=='y') { 
        if (currheight==fromNum) {  // minimize height
            if (navigator.userAgent.indexOf("Firefox")>0) {
                $("#"+divid).attr("style","overflow-y:auto;overflow-x:hidden;height:" + toNum.toString() + "px");
            } else {
                $("#"+divid).animate({height: toNum},800); // minimize 
            }
            
        } else {                    // maximize height
            if (navigator.userAgent.indexOf("Firefox")>0) {
                $("#"+divid).attr("style","overflow-y:auto;overflow-x:hidden;height:" + fromNum.toString() + "px");
                if (divid=="navison") {
                    setTimeout("$('#navison').hide();",1300);
                }
            } else {
                $("#"+divid).animate({height: fromNum},800); 
                if (divid=="navison") {
                    setTimeout("$('#navison').fadeOut();",1300);
                }
            }
        }
    } else { 
        if (currwidth==fromNum) {   // maximize width
            if (navigator.userAgent.indexOf("Firefox")>0) { //
                $("#"+divid).attr("style","overflow-y:auto;overflow-x:hidden;width:" + toNum.toString() + "px");
            } else {
                $("#"+divid).animate({width: toNum},800);   
            }
            
        } else {                    // minimize width
            if (navigator.userAgent.indexOf("Firefox")>0) {
                $("#"+divid).attr("style","overflow-y:auto;overflow-x:hidden;width:" + fromNum.toString() + "px");
                if (divid=="navison") {
                    setTimeout("$('#navison').hide();",1300);
                }
            } else {
                $("#"+divid).animate({width: fromNum},800);
                if (divid=="navison") {
                    setTimeout("$('#navison').hide();",1300);
                }
            }
            
            
        }
    }
}

function LoadFrame(Frame,URL){
	$("#"+Frame).attr("src",URL);
}

function LoadFrameParent(Frame,URL){
	if (navigator.userAgent.indexOf("Firefox")>0){
	    parent.document.getElementById(Frame).src=URL;
	} else {
	    parent.document[Frame].location.href=URL;}
}

function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} 
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 

function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} 
function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} 
function posRight() {return posLeft()+pageWidth();} 
function posBottom() {return posTop()+pageHeight();}