﻿// JScript File
var AjaxServerPageName = "AjaxServices.aspx";
function goToMainSearch()
{
    var drp = dcge('drpLanguages');
    var language = drp.value;
    var drp = dcge('drpCountries');
    var country = drp.value;
    var drp = dcge('drpCities');
    var city = drp.value;
    var drp = dcge('drpCenters');
    var center = drp.value;
    var drp = dcge('drpDurations');
    var duration = drp.value;
    
    if(language <= 0)
    {
        alert("Lütfen öğrenmek istediğiniz dil seçimi yapınız.");
        return false;
    }
    if(duration <= 0)
    {
        alert("Lütfen kurs süresini seçiniz");
        return false;
    }
    var start = new Date();
    document.location.href = 'SearchSchool.aspx?lng='+ language + '&cntry='+ country +'&cty='+ city  +'&cntr='+center  + '&drtn='+ duration  + "&par=" + start.getTime();
}
function searchOnload()
{
    fillLanguages();
    
    var queryString = window.top.location.search.substring(1);
    
    var language = getParameter( queryString, "lng" );
    var country = getParameter( queryString, "cntry" );
    var city = getParameter( queryString, "cty" );
    var center = getParameter( queryString, "cntr" );
    var duration = getParameter( queryString, "drtn" );
    
    var drp = dcge('drpLanguages');
    drp.value = language;
    getCountries();
    
    var drp = dcge('drpCountries');
    drp.value = country;
    getCities();
    var drp = dcge('drpCities');
    drp.value = city;
    getCenters();
    var drp = dcge('drpCenters');
    drp.value = center;
    var drp = dcge('drpDurations');
    drp.value = duration;
    
    dilOkullariGetir(language, country, city, center, duration);
}
function fillLanguages()
{
    var res = callWS("getLanguages","" );

     if(res.indexOf("HATA:")>-1){		
		  WriteError(res,"../");
		  return false;
	}
	else
	{
    	 if(res != '')
            {
                fillListboxCallWs(res,'drpLanguages',0,'Seçiniz');                                    
  
            }
            else
            {
                alert("Dil seçenekleri yüklenmemiştir.");
                return false;
            }   
    //FetchDRPContents('getLanguages','');
    }
}
function getCountries()
{
    var txt = dcge('drpLanguages');
    var language = txt.value;
    
    if(language != 0)
    {
        var res = callWS("getDORACountries","",language );

         if(res.indexOf("HATA:")>-1){		
		      WriteError(res,"../");
		      return false;
	    }
	    else
	    {
    	     if(res != '')
                {
                    fillListboxCallWs(res,'drpCountries',0,'Seçiniz');                                    
      
                }
                else
                {
                    alert("Ülke seçenekleri yüklenmemiştir.");
                    return false;
                }   
        
        }
        //FetchDRPContentsCountries('getDORACountries',language);
    }
}

function getCities()
{
    var txt = dcge('drpLanguages');
    var language = txt.value;
    
    var txt = dcge('drpCountries');
    var country = txt.value;
    
    if(country != 0)
    {
        var res = callWS("getDORACities","",language, country );

         if(res.indexOf("HATA:")>-1){		
		      WriteError(res,"../");
		      return false;
	    }
	    else
	    {
    	     if(res != '')
                {
                    fillListboxCallWs(res,'drpCities',0,'Seçiniz');                                    
      
                }
                else
                {
                    alert("Şehir seçenekleri yüklenmemiştir.");
                    return false;
                }   
        
        }
        //FetchDRPContentsCities('getDORACities', language, country);
    }
}

function getCenters()
{
    var txt = dcge('drpLanguages');
    var language = txt.value;
    
    var txt = dcge('drpCountries');
    var country = txt.value;
    
    var txt = dcge('drpCities');
    var city = txt.value;
    
    if(city != 0 )
    {
        var res = callWS("getDORACenters","",language, country, city );

         if(res.indexOf("HATA:")>-1){		
		      WriteError(res,"../");
		      return false;
	    }
	    else
	    {
    	     if(res != '')
                {
                    fillListboxCallWs(res,'drpCenters',0,'Seçiniz');                                    
      
                }
                else
                {
                    alert("Merkez seçenekleri yüklenmemiştir.");
                    return false;
                }   
        
        }
        //FetchDRPContentsCenters('getDORACenters', language, country, city);
    }
}


