function popHelpEdit(url,name,h,w)
{
	top1=((screen.height/2)-(h/2))
	left1=((screen.width/2)-(w/2))
	newwindow=window.open(url,name,'top='+top1+',left='+left1+',height='+h+',width='+w+',scrollbars=yes,resizable=no,personalbar=no,menubar=no');
	if (window.focus) {newwindow.focus()}
}

function popTextEdit(url)
{

	newwindow=window.open(url,'name','height=350,width=300,scrollbars=no,resizable=no, personalbar=no, menubar=no');
	if (window.focus) {newwindow.focus()}
	return false;
}

function openWindow(url, name, h, w)
{
	newwindow=window.open(url, name,'height=' + h + ',width=' + w + ',status=yes');
	if (window.focus) {newwindow.focus()}
//	return false;
}

function openContentWindow(url, name, h, w)
{
	newwindow=window.open(url, name,'height=' + h + ',width=' + w + ',resizable=yes,status=yes');
	//newwindow=window.open(url, name,'fullscreen=yes');
	
	if (window.focus) {newwindow.focus()}
//	return false;
}

function userInfo(userID)
{	
	var len = (document.location.href.toLowerCase().indexOf("aspx_customer") == -1) ? 0 : 2;

	var fullAppPath2 = "";
	var i = 0;
	
	for (i = 0; i < len; i++)
	    fullAppPath2 = fullAppPath2 + "../";
    
	var url = fullAppPath2 + "user_popup_info.aspx?userID="+userID;
	newwindow=window.open(url,'name','top=50, left=150, width=560, height=533, resizable=no, menubar=no, toolbar=no, scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function courseInfo(unitID)
{	
	var len = (document.location.href.toLowerCase().indexOf("aspx_customer") == -1) ? 0 : 2;

	var fullAppPath2 = "";
	var i = 0;
	
	for (i = 0; i < len; i++)
	    fullAppPath2 = fullAppPath2 + "../";
    
	var url = fullAppPath2 + "course_info.aspx?unitID="+unitID;
	newwindow=window.open(url,'name','top=50, left=150, width=560, height=560, resizable=no, menubar=no, toolbar=no, scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function contentInfo(contentID)
{	
	var len = (document.location.href.toLowerCase().indexOf("aspx_customer") == -1) ? 0 : 2;

	var fullAppPath2 = "";
	var i = 0;
	
	for (i = 0; i < len; i++)
	    fullAppPath2 = fullAppPath2 + "../";
    
	var url = fullAppPath2 + "course_info.aspx?contentID="+contentID;
	newwindow=window.open(url,'name','top=50, left=150, width=560, height=560, resizable=no, menubar=no, toolbar=no, scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function FullApplicationPath2()
{
    var s = "";
}

function FullApplicationPath()
{
    var s = "";
}

function openDatePicker(openerObj)
{
	var url = "common_date_picker?openerObj="+openerObj;
	newwindow=window.open(url,'name','height=400,width=300');
	if (window.focus) {newwindow.focus()}
	return false;
}

function openExamWindow(url,height,width,Myform,userID,examID,activityID,startQuestion,noContent) 
{
		var myform = Myform;
		var x;
		x = confirm(startQuestion);
		if (x)
		{
			//top1=((screen.height/2)-(height/2));
			//left1=((screen.width/2)-(width/2));
			//window.open("about:blank","Exam","top="+top1+",left="+left1+",height="+height+",width="+width+",scrollbars=no,resizable=no, personalbar=no, menubar=no");
			
			
			//case 16586 - orhan
//			var new_win;

//			try { new_win = window.open('about:blank', 'Exam', 'top=3000, left=5000, width=1, height=1'); new_win.close(); } catch (EE) { }

//			if (noContent == '1') {
//			    new_win = open("about:blank", "ExamNC", "resizable=no, top=0, left=0, menubar=no, toolbar=no, status location=no, scrollbars=no");
//			}
//			else {
//			    new_win = open("about:blank", "Exam", "resizable=no, top=0, left=0, menubar=no, toolbar=no, status location=no, scrollbars=no");
//			}
//			new_win.resizeTo(screen.availWidth,screen.availHeight);
//		
//			myform.action = url;
//			myform.elements["examID"].value = examID;
//			myform.elements["activityID"].value = activityID;
//			myform.elements["Co"].value = 1;
//			if (noContent == '1') {
//			    myform.target = "ExamNC";
//			}
//			else {
//			    myform.target = "Exam";
//			}
//
		    //			myform.submit();
		    var new_win;

		  //  new_win = window.open('about:blank', 'Exam', 'top=3000, left=5000, width=1, height=1'); new_win.close();

		    new_win = open("about:blank", "Exam", "resizable=no, top=0, left=0, menubar=no, toolbar=no, status location=no, scrollbars=no");
		    new_win.resizeTo(screen.availWidth, screen.availHeight);

		    myform.action = url;
		    myform.elements["examID"].value = examID;
		    myform.elements["activityID"].value = activityID;
		    myform.elements["Co"].value = 1;
		    myform.target = "Exam";
		    myform.submit();

		}
}


function getHTTPObject() {
  var xmlhttp = false;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

var http;
var domDoc;

function changeTablePageCount(count,linkPage)
{
	http = getHTTPObject();

	http.open("POST", "common_page_count_update.aspx?count=" + count, false);
	//http.onreadystatechange = handleHttpResponse;
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	http.send('');
	//window.location.href=window.location.href;
	//__doPostBack("","");
	//window.location.reload(false);
	try
	{
		window.navigate(linkPage);
	}
	catch (e)
	{
		window.location  = linkPage;
	}
}



function ask(hiddenButtonID, question)
{
	try
	{
		window.open ('confirm.aspx?id='+hiddenButtonID+'&q='+question,'ABlms', 'top=200, left=200, width=350, height=150, menubar=0, scrollbars=0, resizable=0');
		return false;
	}
	catch(e)
	{
		alert(hiddenButtonID);
		alert(e);
	}
}

function question(hiddenButtonID, questionText)
{
	var userDecision = confirm(questionText);
	if (userDecision)
	{
		try
		{		
			document.getElementById(hiddenButtonID).click();				
		}
		catch(e)
		{		
			alert(e);
		}
	}
	else
	{
		return;
	}
}

function navigateQuestion(question, navOK, navCancel)
{

	var x;
	x = confirm(question);
	if (x)
	{
		window.navigate(navOK);
	}
	else
	{
		if (navCancel == '')
			return;
		else
			window.navigate(navCancel);
	}
}

function navigateQuestionWithDocument(question, navOK, navCancel)
{

	var x;
	x = confirm(question);
	if (x)
	{
		document.location =  navOK;
	}
	else
	{
		if (navCancel == '')
			return;
		else
			document.location =  navCancel;
	}
}

function returnQuestion(question){

	var x;
	x = confirm(question);
		
	if (x)
		return true;
	else
		return false;
}

var defaultKey = 16524381;

function getDefaultKey()
{
	return defaultKey;
}

function isTrueDefaultKey(key)
{
	if (defaultKey == key)
		return true;
	else
		return false;
}

function openLink(link)
{
	window.open(link);
}

function delayf(tbl,i,quantAmount,interval,delaytime)
{
	var mytbl = document.getElementById(tbl);

	var rows = mytbl.rows;

	if (i == rows.length)
	{
		setTimeout("delayf1('"+tbl+"',"+quantAmount+","+interval+","+delaytime+",0)",delaytime);
		return false;
	}

	if (i >= rows.length)
		return false;

	if (rows[i].getAttribute("delay") != null && rows[i].getAttribute("delay") != "")
	{
		rows[i].style.display = "";
		rows[i].style.visibility = "visible";
		rows[i].style.filter = "alpha(opacity="+interval+")";
		rows[i].style.opacity = "."+interval+"";

		var j = quantAmount;
		for (j = quantAmount; j > 0; j--)
		{
			if (i >= j)
			{
				var tmp = j*interval;
				if (tmp >= 100)
				{
					rows[i-j].style.filter = "";
					rows[i-j].style.opacity = "";
				}
				else
				{
					rows[i-j].style.filter = "alpha(opacity="+tmp+")";
					rows[i-j].style.opacity = "."+tmp+"";
				}
			}
		}


	}

	var i1 = i + 1;
	setTimeout("delayf('"+tbl+"',"+i1+","+quantAmount+","+interval+","+delaytime+")",delaytime);
}

function delayf1(tbl,quantAmount,interval,delaytime,cur)
{
	var mytbl = document.getElementById(tbl);

	var rows = mytbl.rows;
	
	var j = quantAmount;
	for (j = quantAmount; j > 0; j--)
	{
		var tmp = (j+cur)*interval;
		if (rows.length >= j)
		{
			if (tmp >= 100)
			{
				rows[rows.length-j].style.filter = "";
				rows[rows.length-j].style.opacity = "";
			}
			else if (rows[i].getAttribute("delay") != null && rows[i].getAttribute("delay") != "")
			{
				rows[rows.length-j].style.filter = "alpha(opacity="+tmp+")";
				rows[rows.length-j].style.opacity = "."+tmp+"";
			}	
		}
	}

	if (quantAmount <= cur)
		return false;
	else
	{
		var cur1 = cur+1;
		setTimeout("delayf1('"+tbl+"',"+quantAmount+","+interval+","+delaytime+","+cur1+")",delaytime);
	}
}

function buttonConfirm(str_confirm)
{
    if (confirm(str_confirm))
        return true;
    else
        return false;
}

//IntBox komponenti için.
function IntAlert(txb,spnID)
{
	var str = trim(txb.value);
//	alert(str);
//	return;
	
	if (str.length > 0 && str.charAt(0) == '-')
	    str = str.substring(1,str.length-1);

	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;
	var i = 0;

 	for (i = 0; i < str.length && IsNumber == true; i++) 
	{ 
		Char = str.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
			break;
		}
	}

    if (spnID == null || spnID == "")
        return;
        
	if (IsNumber == true || str == "")
	{
	    try
	    {
		    document.getElementById(spnID).style.display = "none";
    		document.getElementById(spnID).style.visibility = "hidden";
    	}
    	catch (E)
    	{
    	}
	}
	else
	{
	    try
	    {
		    document.getElementById(spnID).style.display = "";
		    document.getElementById(spnID).style.visibility = "visible";
    	}
    	catch (E)
    	{
    	}
	}
}

function ltrim(str)
{
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}

function rtrim(str)
{
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}

function trim(str)
{
	return ltrim(rtrim(str));
}

function isWhitespace(charToCheck)
{
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}

function AddLog(logType, sysMessage, userMessage, logStatus)
{
    var _logType = (logType >= 0) ? logType : 577;
    var _logStatus = (logStatus == 0) ? 0 : 1;
    var _sysMessage = sysMessage; // url encode lazım mı?
    var _userMessage = userMessage; // url encode lazım mı?
    
	http = getHTTPObject();

	http.open("POST", "common_retrieve_custom_xml.aspx?xmlType=14&logType=" + _logType + "&logStatus=" + _logStatus + "&sysMessage=" + _sysMessage + "&userMessage=" + _userMessage, false);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	http.send('');
}

function MainPageCellOver(tbl)
{
    var rows = tbl.rows;
    var cells = rows[0].cells;
    cells[0].className = "mainPageElTopLeftOver";
    cells[1].className = "mainPageElTopOver";
    cells[2].className = "mainPageElTopRightOver";
    
    cells = rows[1].cells;
    cells[0].className = "mainPageElMidLeftOver";
    cells[1].className = "mainPageElMidOver";
    cells[2].className = "mainPageElMidOver";
    cells[3].className = "mainPageElMidRightOver";
    
    cells = rows[2].cells;
    cells[0].className = "mainPageElBottomLeftOver";
    cells[1].className = "mainPageElBottomOver";
    cells[2].className = "mainPageElBottomRightOver";
}

function MainPageCellOut(tbl)
{
    var rows = tbl.rows;
    var cells = rows[0].cells;
    cells[0].className = "mainPageElTopLeft";
    cells[1].className = "mainPageElTop";
    cells[2].className = "mainPageElTopRight";
    cells = rows[1].cells;
    cells[0].className = "mainPageElMidLeft";
    cells[1].className = "mainPageElMid";
    cells[2].className = "mainPageElMid";
    cells[3].className = "mainPageElMidRight";
    
    cells = rows[2].cells;
    cells[0].className = "mainPageElBottomLeft";
    cells[1].className = "mainPageElBottom";
    cells[2].className = "mainPageElBottomRight";
}


// Başla --- UserProperties.ascx ile ilgili fonksiyonlar

var myProps = new Array();
var resulthttpList = new Array(); //= getDDLHTTPObject();

function getddlData(propID, htmlElementID, propName, seciliOzellik, defaultName) {

    if (myProps[htmlElementID] == "ok") {
    
    }
    else {
        var busyImg = document.getElementById('imgbusy_' + propID);

        busyImg.style.display = '';
        busyImg.style.visibility = 'visible';

        var resulthttp = getDDLHTTPObject();

        resulthttpList.push(resulthttp);

     //   alert(htmlElementID);
        
        resulthttp.open("GET", 'common_retrieve_custom_xml.aspx' + '?' + 'propID=' + propID + '&htmlElementID=' +
	            htmlElementID + '&propName=' + propName + '&seciliOzellik=' + seciliOzellik +  '&defaultName=' +  defaultName +  '&xmlType=16', true);
        resulthttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        resulthttp.setRequestHeader("Content-Length", 1);

        resulthttp.onreadystatechange = getddlDataCallBack;  
                
        resulthttp.send(null);

       
    }
}


function getDDLHTTPObject() {
    var http = false;
    if (typeof ActiveXObject != "undefined") {
        try { http = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch (e) {
            try { http = new ActiveXObject("Microsoft.XMLHTTP"); }
            catch (E) { http = false; }
        }
    } else if (XMLHttpRequest) {
        try {
            http = new XMLHttpRequest();
        } catch (e) {
            http = false;
        }
    }
    return http;
}

function getddlDataCallBack() {

    var resulthttp;
    var nowbreak = false;

    //alert(resulthttpList.length);

    for (cnt = 0; cnt < resulthttpList.length; cnt++) {
        resulthttp = resulthttpList[cnt];

        try {
            if (resulthttp.readyState == 4) {
                if (resulthttp.status == 200) {

                    var tmpSelectedIndex = 0;
                    var propresult = resulthttp.responseText;

                    var defNameList = propresult.split("<prfbadftnam>");

                    var defaultName = defNameList[1];

                    var prpList = defNameList[0].split("<prfbaprpid>");

                    var propID = prpList[1];

                    var busyImg = document.getElementById('imgbusy_' + propID);

                    var htmleSplit = prpList[0].split("<prfbahtmle>");

                    var htmlElementID = htmleSplit[1];

                    var forbidSplit = htmleSplit[0].split("<prfba>");

                    var propList = forbidSplit[0].split("<prp>");

                    var forbidAllOption = false;
                    if (forbidSplit[1] == '1') {
                        forbidAllOption = true;
                    }

                    var tmpElement = document.getElementById(htmlElementID);

                    var tmpSelected = tmpElement.options[tmpElement.selectedIndex].value;

                    for (k = tmpElement.options.length - 1; k >= 0; k--) {
                        tmpElement.options[k] = null;
                    }
                    tmpElement.selectedIndex = -1;

                    if (forbidAllOption) {

                    }
                    else {
                        option = new Option(defaultName, defaultName);
                        tmpElement.options[tmpElement.length] = option;
                    }

                    for (i = 0; i < propList.length - 1; i++) {
                        var propInList = propList[i].split("<pr>");

                        option = new Option(propInList[0], propInList[1]);
                        tmpElement.options[tmpElement.length] = option;

                        if (propInList[1] == tmpSelected) {
                            tmpSelectedIndex = tmpElement.length - 1;
                        }

                    }

                    myProps[htmlElementID] = "ok";

                    document.getElementById(htmlElementID).selectedIndex = tmpSelectedIndex;

                    if (document.getElementById(htmlElementID).options.length > 9) {
                        document.getElementById(htmlElementID).size = 10;
                    }
                    else {
                        document.getElementById(htmlElementID).size = document.getElementById(htmlElementID).options.length
                    }


                    

                    busyImg.style.display = 'none';
                    busyImg.style.visibility = 'hidden';

                    resulthttpList[cnt] = null;
                }
            }
        }
        catch (e) {
        }

        if (nowbreak) {
            break;
        }
    }



}

function changeDDLSelection(propID, htmlElementID) {

    var tmpElement = document.getElementById(htmlElementID);

    document.getElementById("tbsv_" + propID).value = tmpElement.options[tmpElement.selectedIndex].value;
}

function changeDDLSelectionFocusLost(propID, htmlElementID) {
    var tmpElement = document.getElementById(htmlElementID);

    //Şimdilik burayı kapatıyorum, sayfada listeleme düğmesine basmayı zorlaştırıyor. Orhan
   // tmpElement.size = 1;
}


// Bit ---  UserProperties.ascx ile ilgili fonksiyonlar