﻿function Utilities() {
  
  isNS=(document.layers || (document.getElementById && !document.all)) ? true : false;
    this.confirmDialogue = function(msg, fn) {
        if (confirm(msg)) { fn(); } else { return false; }
    }
    this.getQueryStr = function(str) {
        qstr = window.location.search.substring(1);
        qarray = qstr.split("&");
        for (var i = 0; i < qarray.length; i++) {
            if (qarray[i].split("=")[0] == str) {
                return qarray[i].split("=")[1];
            }
        }
    }
    this.doClick = function(buttonName,e)
    {
        var url;
        var key;
          if(window.event)
              key = window.event.keyCode;   
         else
		{key = e.which; }
        if (key == 13)
        { 
     
        __doPostBack(buttonName,'');}
    } 
    
 this.onlyPagingNumber=function(e) {
var keyCode = (isNS) ? e.which : e.keyCode;
if ((keyCode<48 || keyCode>57)&&keyCode!=8&&keyCode!=0&&keyCode!=44&&keyCode!=13){
	return false;}
	}
	
	
 this.SetUniqueRadioButton=function (nameregex, current)
 {
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;
 }

 

    
}
 var util = new Utilities();   
 
 
 //********************//
//** kutu kontrol //

function clearField(field) {
	if (field.value == field.defaultValue) {
	field.value = "";
	}
}	
function checkField(field) {
	if (field.value == "") {
	field.value = field.defaultValue;
	}
	
	
	 this.Hash = function() {
        this.length = 0;
        this.items = new Array();
        for (var i = 0; i < arguments.length; i += 2) {
            if (typeof (arguments[i + 1]) != 'undefined') {
                this.items[arguments[i]] = arguments[i + 1];
                this.length++;
            }
        }

        this.removeItem = function(in_key) {
            var tmp_previous;
            if (typeof (this.items[in_key]) != 'undefined') {
                this.length--;
                var tmp_previous = this.items[in_key];
                delete this.items[in_key];
            }

            return tmp_previous;
        }

        this.getItem = function(in_key) {
            return this.items[in_key];
        }

        this.setItem = function(in_key, in_value) {
            var tmp_previous;
            if (typeof (in_value) != 'undefined') {
                if (typeof (this.items[in_key]) == 'undefined') {
                    this.length++;
                }
                else {
                    tmp_previous = this.items[in_key];
                }

                this.items[in_key] = in_value;
            }

            return tmp_previous;
        }

        this.hasItem = function(in_key) {
            return typeof (this.items[in_key]) != 'undefined';
        }

        this.clear = function() {
            for (var i in this.items) {
                delete this.items[i];
            }

            this.length = 0;
        }
    }


}





function OpenTraining(strOrgOrAtt) {

    var a;
    if ((a = strOrgOrAtt.match(/^Org:([0-9]+)$/)) != null) {
        var args = new Object;
        args.OrganizationId = a[1];
        args.OnAttemptCreated = OnAttemptCreated;
        ShowDialog("CreateAttempt.aspx", args, 450, 250, false);
    }
    else
        if ((a = strOrgOrAtt.match(/^Att:([0-9]+)$/)) != null) {
        OpenFrameset(a[1]);
    }
}

/*Scrom*/
function OnAttemptCreated(strOrganizationId, strAttemptId) {

    var anchor = document.getElementById("Org_" + strOrganizationId);
    anchor.href = "javascript:OpenTraining('Att:" + strAttemptId + "')";
    anchor.title = "Eğitime Devam Et";
    OpenFrameset(strAttemptId);
}

function OpenFrameset(strAttemptId) {

    window.open("Frameset/Frameset.aspx?View=0&AttemptId=" + strAttemptId, "_blank");
}

function ShowDialog(strUrl, args, cx, cy, fScroll) {

    var useShowModalDialog = false;
    var strScroll = fScroll ? "yes" : "no";
    if (useShowModalDialog) {
        showModalDialog(strUrl, args,
				    "dialogWidth: " + cx + "px; dialogHeight: " + cy +
					"px; center: yes; resizable: yes; scroll: " + strScroll + ";");
    }
    else {
        dialogArguments = args; // global variable accessed by dialog
        var x = Math.max(0, (screen.width - cx) / 2);
        var y = Math.max(0, (screen.height - cy) / 2);
        window.open(strUrl, "_blank", "left=" + x + ",top=" + y +
					",width=" + cx + ",height=" + cy +
					",location=no,menubar=no,scrollbars=" + strScroll +
					",status=no,toolbar=no,resizable=yes");
    }
}


/*Scrom*/

 
 