function FetchDRPContents(fonksiyon, par1)
{
	//Starts displaying the Process Image table
	imgtbl.style.visibility = 'visible';
	var requestUrl = AjaxServerPageName + "?fnName=" + encodeURIComponent(fonksiyon) + "&par1=" + par1 + "&par2=" + start.getTime();;
	
	CreateXmlReq();
	
	if(XmlReq)
	{
		XmlReq.onreadystatechange = HandleResponseFillLanguages;
		XmlReq.open("GET", requestUrl,  true);
		XmlReq.send();		
	}
}
function HandleResponseFillLanguages()
{
	if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
			// Before filling new contents into the DataGrid, clear the cotents by calling this function
			// Fill the cleared Datagrid with new XML Reponse
			fillListbox(XmlReq.responseXML.documentElement,'drpLanguages',false,'Seçiniz');
			// Hides the Process Image Table after displaying the contents
			imgtbl.style.visibility = 'hidden';
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
function FetchDRPContentsCountries(fonksiyon, par1)
{
	//Starts displaying the Process Image table
	imgtbl.style.visibility = 'visible';
	var requestUrl = AjaxServerPageName + "?fnName=" + encodeURIComponent(fonksiyon) + "&par1=" + par1 + "&par2=" + start.getTime();;
	
	CreateXmlReq();
	
	if(XmlReq)
	{
		XmlReq.onreadystatechange = HandleResponseFillCountries;
		XmlReq.open("GET", requestUrl,  true);
		XmlReq.send();		
	}
}
function HandleResponseFillCountries()
{
	if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
			// Before filling new contents into the DataGrid, clear the cotents by calling this function
			// Fill the cleared Datagrid with new XML Reponse
			fillListbox(XmlReq.responseXML.documentElement,'drpCountries',false,'Tüm Ülkeler');
			// Hides the Process Image Table after displaying the contents
			imgtbl.style.visibility = 'hidden';
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
function FetchDRPContentsCities(fonksiyon, par1, par2)
{
	//Starts displaying the Process Image table
	imgtbl.style.visibility = 'visible';
	var requestUrl = AjaxServerPageName + "?fnName=" + encodeURIComponent(fonksiyon) + "&par1=" + par1 + "&par2=" + par2 + "&par3=" + start.getTime();;
	
	CreateXmlReq();
	
	if(XmlReq)
	{
		XmlReq.onreadystatechange = HandleResponseFillCities;
		XmlReq.open("GET", requestUrl,  true);
		XmlReq.send();		
	}
}
function HandleResponseFillCities()
{
	if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
			// Before filling new contents into the DataGrid, clear the cotents by calling this function
			// Fill the cleared Datagrid with new XML Reponse
			fillListbox(XmlReq.responseXML.documentElement,'drpCities',false,'Tüm şehirler');
			// Hides the Process Image Table after displaying the contents
			imgtbl.style.visibility = 'hidden';
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
function FetchDRPContentsCenters(fonksiyon, par1, par2, par3)
{
	//Starts displaying the Process Image table
	imgtbl.style.visibility = 'visible';
	var requestUrl = AjaxServerPageName + "?fnName=" + encodeURIComponent(fonksiyon) + "&par1=" + par1 + "&par2=" + par2 + "&par3=" +par3 + "&par4=" + start.getTime();;
	
	CreateXmlReq();
	
	if(XmlReq)
	{
		XmlReq.onreadystatechange = HandleResponseFillCenters;
		XmlReq.open("GET", requestUrl,  true);
		XmlReq.send();		
	}
}
function HandleResponseFillCenters()
{
	if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
			// Before filling new contents into the DataGrid, clear the cotents by calling this function
			// Fill the cleared Datagrid with new XML Reponse
			fillListbox(XmlReq.responseXML.documentElement,'drpCenters',false,'Tüm Merkezler');
			// Hides the Process Image Table after displaying the contents
			imgtbl.style.visibility = 'hidden';
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
function dilOkullariGetir(language, country, city, center, duration)
{  
       FetchDGContents('getDORACourses',language, country, city, center, duration);    			
}
function dilOkullariGetirButton()
{

    var txt = dcge('drpLanguages');
    var language = txt.value;
    
    var txt = dcge('drpCountries');
    var country = txt.value;
    
    var txt = dcge('drpCities');
    var city = txt.value;
    
    var txt = dcge('drpCenters');
    var center = txt.value;
    
    var txt = dcge('drpDurations');
    var duration = txt.value;
    
       FetchDGContents('getDORACourses',language, country, city, center, duration);    			
}

var XmlReq;
// This page returns the XML Response for the selected choice
function CreateXmlReq()
{
	try
	{
		XmlReq = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlReq = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlReq = null;
		}
	}
	if(!XmlReq && typeof XMLHttpRequest != "undefined") 
	{
		XmlReq = new XMLHttpRequest();
	}
}

//This fucntion is to send the choice into the AJAX Server page for processing


function HandleResponse()
{
	if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
			// Before filling new contents into the DataGrid, clear the cotents by calling this function
			ClearTable();
			// Fill the cleared Datagrid with new XML Reponse
			FillTable(XmlReq.responseXML.documentElement);
			// Hides the Process Image Table after displaying the contents
			imgtbl.style.visibility = 'hidden';
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
function createHeader()
{
    var tbl = document.getElementById('tblList').getElementsByTagName("tbody")[0];
    //
    var row = document.createElement("TR"); 	  
    var cell = document.createElement("TD"); 
    cell.innerHTML = "Sec";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);
    // 
    var cell = document.createElement("TD");
    cell.innerHTML = "<img src='images/Filtre.png' /> Ülke";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    // 
    var cell = document.createElement("TD");
    cell.innerHTML = "<img src='images/Filtre.png' /> Şehir";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "<img src='images/Filtre.png' /> Birim";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    // 
    var cell = document.createElement("TD");
    cell.innerHTML = "<img src='images/Filtre.png' /> Şirket";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    // 
    var cell = document.createElement("TD");
    cell.innerHTML = "<img src='images/Filtre.png' /> Kurs Tipi";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "Haftalık Ders Saati";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "<img src='images/Filtre.png' /> Fiyatlama </br> Sistemi";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell); 
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "<img src='images/Detay.png' /> Detay";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);     
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "Başvuru Ücreti";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "Kurs Ücreti";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell); 
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "Para Birimi";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "<img src='images/Detay.png' /> Konaklama </br> Seçenekleri";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    //
    tbl.appendChild(row);

    
}
function createData(auth)
{
    var tbl = document.getElementById('tblList').getElementsByTagName("tbody")[0];
    for(var i=0;i<auth.context.childNodes(0).parentNode.childNodes.length;i++)
	{
	    var className= "";
	    if(i%2 == 0)
	    {
	        className= "alternate";
	    }
	    else
	    {
	        className= "alternate2";
	    }	
	   //
	    var row = document.createElement("TR"); 
	    row.setAttribute("className","text");
	    row.setAttribute("bgColor","#ECECEC");
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = "<input type=checkbox id='chk" + auth.context.childNodes(i).childNodes(0).text + "' value='unchecked' onclick= 'selectRow(" + auth.context.childNodes(i).childNodes(0).text + ");' >" ;		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	   
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = "<a href='#' onclick='getCoursesByCountry("+ auth.context.childNodes(i).childNodes(2).text +")' > " + auth.context.childNodes(i).childNodes(1).text + "</a>";		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = "<a href='#' onclick='getCoursesByCity("+ auth.context.childNodes(i).childNodes(4).text +")' > " + auth.context.childNodes(i).childNodes(3).text + "</a>";		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = "<a href='#' onclick='getCoursesByCenter("+ auth.context.childNodes(i).childNodes(6).text +")' > " + auth.context.childNodes(i).childNodes(5).text + "</a>";		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = "<img src='images/schoolsmall/" + auth.context.childNodes(i).childNodes(18).text + "' onclick='getCoursesByCompany("+ auth.context.childNodes(i).childNodes(8).text +")' alt='" + auth.context.childNodes(i).childNodes(7).text + "' style='cursor:hand' ></img>";		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = "<a href='#' onclick='getCoursesByCourseType("+ auth.context.childNodes(i).childNodes(10).text +")' > " + auth.context.childNodes(i).childNodes(9).text + "</a>";		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = auth.context.childNodes(i).childNodes(11).text ;		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = "<a href='#' onclick='getCoursesByAccType("+ auth.context.childNodes(i).childNodes(13).text +")' > " + auth.context.childNodes(i).childNodes(12).text + "</a>";		  	  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	     //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = "<a href='#' onmouseover='getCourseDetail("+ auth.context.childNodes(i).childNodes(0).text +");' onmouseout='ClosePanel();'  > Kurs Detayı</a>";		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //	  
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = auth.context.childNodes(i).childNodes(14).text ;		  	  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //  	    
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = auth.context.childNodes(i).childNodes(15).text ;		  	  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    // 
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = auth.context.childNodes(i).childNodes(16).text ;		  	  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    // 
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = "<a href='#' onmouseover='getAccoList("+ auth.context.childNodes(i).childNodes(17).text +")' onmouseout='ClosePanel3();' > Konaklama Seçenekleri</a>";		  	  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //	
	    tbl.appendChild(row)
	 }
}
//Fills the datagrid contents with the newly recieved Response content
function FillTable(scity)
{
	// Gets the response XML
	var auth = scity.getElementsByTagName('TABLE'); 
	// Gets the table type content present in the Response XML and gets the data into a variable tbl
	var tbl = document.getElementById('tblList').getElementsByTagName("tbody")[0];

    if(auth.context.childNodes(0))
    {      	         	                         
        createHeader();
        //DATA
        createData(auth);
        selectedRows = 0;
	}
}

// Clearing the existing contents of the Datagrid
function ClearTable()
{
	var dg = document.getElementById('tblList');
	if(dg)
	{
	    var tbl = document.getElementById('tblList').getElementsByTagName("tbody")[0];
	    //tbl.innerHTML ='';
	    var row = tbl.rows.length
	    for (var i=1,j=1;j<=row;i++,j++)
	    {
	    tbl.deleteRow(row-i);
		    /*if (tbl.rows.length == 2){i = 1;}
		    tbl.deleteRow(i);
		    if (tbl.rows.length == i) {i = 0;}*/
	    }
	}
}
function GetSelected()
{
    var tbl = document.getElementById('tblList').getElementsByTagName("tbody")[0];
    var rowNumber = tbl.rows.length;
    var result = document.getElementById('txtResult');
    for (var i=1,j=1;j<rowNumber;i++,j++)
	{
	    chk = document.getElementById('chk'+ tbl.rows[rowNumber-i].cells[1].innerText)
	    if(chk.checked == true)
	    {
	        result.value = result.value + ' ' + tbl.rows[rowNumber-i].cells[1].innerText;
	    }
	}
}
function FetchDGContents(fonksiyon, par1,par2,par3,par4,par5)
{
	//Starts displaying the Process Image table
	imgtbl.style.visibility = 'visible';
	var start = new Date();
	var requestUrl = AjaxServerPageName + "?fnName=" + encodeURIComponent(fonksiyon) + "&par1=" + par1+ "&par2=" + par2+ "&par3=" + par3+ "&par4=" + par4+ "&par5=" + par5 + "&par6=" + start.getTime();
	
	CreateXmlReq();
	
	if(XmlReq)
	{
		XmlReq.onreadystatechange = HandleResponse;
		XmlReq.open("GET", requestUrl,  true);
		XmlReq.send();		
	}
}
function fillListbox(res,drpid,onlyCode,drp0)
{
    // Gets the response XML
	var auth = res.getElementsByTagName('TABLE'); 
	// Gets the table type content present in the Response XML and gets the data into a variable tbl
	var drp = document.getElementById(drpid);
	clearListbox(drp.id,drp0);
    
    if(auth.context.childNodes(0))
    {
        for(var i=1;i<=auth.context.childNodes(0).parentNode.childNodes.length;i++)
	    {       
		    if(!onlyCode)
            {
                drp.options[i]=new Option(auth.context.childNodes(i-1).childNodes(1).text ,auth.context.childNodes(i-1).childNodes(0).text);
            }
            else
            {
                drp.options[i]=new Option(auth.context.childNodes(i-1).childNodes(0).text + " - " + auth.context.childNodes(i-1).childNodes(1).text ,auth.context.childNodes(i-1).childNodes(0).text);
            }		
	    }
	}
	else
	{
	    alert("Gerekli data olmadigi icin liste doldurulamamaktadir.");
	}
}
function fillListboxCallWs(res,drpid,onlyCode,drp0)
{
    var drp = dcge(drpid);
    var arr = res.split("||");
    var a=0;
    clearListbox(drp.id,drp0);
    
    while(a<arr.length && res.length>0 )
    {
        if(!onlyCode)
        {
            drp.options[(a/2)+1]=new Option(arr[a+1] ,arr[a]);
        }
        else
        {
            drp.options[(a/2)+1]=new Option(arr[a] + " - " + arr[a+1],arr[a]);
        }
        a+=2;
    }
}
function clearListbox(drpid,drp0){
	
	var drp = dcge(drpid);
    if(drp)
    {
        drp.innerHTML='';
       
        drp[0] = new Option(drp0,"0");
      
    }
}

function  getParameter( queryString, parameterName )
{
    var parameterName = parameterName + '=';
    if(queryString.length > 0 ){
        begin = queryString.indexOf(parameterName);
        if(begin != -1){
            begin += parameterName.length ;
            end = queryString.indexOf("&", begin);
            if(end == -1){
                end = queryString.length;
            }
            return queryString.substring(begin,end);
        }
        return null;
    }    
}
function getCoursesByCountry(countryCode)
{
    var txt = dcge('drpLanguages');
    var language = txt.value;
    
    var txt = dcge('drpDurations');
    var duration = txt.value;
    
    FetchDGContents('getDORACourses',language, countryCode, 0, 0, duration); 
}
function getCoursesByCity(cityCode)
{
    var txt = dcge('drpLanguages');
    var language = txt.value;
    
    var txt = dcge('drpDurations');
    var duration = txt.value;
    
    FetchDGContents('getDORACourses',language, 0, cityCode, 0, duration); 

}

function getCoursesByCenter(centerCode)
{
    var txt = dcge('drpLanguages');
    var language = txt.value;
    
    var txt = dcge('drpDurations');
    var duration = txt.value;
    
    FetchDGContents('getDORACourses',language, 0, 0, centerCode, duration); 

}
function getCoursesByCompany(companyCode)
{
    var txt = dcge('drpLanguages');
    var language = txt.value;
    
    var txt = dcge('drpDurations');
    var duration = txt.value;
    
    FetchDGContents('getDORACoursesByCompany',language, duration, companyCode); 

}
function getCoursesByCourseType(courseType)
{
    var txt = dcge('drpLanguages');
    var language = txt.value;
    
    var txt = dcge('drpDurations');
    var duration = txt.value;
    
    FetchDGContents('getDORACoursesByCourseType',language, duration, courseType); 
}
function getCoursesByAccType(accTypeCode)
{
    var txt = dcge('drpLanguages');
    var language = txt.value;
    
    var txt = dcge('drpDurations');
    var duration = txt.value;
    
    FetchDGContents('getDORACoursesByAccType',language, duration, accTypeCode); 

}
function getCourseDetail(courseDetail)
{
    CourseDetail.style.visibility = 'visible';

    fillCourseDetail(courseDetail);
    fillCoursePrices(courseDetail);
    
    var IE = document.all?true:false;
    var tempX = 0;
    var tempY = 0;
    if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft :document.body.scrollLeft);
    tempY = event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop :document.body.scrollTop);
    }
    else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
    }  
    if (tempX < 0){tempX = 0;}
    if (tempY < 0){tempY = 0;}  

    Panel2.style.left = tempX-540 ;
    Panel2.style.top = tempY-500 ;

}
function ClosePanel()
{

    CourseDetail.style.visibility = 'hidden';
}
function ShowPanel()
{
    CourseDetail.style.visibility = 'visible';
}

function ClosePanel3()
{
    AccomodationList.style.visibility = 'hidden';
}
function ShowPanel3()
{
    AccomodationList.style.visibility = 'visible';
}
function fillCourseDetail(CourseCode)
{
     var tbl = document.getElementById('tblCourseDetail').getElementsByTagName("tbody")[0];
     ClearTables("tblCourseDetail");
     var res = callWS("getCourseSummary","", CourseCode );

     if(res.indexOf("HATA:")>-1){		
		  WriteError(res,"../");
		  return false;
	}
	else
	{
    	 if(res != '')
            {
                var arr = res.split("||");  
                //    
                var row = document.createElement("TR");                 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Okul:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[0];
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Kurs Tipi:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[1];
                row.appendChild(cell);                 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR"); 
                
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Ek Bilgi:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[4];
                row.appendChild(cell);                 
                tbl.appendChild(row);

            }
            else
            {
                alert("Seçtiğiniz kursa ait detaylar bulunamamıştır.");
                return false;
            }     

	}
	
	var res = callWS("getCourseDetail","", CourseCode );

     if(res.indexOf("HATA:")>-1){		
		  WriteError(res,"../");
		  return false;
	}
	else
	{
    	 if(res != '')
            {
                var arr = res.split("||");  
                //    
                var row = document.createElement("TR");                 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Haftalık Ders Saati:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[3];
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR");  
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Başvuru ücreti:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[5] + " " + arr[6];
                row.appendChild(cell);                 
                tbl.appendChild(row)
                
               if(arr[8] != "0")
               {                
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Yaş Aralığı:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[7] + " " + arr[8];
                row.appendChild(cell);                 
                tbl.appendChild(row)
                }
                
                if(arr[9] != "01/01/1900")
               {
                var row = document.createElement("TR"); 

                //
                 var cell = document.createElement("TD"); 
                cell.innerHTML = "Tarih Aralığı:";
                cell.setAttribute("className","ptoolbar");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[9] + " " + arr[10];
                row.appendChild(cell);
        	    tbl.appendChild(row)
                }
                
                if(arr[9] != "01/01/1900")
               {
                var row = document.createElement("TR"); 
                row.setAttribute("className","ptoolbar");
                row.setAttribute("bgColor","#ECECEC");
                //
                 var cell = document.createElement("TD"); 
                cell.innerHTML = "Seans:";
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[11] ;
                row.appendChild(cell);
        	    tbl.appendChild(row) 
                }
                 
            }
            else
            {
                alert("Seçtiğiniz kursa ait detaylar bulunamamıştır.");
                return false;
            }     

	}
}

function ClearTables(tableId)
{
	var dg = document.getElementById(tableId);
	if(dg)
	{
	    var tbl = document.getElementById(tableId).getElementsByTagName("tbody")[0];
	    //tbl.innerHTML ='';
	    var row = tbl.rows.length
	    for (var i=1,j=1;j<=row;i++,j++)
	    {
	    tbl.deleteRow(row-i);
		    /*if (tbl.rows.length == 2){i = 1;}
		    tbl.deleteRow(i);
		    if (tbl.rows.length == i) {i = 0;}*/
	    }
	}
}
function fillCoursePrices(courseDetail)
{
     
     FetchDGContentsRates('getCourseRates', courseDetail);
}
function FetchDGContentsRates(fonksiyon, par1,par2,par3,par4,par5)
{
	//Starts displaying the Process Image table
	imgtbl.style.visibility = 'visible';
	var start = new Date();
	var requestUrl = AjaxServerPageName + "?fnName=" + encodeURIComponent(fonksiyon) + "&par1=" + par1+ "&par2=" + start.getTime()+ "&par3=" + par3+ "&par4=" + par4+ "&par5=" + start.getTime();
	
	CreateXmlReq();
	
	if(XmlReq)
	{
		XmlReq.onreadystatechange = HandleResponseRates;
		XmlReq.open("GET", requestUrl,  true);
		XmlReq.send();		
	}
}

function HandleResponseRates()
{
	if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
			// Before filling new contents into the DataGrid, clear the cotents by calling this function
			ClearTables('tblListWeekly');
			ClearTables('tblListTermly');
			// Fill the cleared Datagrid with new XML Reponse
			FillTables(XmlReq.responseXML.documentElement);
			// Hides the Process Image Table after displaying the contents
			imgtbl.style.visibility = 'hidden';
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

function FillTables(srates)
{
	var weekRates = srates.getElementsByTagName('TABLE'); 
    fillTablesFromXML('tblListWeekly','tblListTermly',weekRates);	

}

function fillTablesFromXML(tblName1,tblName2,content)
{
    var tblWeek = document.getElementById(tblName1).getElementsByTagName("tbody")[0];
	var tblTerm = document.getElementById(tblName2).getElementsByTagName("tbody")[0];
			
	// Iterate through the table and add HTML Rows & contents into it.
	var isHeaderTerm = 0;
	var isHeaderWeek = 0;

    if(content.context.childNodes(0))
    {      	         	         
        for(var i=0;i<content.context.childNodes(0).parentNode.childNodes.length;i++)
	    {  
	           
	        //Header
	        if(isHeaderTerm == 0) 
	        {
	            if(content.context.childNodes(i).nodeName == "TERM")
	            {
	                var row = document.createElement("TR"); 	  

                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Kurs Dönemi";
                    cell.setAttribute("className","Baslik");
                    row.appendChild(cell); 
                    
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Dönem Süresi (Hafta)";
                    cell.setAttribute("className","Baslik");
                    row.appendChild(cell); 
                    
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Dönemlik Ücret";
                    cell.setAttribute("className","Baslik");
                    row.appendChild(cell); 
                   
                    if(content.context.childNodes(i).childNodes(6).text != "01/01/1900")
                    {
                        var cell = document.createElement("TD"); 
                        cell.innerHTML = "Dönem Tarih Aralığı";
                        cell.setAttribute("className","Baslik");
                        row.appendChild(cell);                    
                    }

                    tblTerm.appendChild(row);

	                isHeaderTerm = 1;
	            }

	        } 
	        if(isHeaderWeek == 0) 
	        {
	            if(content.context.childNodes(i).nodeName == "WEEK")
	            {
	                var row = document.createElement("TR"); 	  
 
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Kurs Süresi (Hafta)";
                    cell.setAttribute("className","Baslik");
                    row.appendChild(cell); 
                    
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Haftalık Ücret";
                    cell.setAttribute("className","Baslik");
                    row.appendChild(cell); 
                    
                    tblWeek.appendChild(row);

	                isHeaderWeek = 1;

	            }

	        } 
	        //DATA week
	            var className= "";
	            if(i%2 == 0)
	            {
	                className= "alternate";
	            }
	            else
	            {
	                className= "alternate2";
	            }	
	        if(content.context.childNodes(i).nodeName == "WEEK")
            {
	            // Create an HTML Row
	            var row = document.createElement("TR"); 
        		
	            // Set the style
	            row.setAttribute("className","text");
	            row.setAttribute("bgColor","#ECECEC");
	   
	            // Create a HTML DataColumn
	            var cell = document.createElement("TD"); 
	            cell.innerHTML = content.context.childNodes(i).childNodes(1).text + " - " + content.context.childNodes(i).childNodes(2).text + " Hafta";
	            cell.setAttribute("className",className);
	            row.appendChild(cell); 
	            // Create a HTML DataColumn
	            var cell = document.createElement("TD"); 
	            cell.innerHTML = content.context.childNodes(i).childNodes(3).text + " " + content.context.childNodes(i).childNodes(4).text;
	            cell.setAttribute("className",className);
	            row.appendChild(cell); 
	          
	            // Append the current row into the HTML Table(i.e DataGrid)
	            tblWeek.appendChild(row);
	        }
	        //DATA Term
	        if(content.context.childNodes(i).nodeName == "TERM")
            {
	            // Create an HTML Row
	            var row = document.createElement("TR"); 
        		
	            // Set the style
	            row.setAttribute("className","text");
	            row.setAttribute("bgColor","#ECECEC");
	            //check box

	            // Create a HTML DataColumn
	            var cell = document.createElement("TD"); 
	            cell.innerHTML = content.context.childNodes(i).childNodes(1).text;
	            cell.setAttribute("className",className);
	            row.appendChild(cell); 
	            // Create a HTML DataColumn
	            var cell = document.createElement("TD"); 
	            cell.innerHTML = content.context.childNodes(i).childNodes(2).text + " Hafta";
	            cell.setAttribute("className",className);
	            row.appendChild(cell); 
	            // Create a HTML DataColumn
	            var cell = document.createElement("TD"); 
	            cell.innerHTML = content.context.childNodes(i).childNodes(3).text + " " + content.context.childNodes(i).childNodes(4).text;
	            cell.setAttribute("className",className);
	            row.appendChild(cell); 
	            // Create a HTML DataColumn
	            if(content.context.childNodes(i).childNodes(6).text != "01/01/1900")
                {
	                var cell = document.createElement("TD"); 
	                cell.innerHTML = content.context.childNodes(i).childNodes(5).text + " - " + content.context.childNodes(i).childNodes(6).text;
	                cell.setAttribute("className",className);
	                row.appendChild(cell);
	            }

	            // Append the current row into the HTML Table(i.e DataGrid)
	            tblTerm.appendChild(row);
	        }
	    }
	}
}

function getAccoList(schoolCode)
{
    AccomodationList.style.visibility = 'visible';
    SchoolCode = schoolCode;
    fillDurations("drpAccoDuration");
    fillAccoLists();
    
    var IE = document.all?true:false;
    var tempX = 0;
    var tempY = 0;
    if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft :document.body.scrollLeft);
    tempY = event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop :document.body.scrollTop);
    }
    else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
    }  
    if (tempX < 0){tempX = 0;}
    if (tempY < 0){tempY = 0;}  

    Panel3.style.left = tempX - 500 ;
    Panel3.style.top = tempY - 540;
}
function fillAccoLists()
{    
     var drp = dcge("drpAccoDuration");
     var duration = drp.value;

     var info = dcge("lblAccoInfo");
     info.innerHTML = "" + duration + " Haftalık konaklama ile hesaplanmıştır" ;
    
     FetchDGContentsAccomodation("getDORAAccomodations",SchoolCode, duration);
}
function FetchDGContentsAccomodation(fonksiyon, par1,par2,par3,par4,par5)
{
	//Starts displaying the Process Image table
	imgtbl.style.visibility = 'visible';
	var start = new Date();
	var requestUrl = AjaxServerPageName + "?fnName=" + encodeURIComponent(fonksiyon) + "&par1=" + par1+ "&par2=" + par2+ "&par3=" + par3+ "&par4=" + par4+ "&par5=" + par5 + "&par6=" + start.getTime();
	
	CreateXmlReq();
	
	if(XmlReq)
	{
		XmlReq.onreadystatechange = HandleResponseAccomodation;
		XmlReq.open("GET", requestUrl,  true);
		XmlReq.send();		
	}
}

function HandleResponseAccomodation()
{
	if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
			// Before filling new contents into the DataGrid, clear the cotents by calling this function
			ClearTables("tblAccomodationList");
			// Fill the cleared Datagrid with new XML Reponse
			FillAccoTable(XmlReq.responseXML.documentElement, "tblAccomodationList");
			// Hides the Process Image Table after displaying the contents
			imgtbl.style.visibility = 'hidden';
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}


function FillAccoTable(scity, tblName)
{
	var auth = scity.getElementsByTagName('TABLE'); 


    if(auth.context.childNodes(0))
    {   
        ClearTables('tblAccomodationList')
    	createAccoHeader('tblAccomodationList');		
	    createAccoData(auth,'tblAccomodationList');   	         	                         
	}// Gets the response XML

}
function createAccoHeader(tableId)
{
     var tbl = document.getElementById(tableId).getElementsByTagName("tbody")[0];
    //
     var row = document.createElement("TR"); 
    //
    if(tableId == "tblSelectedAccomodationList")
    {
        var cell = document.createElement("TD");
        cell.innerHTML = "Seçiniz";
        cell.setAttribute("className","Baslik");
        row.appendChild(cell); 
    }
    var cell = document.createElement("TD");
    cell.innerHTML = "<img src='images/Detay.png' /> Detay";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    // 
    var cell = document.createElement("TD");
    cell.innerHTML = "Konaklama Tipi";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "Odadaki Kişi </br>Sayısı";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell); 
    // 
    var cell = document.createElement("TD");
    cell.innerHTML = "Fiyatlama </br>Sistemi";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);      
    // 
    var cell = document.createElement("TD");
    cell.innerHTML = "Rezervasyon </br>Ücreti";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    // 
    var cell = document.createElement("TD");
    cell.innerHTML = "Konaklama </br>Ücreti";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "Para </br>Birimi";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    //

    tbl.appendChild(row);
    
}

function createAccoData(auth,tableId)
{
     var tbl = document.getElementById(tableId).getElementsByTagName("tbody")[0];
     for(var i=0;i<auth.context.childNodes(0).parentNode.childNodes.length;i++)
	 {
	    var className= "";
        if(i%2 == 0)
        {
            className= "alternate";
        }
        else
        {
            className= "alternate2";
        }
	    //        
	    var row = document.createElement("TR"); 
	    row.setAttribute("className","text");
	    row.setAttribute("bgColor","#ECECEC");

        if(tableId == "tblSelectedAccomodationList")
        {
            var cell = document.createElement("TD");
            cell.innerHTML = "<input type=radio name='accoRadio' id='accoRadio' value=" + auth.context.childNodes(i).childNodes(0).text + "></input>";
            cell.setAttribute("className",className);
            row.appendChild(cell); 
        }
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = "<a href='#' onmouseover='getAccoDetail("+ auth.context.childNodes(i).childNodes(0).text +");' onmouseout='' > Konaklama Detayı</a>";		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML =  auth.context.childNodes(i).childNodes(2).text ;		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = auth.context.childNodes(i).childNodes(3).text ; 
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = "<a href='#' onclick='getCoursesByCenter("+ auth.context.childNodes(i).childNodes(4).text +")' > " + auth.context.childNodes(i).childNodes(5).text + "</a>";		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML =  auth.context.childNodes(i).childNodes(6).text ;
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = auth.context.childNodes(i).childNodes(7).text ;		  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);	 
	    //	  
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = auth.context.childNodes(i).childNodes(8).text ;		  	  
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	  
	    //	
	    tbl.appendChild(row)
	 }
	 
}

function getAccoDetail(accoCode)
{
    fillAccoPrices(accoCode);
    fillAccoDetails(accoCode);
    
    ShowPanel4();
    
        var IE = document.all?true:false;
    var tempX = 0;
    var tempY = 0;
    if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft :document.body.scrollLeft);
    tempY = event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop :document.body.scrollTop);
    }
    else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
    }  
    if (tempX < 0){tempX = 0;}
    if (tempY < 0){tempY = 0;}  

    Panel4.style.left = tempX - 500 ;
    Panel4.style.top = tempY - 540;

}
function fillAccoPrices(accoCode)
{
    FetchDGContentsAccoRates('getAccomodationRates', accoCode);
}
function fillAccoDetails(accoCode)
{
   
    var tbl = document.getElementById('tblAccoDetail').getElementsByTagName("tbody")[0];
    ClearTables("tblAccoDetail");
    var res = callWS("getAccomodationSummary","", accoCode );

    if(res.indexOf("HATA:")>-1){		
        WriteError(res,"../");
        return false;
    }
	else
	{
    	 if(res != '')
            {
                var arr = res.split("||");  
                    
                var row = document.createElement("TR"); 
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Okul:";
                cell.setAttribute("className","ptoolbar");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[0];
                row.appendChild(cell); 
                tbl.appendChild(row);                
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Konaklama Tipi:";
                cell.setAttribute("className","ptoolbar");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[1];
                row.appendChild(cell);                 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR");                 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Kişi Sayısı:";
                cell.setAttribute("className","ptoolbar");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[4];
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR");                 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Ek Bilgi:";
                cell.setAttribute("className","ptoolbar");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[5];
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
            }
            else
            {
                alert("Seçtiğiniz konaklamaya ait detaylar bulunamamıştır.");
                return false;
            }     
	}

}
var durations=
	[
	    0,
	    2,
	    3,
		4,
		5,
		6,
		7,
		8,
		12,
		16,
		20,
		24,
		28,
		32,
		36,
		48
	];
var SchoolCode = 0;
function fillDurations(drpId)
{
    var drp = document.getElementById('drpDurations');
    var courseDuration = drp.value;
    
    drp = document.getElementById(drpId);
	clearListbox(drp.id,'seçiniz');
   
    for(i=0 ;i<durations.length;i++)
    {
        if(durations[i] <= courseDuration)
        {
            drp.options[i]= new Option(durations[i] + " Hafta" , durations[i]);
        }
    }  
    drp.value =  courseDuration;     		
	
}
function FetchDGContentsAccoRates(fonksiyon, par1, par2, par3, par4, par5)
{
    //Starts displaying the Process Image table
	imgtbl.style.visibility = 'visible';
	var start = new Date();
	var requestUrl = AjaxServerPageName + "?fnName=" + encodeURIComponent(fonksiyon) + "&par1=" + par1+ "&par2=" + par2+ "&par3=" + par3+ "&par4=" + par4+ "&par5=" + par5 + "&par6=" + start.getTime();
	
	CreateXmlReq();
	
	if(XmlReq)
	{
		XmlReq.onreadystatechange = HandleResponseAcco;
		XmlReq.open("GET", requestUrl,  true);
		XmlReq.send();		
	}

}
function HandleResponseAcco()
{
	if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
			// Before filling new contents into the DataGrid, clear the cotents by calling this function
			ClearTables('tblAccoListWeekly');
			ClearTables('tblAccoListTerm');
			// Fill the cleared Datagrid with new XML Reponse
			FillAccoTables(XmlReq.responseXML.documentElement);
			// Hides the Process Image Table after displaying the contents
			imgtbl.style.visibility = 'hidden';
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

function ClosePanel4()
{
    AccommodationDetail.style.visibility = 'hidden';
}
function ShowPanel4()
{
    AccommodationDetail.style.visibility = 'visible';
}

function FillAccoTables(srates)
{
	var weekRates = srates.getElementsByTagName('TABLE'); 
    fillAccoTablesFromXML('tblAccoListWeekly','tblAccoListTerm',weekRates);	

}

function fillAccoTablesFromXML(tblName1,tblName2,content)
{
    var tblWeek = document.getElementById(tblName1).getElementsByTagName("tbody")[0];
	var tblTerm = document.getElementById(tblName2).getElementsByTagName("tbody")[0];
			
	// Iterate through the table and add HTML Rows & contents into it.
	var isHeaderTerm = 0;
	var isHeaderWeek = 0;

    if(content.context.childNodes(0))
    {      	         	         
        for(var i=0;i<content.context.childNodes(0).parentNode.childNodes.length;i++)
	    {     
	        //Header
	        if(isHeaderTerm == 0) 
	        {
	            if(content.context.childNodes(i).nodeName == "TERM")
	            {
	                var row = document.createElement("TR"); 	  

                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Konaklama Dönemi";
                    cell.setAttribute("className","Baslik");
                    row.appendChild(cell); 
                    
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Dönem Süresi (Hafta)";
                    cell.setAttribute("className","Baslik");
                    row.appendChild(cell); 
                    
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Dönemlik Ücret";
                    cell.setAttribute("className","Baslik");
                    row.appendChild(cell); 
                   
                    if(content.context.childNodes(i).childNodes(6).text != "01/01/1900")
                    {
                        var cell = document.createElement("TD"); 
                        cell.innerHTML = "Dönem Tarih Aralığı";
                        cell.setAttribute("className","Baslik");
                        row.appendChild(cell);                    
                    }
                    
                    tblTerm.appendChild(row);

	                isHeaderTerm = 1;
	            }

	        } 
	        if(isHeaderWeek == 0) 
	        {
	            if(content.context.childNodes(i).nodeName == "WEEK")
	            {
	                 var row = document.createElement("TR"); 	  
 
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Konaklama Süresi (Hafta)";
                    cell.setAttribute("className","Baslik");
                    row.appendChild(cell); 
                    
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Haftalık Ücret";
                    cell.setAttribute("className","Baslik");
                    row.appendChild(cell); 
                    
                    tblWeek.appendChild(row);

	                isHeaderWeek = 1;

	            }

	        } 
	        //DATA week
	        var className= "";
            if(i%2 == 0)
            {
                className= "alternate";
            }
            else
            {
                className= "alternate2";
            }
	        if(content.context.childNodes(i).nodeName == "WEEK")
            {
	            // Create an HTML Row
	            var row = document.createElement("TR"); 
	   
	            // Create a HTML DataColumn
	            var cell = document.createElement("TD"); 
	            cell.innerHTML = content.context.childNodes(i).childNodes(3).text + " - " + content.context.childNodes(i).childNodes(4).text + " Hafta";
	            cell.setAttribute("className",className);
	            row.appendChild(cell); 
	            // Create a HTML DataColumn
	            var cell = document.createElement("TD"); 
	            cell.innerHTML = content.context.childNodes(i).childNodes(1).text + " " + content.context.childNodes(i).childNodes(2).text;
	            cell.setAttribute("className",className);
	            row.appendChild(cell); 
	          
	            // Append the current row into the HTML Table(i.e DataGrid)
	            tblWeek.appendChild(row);
	        }
	        //DATA Term
	        if(content.context.childNodes(i).nodeName == "TERM")
            {
	            // Create an HTML Row
	            var row = document.createElement("TR"); 
        		
	            // Create a HTML DataColumn
	            var cell = document.createElement("TD"); 
	            cell.innerHTML = content.context.childNodes(i).childNodes(1).text;
	            cell.setAttribute("className",className);
	            row.appendChild(cell); 
	            // Create a HTML DataColumn
	            var cell = document.createElement("TD"); 
	            cell.innerHTML = content.context.childNodes(i).childNodes(2).text + " Hafta";
	            cell.setAttribute("className",className);
	            row.appendChild(cell); 
	            // Create a HTML DataColumn
	            var cell = document.createElement("TD"); 
	            cell.innerHTML = content.context.childNodes(i).childNodes(3).text + " " + content.context.childNodes(i).childNodes(4).text;
	            cell.setAttribute("className",className);
	            row.appendChild(cell); 
	            // Create a HTML DataColumn
	            if(content.context.childNodes(i).childNodes(6).text != "01/01/1900")
                {
	                var cell = document.createElement("TD"); 
	                cell.innerHTML = content.context.childNodes(i).childNodes(5).text + " - " + content.context.childNodes(i).childNodes(6).text;
	                cell.setAttribute("className",className);
	                row.appendChild(cell);
	            }

	            // Append the current row into the HTML Table(i.e DataGrid)
	            tblTerm.appendChild(row);
	        }
	    }
	}
}
function goToCourseDetail()
{
    var tbl = document.getElementById('tblList').getElementsByTagName("tbody")[0];
    var rowNumber = tbl.rows.length;
    var result = "";
    for (var j=1;j<rowNumber;j++)
	{

	    chk = document.getElementById('tblList').getElementsByTagName("INPUT")[j-1];
	    if(chk.checked == true)
	    {
	        var strId = chk.id;
	        result = strId.substring(3);
	        
	        var txt = dcge('drpDurations');
            var duration = txt.value;
            
	        var div1 = dcge("div1");
	        var div2 = dcge("div2");
	        
	        div1.style.display="none";
	        div2.style.display="";
	        
	        fillSelectedCourseDetails(result, duration);
	        return false;
	    }
	}
	
}
var selectedRows = 0;
function selectRow(courseCode)
{
    chk = document.getElementById('chk'+ courseCode)
    if(chk.checked == true)
    {
        selectedRows ++;
        if(selectedRows == 2)
        {
            var btn = dcge("btnNext");
            
            alert("Sadece tek kurs için konaklama bilgileri sayfasına geçebilirsiniz.");
        }
       
    }
    if(chk.checked == false)
    {
        selectedRows --;
        if(selectedRows < 2)
        {
            var btn = dcge("btnNext");
            
        }
         
    }                 
}

//SECOND PAGE
var CourseCode = 0 ;
function fillSelectedCourseDetails(courseCode, duration)
{
    var tbl = document.getElementById('tblSelectCoursePrice').getElementsByTagName("tbody")[0];
    ClearTables("tblSelectCoursePrice");
    
    var res = callWS("getSelectedCourseDetails","", courseCode, duration);

    if(res.indexOf("HATA:")>-1){		
        WriteError(res,"../");
        return false;
    }
	else
	{
    	 if(res != '')
            {
                var arr = res.split("||");  
                    
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Ülke:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[1];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR");
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Şehir:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[3];
                cell.setAttribute("className","data");
                row.appendChild(cell);                 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Merkez:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[5];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR");
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Şirket:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[7];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Kurs Tipi:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[9];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR");
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Haftalık Ders Saati:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[11];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Fiyatlama Sistemi:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[12];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR");
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Başvuru Ücreti:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[14] + " " + arr[16] ;
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR");
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Kurs Ücreti:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[15] + " " + arr[16] ;
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR");
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Kurs Süresi:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                drpDuration = dcge("drpDurations");
                cell.innerHTML = drpDuration.value + " Hafta"   ;
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                
                CourseCode = arr[0];
                SchoolCode = arr[17];
                fillDurations("drpSelectedAccoDuration");
                fillSelectedAccoLists();

            }
            else
            {
                alert("Seçtiğiniz kursa ait detaylar bulunamamıştır.");
                return false;
            }     
	}

}

function gotoCourseList()
{
    var div1 = dcge("div1");
    var div2 = dcge("div2");
    
    div1.style.display="";
    div2.style.display="none";
}
/*function addAccoPrizestoList()
{
    for (var i=0; i < document.form1.accoRadio.length; i++)
   {
        if (document.form1.accoRadio[i].checked)
        {
            var result = document.form1.radioAcco[i].value;
        }
   }
    alert(rad_val);
}*/

function fillSelectedAccoLists()
{    
    var drp = dcge("drpSelectedAccoDuration");
    var duration = drp.value;

    FetchDGAccoList("getDORAAccomodations",SchoolCode, duration);
}
function FetchDGAccoList(fonksiyon, par1,par2,par3,par4,par5)
{
	//Starts displaying the Process Image table
	imgtbl.style.visibility = 'visible';
	var start = new Date();
	var requestUrl = AjaxServerPageName + "?fnName=" + encodeURIComponent(fonksiyon) + "&par1=" + par1+ "&par2=" + par2+ "&par3=" + par3+ "&par4=" + par4+ "&par5=" + par5 + "&par6=" + start.getTime();
	
	CreateXmlReq();
	
	if(XmlReq)
	{
		XmlReq.onreadystatechange = HandleResponseAccoList;
		XmlReq.open("GET", requestUrl,  true);
		XmlReq.send();		
	}
}

function HandleResponseAccoList()
{
	if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
			// Before filling new contents into the DataGrid, clear the cotents by calling this function
			ClearTables("tblSelectedAccomodationList");
			// Fill the cleared Datagrid with new XML Reponse
			FillAccoList(XmlReq.responseXML.documentElement, "tblSelectedAccomodationList");
			// Hides the Process Image Table after displaying the contents
			imgtbl.style.visibility = 'hidden';
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
function FillAccoList(scity, tblName)
{
	var auth = scity.getElementsByTagName('TABLE'); 
    if(auth.context.childNodes(0))
    {   
        ClearTables('tblSelectedAccomodationList')
    	createAccoHeader('tblSelectedAccomodationList');		
	    createAccoData(auth,'tblSelectedAccomodationList');   	         	                         
	}// Gets the response XML

}
function gotoAirTransfer()
{   
    var result = "";
     var divImg2 = dcge("divImg2");
	 var divImg3 = dcge("divImg3");
	 var divImg4 = dcge("divImg4");
	        
    divImg2.style.display="none";
    divImg3.style.display="";
    divImg4.style.display="none";
    
    for (var j=0;j<=document.form1.accoRadio.length;j++)
	{
	    if(document.form1.accoRadio[j].checked)
	    {
	        result = document.form1.accoRadio[j].value;
	        
	        var txt = dcge('drpSelectedAccoDuration');
            var duration = txt.value;
            
            var div3 = dcge("div3");
            var div4 = dcge("div4");
            var div5 = dcge("div5");

            div5.style.display="";
            div4.style.display="";
            div3.style.display="none";
	        
	        fillSelectedAccoDetails(result, duration);
	        return false;
	    }
	}

}
function gotoAccoList()
{
    var div3 = dcge("div3");
    var div4 = dcge("div4");
    var div5 = dcge("div5");

    div5.style.display="none";
    div4.style.display="none";
    div3.style.display="";
    
    var divImg2 = dcge("divImg2");
	 var divImg3 = dcge("divImg3");
	 var divImg4 = dcge("divImg4");
	        
    divImg2.style.display="";
    divImg3.style.display="none";
    divImg4.style.display="none";

}
function gotoTransList()
{

    var div5 = dcge("div5");
    var div6 = dcge("div6");

    div6.style.display="none";
    div5.style.display="";    
    
    var divImg2 = dcge("divImg2");
	 var divImg3 = dcge("divImg3");
	 var divImg4 = dcge("divImg4");
	        
    divImg2.style.display="none";
    divImg3.style.display="";
    divImg4.style.display="none";
 
}
function gotoConfirmPage()
{
    var result = "";

    for (var j=0;j<=document.form1.transRadio.length;j++)
	{
	    if(document.form1.transRadio[j].checked)
	    {
	        result = document.form1.transRadio[j].value;
            var div5 = dcge("div5");
            var div6 = dcge("div6");

            div5.style.display="none";
            div6.style.display="";
	        
	        fillSelectedTransDetails(result);
	        return false;
	    }
	}
	var div5 = dcge("div5");
    var div6 = dcge("div6");

    div5.style.display="none";
    div6.style.display="";
	fillSelectedTransDetails("-1");
	
	 var divImg2 = dcge("divImg2");
	 var divImg3 = dcge("divImg3");
	 var divImg4 = dcge("divImg4");
	        
    divImg2.style.display="none";
    divImg3.style.display="none";
    divImg4.style.display="";
}
var AccoCode = 0;
function fillSelectedAccoDetails(accoCode, duration)
{
    AccoCode = accoCode;
    var tbl = document.getElementById('tblSelectAccoDetails').getElementsByTagName("tbody")[0];
    ClearTables("tblSelectAccoDetails");
    
    var res = callWS("getSelectedAccoDetails","", accoCode, duration);

    if(res.indexOf("HATA:")>-1){		
        WriteError(res,"../");
        return false;
    }
	else
	{
    	 if(res != '')
            {
                var arr = res.split("||");  
                    
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Konaklama Tipi:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[2];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Kişi Sayısı:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[3];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Fiyatlama Sistemi:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[5];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Konaklama Rezervasyon Ücreti:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[6] + " " + arr[8];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Konaklama Ücreti:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[7] + " " + arr[8];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Konaklama Süresi:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                drpDuration = dcge("drpSelectedAccoDuration");
                cell.innerHTML = drpDuration.value + " Hafta"   ;
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
                fillSelectedTransferList();
                //
            }
    }

}

function fillSelectedTransferList()
{
    FetchDGTransferList("getDORATransfers", SchoolCode );
}
function FetchDGTransferList(fonksiyon, par1,par2,par3,par4,par5)
{
	//Starts displaying the Process Image table
	imgtbl.style.visibility = 'visible';
	var start = new Date();
	var requestUrl = AjaxServerPageName + "?fnName=" + encodeURIComponent(fonksiyon) + "&par1=" + par1+ "&par2=" + par2+ "&par3=" + par3+ "&par4=" + par4+ "&par5=" + par5 + "&par6=" + start.getTime();
	
	CreateXmlReq();
	
	if(XmlReq)
	{
		XmlReq.onreadystatechange = HandleResponseTransList;
		XmlReq.open("GET", requestUrl,  true);
		XmlReq.send();		
	}
}

function HandleResponseTransList()
{
	if(XmlReq.readyState == 4)
	{
		if(XmlReq.status == 200)
		{			
			// Before filling new contents into the DataGrid, clear the cotents by calling this function
			ClearTables("tblSelectedTransList");
			// Fill the cleared Datagrid with new XML Reponse
			FillTransList(XmlReq.responseXML.documentElement, "tblSelectedTransList");
			// Hides the Process Image Table after displaying the contents
			imgtbl.style.visibility = 'hidden';
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}
function FillTransList(scity, tblName)
{
	var auth = scity.getElementsByTagName('TABLE'); 
       
    ClearTables('tblSelectedTransList')
	createTransHeader('tblSelectedTransList');	
       	         	                         
	if(auth.context.childNodes(0))
    {
        createTransData(auth,'tblSelectedTransList');
    }// Gets the response XML

}

function createTransHeader(tableId)
{
     var tbl = document.getElementById(tableId).getElementsByTagName("tbody")[0];
    //
     var row = document.createElement("TR"); 
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "Seçiniz";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell); 
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "Havaalanı";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);            
    // 
    var cell = document.createElement("TD");
    cell.innerHTML = "Transfer Ücreti";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "Para Birimi";
    cell.setAttribute("className","Baslik");
    row.appendChild(cell);    

    tbl.appendChild(row);
    
    //
    var row = document.createElement("TR"); 
    var cell = document.createElement("TD");
    cell.innerHTML = "<input type=radio name=transRadio value=-1></input>";
    row.appendChild(cell); 
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "İstemiyorum";
    row.appendChild(cell);            
    // 
    var cell = document.createElement("TD");
    cell.innerHTML = "-";
    row.appendChild(cell);    
    //
    var cell = document.createElement("TD");
    cell.innerHTML = "-";
    row.appendChild(cell);    
    //
    tbl.appendChild(row);
 
    
}

function createTransData(auth,tableId)
{
     var tbl = document.getElementById(tableId).getElementsByTagName("tbody")[0];
     for(var i=0;i<auth.context.childNodes(0).parentNode.childNodes.length;i++)
	 {
	    var className= "";
        if(i%2 == 0)
        {
            className= "alternate";
        }
        else
        {
            className= "alternate2";
        }
        //
	    var row = document.createElement("TR"); 
        var cell = document.createElement("TD");
        cell.innerHTML = "<input type=radio name=transRadio value=" + auth.context.childNodes(i).childNodes(0).text + "></input>";
        cell.setAttribute("className",className);
        row.appendChild(cell); 
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML =  auth.context.childNodes(i).childNodes(2).text ;	
	    cell.setAttribute("className",className);	  
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = auth.context.childNodes(i).childNodes(3).text ; 
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //
	    var cell = document.createElement("TD"); 
	    cell.innerHTML = auth.context.childNodes(i).childNodes(4).text ; 
	    cell.setAttribute("className",className);
	    row.appendChild(cell);
	    //	
	    tbl.appendChild(row)
	 }
	 
}
var TransCode =-1;
function fillSelectedTransDetails(transCode)
{
   var tbl = document.getElementById('tblSelectedTransDetails').getElementsByTagName("tbody")[0];
   ClearTables("tblSelectedTransDetails");
   TransCode = transCode;
    
   if(transCode != -1)
   {
        var res = callWS("getSelectedTransDetails","", transCode );

        if(res.indexOf("HATA:")>-1){		
            WriteError(res,"../");
            return false;
        }
	    else
	    {
    	    if(res != '')
            {
                var arr = res.split("||");  
                    
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Havaalanı:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[0];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);          
                //
                var row = document.createElement("TR"); 
                var cell = document.createElement("TD"); 
                cell.innerHTML = "Transfer Ücreti:";
                cell.setAttribute("className","label");
                row.appendChild(cell);
                //
                var cell = document.createElement("TD"); 
                cell.innerHTML = arr[1] + " " + arr[2];
                cell.setAttribute("className","data");
                row.appendChild(cell); 
                tbl.appendChild(row);
                //
            }
        }
    }
    else
    {
        var row = document.createElement("TR"); 
        var cell = document.createElement("TD"); 
        cell.innerHTML = "Havaalanı transferi istemediniz";
        cell.setAttribute("className","label");
        row.appendChild(cell);
        tbl.appendChild(row);
        
    }
    ///TOPLAM MALIYET
    var tbl = document.getElementById('tblTotal').getElementsByTagName("tbody")[0];
    ClearTables("tblTotal");
    
    drpAccoDuration = dcge("drpSelectedAccoDuration");
    drpDuration = dcge("drpDurations");
    
    var res = callWS("getDORATotal","", CourseCode, AccoCode, drpAccoDuration.value, drpDuration.value, TransCode );
    
    if(res.indexOf("HATA:")>-1){		
            WriteError(res,"../");
            return false;
        }
	    else
	    {
    	     if(res != '')
                {
                    var arr = res.split("||");  
                        
                    var row = document.createElement("TR"); 
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Kurs Ücreti:";
                    cell.setAttribute("className","label");
                    row.appendChild(cell);
                    //
                    if(arr[0] =="")
                    arr[0] = 0;
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = arr[0] + " "+ arr[3];
                    cell.setAttribute("className","data");
                    row.appendChild(cell); 
                    tbl.appendChild(row);          
                    //
                    var row = document.createElement("TR"); 
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Konaklama Ücreti:";
                    cell.setAttribute("className","label");
                    row.appendChild(cell);
                    //
                    if(arr[1] =="")
                    arr[1] = 0;
                    
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = arr[1] + " "+ arr[3];
                    cell.setAttribute("className","data");
                    row.appendChild(cell); 
                    tbl.appendChild(row);
                                        //
                    var row = document.createElement("TR"); 
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "Havaalanı Transfer Ücreti:";
                    cell.setAttribute("className","label");
                    row.appendChild(cell);
                    //
                    if(arr[2] =="")
                    arr[2] = 0;
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = arr[2] + " "+ arr[3];
                    cell.setAttribute("className","data");
                    row.appendChild(cell); 
                    tbl.appendChild(row);
                    //
                    //
                    var row = document.createElement("TR"); 
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = "TOPLAM:";
                    cell.setAttribute("className","label");
                    row.appendChild(cell);
                    //
                    var cell = document.createElement("TD"); 
                    cell.innerHTML = arr[0]*1 + arr[1]*1 + arr[2]*1 + " " +  arr[3];
                    cell.setAttribute("className","data");
                    row.appendChild(cell); 
                    tbl.appendChild(row);
                }
        }
}
//thırd page
function backtoConfirmPage()
{
    var div2 = dcge("div2");
    var div7 = dcge("div7");

    div2.style.display="";
    div7.style.display="none";
}
var Regid=0;
function gotoContactPage()
{
    drpAccoDuration = dcge("drpSelectedAccoDuration");
    drpDuration = dcge("drpDurations");
    
    var res = callWS("saveDORARegistry","", CourseCode, AccoCode, drpAccoDuration.value, drpDuration.value, TransCode );

     if(res.indexOf("HATA:")>-1){
        var rgid =  dcge("regid");
        rgid.innerText = res;		
    }
    else
    {
        var rgid =  dcge("regid");
        rgid.innerText = res;   
        Regid = res;
    }
    
    var div2 = dcge("div2");
    var div7 = dcge("div7");

    div2.style.display="none";
    div7.style.display="";
    
}
function savePersonalInfo()
{
    var drp = dcge('txtName');
    var name = drp.value;
    if(name =='')
    {
        alert("Lütfen isminizi giriniz");
        return false;
    }
    
    var drp = dcge('txtSurname');
    var surname = drp.value;
    if(surname =='')
    {
        alert("Lütfen soyadınızı giriniz");
        return false;
    }
    
    var drp = dcge('drpGender');
    var gender = drp.value;
    
    var txt = dcge('txtBirthDate');
    var birthdate = txt.value;
    if(birthdate =='')
    {
        alert("Lütfen doğum tarihinizi giriniz");
        return false;
    }
    
    var txt = dcge('txtPassportNo');
    var passportno = txt.value;
    
    var txt = dcge('txtNationality');
    var nation = txt.value;
    
    var txt = dcge('txtNativeLng');
    var nativelng = txt.value;
    
    var txt = dcge('txtOccupation');
    var occupation = txt.value;
    
    var txt = dcge('txtAddress');
    var address = txt.value;
    
    var txt = dcge('txtHomePhone');
    var homephone = txt.value;
    
    var txt = dcge('txtWorkPhone');
    var workphone = txt.value;
    
    var txt = dcge('txtMobilePhone');
    var mobilephone = txt.value;
    if(email =='')
    {
        alert("Lütfen cep telefonunuzu giriniz");
        return false;
    }
    
    var txt = dcge('txtEmail');
    var email = txt.value;
    if(email =='')
    {
        alert("Lütfen email adresinizi giriniz");
        return false;
    }
    
    var txt = dcge('txtMessage');
    var message = txt.value;
    
    var drp = dcge('drpSmoke');
    var smoke = drp.value;
    
    var drp = dcge('drpFood');
    var food = drp.value;
    
    var drp = dcge('drpPet');
    var pet = drp.value;
    
    var drp = dcge('drpHealth');
    var health = drp.value;

    var txt = dcge('txtAccomodation');
    var accomodation = txt.value;
    
    var drp = dcge('drpOffices');
    var office = drp.value;

    var res = callWS("saveDORAContact","", Regid, name, surname, gender, birthdate, passportno, nation, nativelng, occupation, address, homephone, workphone, mobilephone, email, message, smoke, food, pet, health, accomodation, office );
    if(res.indexOf("HATA:")>-1){
		alert(res);
		return false;
    }
    else
    {
        var div8 = dcge("div8");
        var div7 = dcge("div7");

        div8.style.display="";
        div7.style.display="none";
    
        var tdId = dcge("KayitNo");
        tdId.innerText = Regid;
    }
    
    ///karsılaştır
   
 
}
function gotoComparePage()
{
    var tbl = document.getElementById('tblList').getElementsByTagName("tbody")[0];
    var rowNumber = tbl.rows.length;
    var result = "";
    for (var j=1;j<rowNumber;j++)
	{

	    chk = document.getElementById('tblList').getElementsByTagName("INPUT")[j-1];
	    if(chk.checked == true)
	    {
	        var strId = chk.id;
	        result = result + strId.substring(3) + "||";	    	        
	        
	    }
	}
	
	var arr = result.split("||"); 
	Compare.style.visibility = 'visible'; 
	
	
}
function ClosePanel5()
{
    Compare.style.visibility = 'hidden';
    
}
