// JavaScript Document
var xmlHttp;
var xmlHttp2;
var url="services.php";
//??where to put
function changeRowColorOver(num){
	$('rowx'+num+'1').className='listrow textfont';
	$('rowx'+num+'2').className='listrow textfont';
	$('rowx'+num+'3').className='listrow textfont';
	$('rowx'+num+'4').className='listrow textfont';
	$('rowx'+num+'5').className='listrow textfont';
}

function changeRowColorOut(num){
	$('rowx'+num+'1').className='list'+num%2+'row textfont';
	$('rowx'+num+'2').className='list'+num%2+'row textfont';
	$('rowx'+num+'3').className='list'+num%2+'row textfont';
	$('rowx'+num+'4').className='list'+num%2+'row textfont';
	$('rowx'+num+'5').className='list'+num%2+'row textfont';
}

function  followRowLink(num){
	alert('not implemented yet');
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try{
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	}
	catch (e){
	  // Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	 	catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function GetXmlHttpObject2()
{
	var xmlHttp2=null;
	try{
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp2=new XMLHttpRequest();
	}
	catch (e){
	  // Internet Explorer
		try{
			xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
		}
	 	catch (e){
			xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp2;
}

function CheckAjax(){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){ 
		alert ("Your browser does not support AJAX!"); 
		return;
	}	
}

function CheckAjax2(){
	xmlHttp2=GetXmlHttpObject2();
	if (xmlHttp2==null){ 
		alert ("Your browser does not support AJAX!"); 
		return;
	}	
}

// core.php
function $(element){
	return document.getElementById(element);
}

function ShowPicture(containerName, picName, mouseStyle) {
	if (document.images) { 
		document[containerName].src = "images/" + picName;
		$(containerName).style.cursor = mouseStyle;
	}
}

// hesabim.php
function ListMyActions(){
	this.CheckAjax2();
	url2send = url+'?mode=hesabim.aksiyonlar.15';
	xmlHttp2.onreadystatechange=_ListMyActions;
	xmlHttp2.open("GET",url2send,true);
	xmlHttp2.send(null);
}

function _ListMyActions(){
	if (xmlHttp2.readyState==4){ 
		$('ActionList').innerHTML=xmlHttp2.responseText;
	}
	else{
		$('ActionList').innerHTML = "Yükleniyor";
	}
}


function ListMyJobs(){
	this.CheckAjax();
	url2send = url+'?mode=hesabim.isler.1';
	xmlHttp.onreadystatechange=_ListMyJobs;
	xmlHttp.open("GET",url2send,true);
	xmlHttp.send(null);
}

function _ListMyJobs(){
	if (xmlHttp.readyState==4){ 
		$('AccountQuickList').innerHTML=xmlHttp.responseText;;
		$('Account_Candidates').innerHTML = '<img name="buton_adaylar" src="images/hesapbireysel_left_level22click.gif" width="65" height="28" alt="" onmouseover="ShowPicture(\'buton_adaylar\',\'hesapbireysel_left_level22over.gif\', \'pointer\')" onmouseout="ShowPicture(\'buton_adaylar\',\'hesapbireysel_left_level22click.gif\', \'\')" onclick="ListCandidates()" />';	
		$('Account_Jobs').innerHTML = '<img name="buton_isler" src="images/hesapbireysel_left_level24.gif" width="58" height="28" alt="">';
		$('Account_Add').onclick = function (event) { AddJob(); };
		$('Account_Delete').onclick = function (event) { DeleteJobList(); };
		
	}
	else{
		$('AccountQuickList').innerHTML = "Yükleniyor";
	}
}

function ListCandidates(){
	this.CheckAjax();
	url2send = url+'?mode=hesabim.adaylar.1';
	xmlHttp.onreadystatechange=_ListCandidates;
	xmlHttp.open("GET",url2send,true);
	xmlHttp.send(null);
}

function _ListCandidates(){
	if (xmlHttp.readyState==4){ 
		$('AccountQuickList').innerHTML=xmlHttp.responseText;
		$('Account_Candidates').innerHTML = '<img name="buton_adaylar" src="images/hesapbireysel_left_level22.gif" width="65" height="28" alt="" />';
		$('Account_Jobs').innerHTML = '<img name="buton_isler" src="images/hesapbireysel_left_level24click.gif" width="58" height="28" alt="" onmouseover="ShowPicture(\'buton_isler\',\'hesapbireysel_left_level24over.gif\', \'pointer\')" onmouseout="ShowPicture(\'buton_isler\',\'hesapbireysel_left_level24click.gif\', \'\')" onclick="ListMyJobs()" />';
		$('Account_Add').onclick = function (event) { AddCandidate(); };
		$('Account_Delete').onclick = function (event) { DeleteCandidate(); };
	}
	else{
		$('AccountQuickList').innerHTML = "Yükleniyor";
	}
}

function AddJob(){
	location.replace('pozisyonekle.php');
}

function AddCandidate(){
	location.replace('adayekle.php');
}

//mesajlarim.php
function ListMessagesSent(){
	this.CheckAjax();
	url2send = url+'?mode=mesajlarim.giden.5';
	xmlHttp.onreadystatechange=_ListMessagesSent;
	xmlHttp.open("GET",url2send,true);
	xmlHttp.send(null);
}
function _ListMessagesSent() { 
	if (xmlHttp.readyState==4){ 
		$('MailContainer').innerHTML=xmlHttp.responseText;
		$('Messages_Inbox').innerHTML = '<img name="buton_gelen" src="images/mesajlar_level22click.gif" width="66" height="27" alt="" onmouseover="ShowPicture(\'buton_gelen\',\'mesajlar_level22over.gif\', \'pointer\')" onmouseout="ShowPicture(\'buton_gelen\',\'mesajlar_level22click.gif\', \'\')" onclick="ListInbox()" />';
		$('Messages_Sent').innerHTML = '<img name="buton_gonderilmis" src="images/mesajlar_level23.gif" width="105" height="27" alt="">';
		$('fromtoImg').innerHTML = '<img src="images/mesajlar_level37.jpg" width="170" height="25" alt="" />';
		$('Message_Delete').onclick = function (event) { DeleteOutboxMessage(); };
	}
	else{
		$('agentsList').innerHTML = "Yükleniyor";
	}
}
	
function ListInbox(){
	this.CheckAjax();
	url2send = url+'?mode=mesajlarim.gelen.12';
	xmlHttp.onreadystatechange=_ListInbox;
	xmlHttp.open("GET",url2send,true);
	xmlHttp.send(null);
}
	
function _ListInbox() { 
	if (xmlHttp.readyState==4){ 
		$('MailContainer').innerHTML=xmlHttp.responseText;
		$('Messages_Inbox').innerHTML = '<img name="buton_gelen" src="images/mesajlar_level22.gif" width="66" height="27" alt="" />';
		$('Messages_Sent').innerHTML = '<img name="buton_gonderilmis" src="images/mesajlar_level23click.gif" width="105" height="27" alt="" onmouseover="ShowPicture(\'buton_gonderilmis\',\'mesajlar_level23over.gif\', \'pointer\')" onmouseout="ShowPicture(\'buton_gonderilmis\',\'mesajlar_level23click.gif\', \'\')" onclick="ListMessagesSent()" />';
		$('fromtoImg').innerHTML = '<img src="images/mesajlar_level33.jpg" width="170" height="25" alt="" />';
		$('Message_Delete').onclick = function (event) { DeleteInboxMessage(); };
	}
	else{
		$('agentsList').innerHTML = "Yükleniyor";
	}
}
	
function GetCandidates(){}
function _GetCandidates(){}

//profilim.php
function ListInvited(sortAccepted, sortWaiting){
	this.CheckAjax();
	url2send = url+'?mode=profilim.davetettiklerim.' + sortAccepted + '.' + sortWaiting;
	xmlHttp.onreadystatechange=_ListInvited;
	xmlHttp.open("GET",url2send,true);
	xmlHttp.send(null);
}

function _ListInvited(){
	
	if (xmlHttp.readyState==4){ 
		$('ProfileContent').innerHTML = xmlHttp.responseText;
		$('Details').innerHTML = '<img name="buton_detaylar" src="images/profilim_level22click.jpg" width="85" height="28" alt=""  onmouseover="ShowPicture(\'buton_detaylar\',\'profilim_level22over.gif\', \'pointer\')" onmouseout="ShowPicture(\'buton_detaylar\',\'profilim_level22click.gif\', \'\')" onclick="MyDetails()" />';
		$('InvitedPersons').innerHTML = '<img name="buton_davetedilenler" src="images/profilim_level23.gif" width="125" height="28" alt="">';
	}
	else{
		$('ProfileContent').innerHTML = "Yükleniyor";
	}

}

function MyDetails(){
	this.CheckAjax();
	url2send = url+'?mode=profilim.detaylarim';
	xmlHttp.onreadystatechange=_MyDetails;
	xmlHttp.open("GET",url2send,true);
	xmlHttp.send(null);
}

function _MyDetails(){
	if (xmlHttp.readyState==4){ 
		$('ProfileContent').innerHTML = xmlHttp.responseText;
		$('Details').innerHTML = '<img name="buton_detaylar" src="images/profilim_level22.jpg" width="85" height="28" alt="" />';
		$('InvitedPersons').innerHTML = '<img name="buton_davetedilenler" src="images/profilim_level23click.gif" width="125" height="28" alt=""  onmouseover="ShowPicture(\'buton_davetedilenler\',\'profilim_level23over.gif\', \'pointer\')" onmouseout="ShowPicture(\'buton_davetedilenler\',\'profilim_level23click.gif\', \'\')" onclick="ListInvited(\'date\',\'date\')" />';
	}
	else{
		$('ProfileContent').innerHTML = "Yükleniyor";
	}
}

//habercim.php
function GetMyAgents(){
	this.CheckAjax();
	url2send = url+'?mode=habercim';
	xmlHttp.onreadystatechange=_GetMyAgents;
	xmlHttp.open("GET",url2send,true);
	xmlHttp.send(null);
}

function _GetMyAgents(){
	if (xmlHttp.readyState==4){ 
		$('agentsList').innerHTML=xmlHttp.responseText;
	}
	else{
		$('agentsList').innerHTML = "Yükleniyor";
	}
}


function CompanyDetails(){
	this.CheckAjax();
	url2send = url+'?mode=profilim.firmaDetay';
	xmlHttp.onreadystatechange=_CompanyDetails;
	xmlHttp.open("GET",url2send,true);
	xmlHttp.send(null);
}

function _CompanyDetails(){
	if (xmlHttp.readyState==4){ 
		$('HirerProfileContent').innerHTML = xmlHttp.responseText;
		$('CompanyDetails').innerHTML = '<img name="buton_detaylar" src="images/hsirket_level22.jpg" width="90" height="28" alt="" />';
		$('OptionalDetails').innerHTML = '<img name="buton_davetedilenler" src="images/hopsiyonel_level23click.jpg" width="120" height="28" alt="" onmouseover="ShowPicture(\'buton_davetedilenler\',\'hopsiyonel_level23over.jpg\', \'pointer\')" onmouseout="ShowPicture(\'buton_davetedilenler\',\'hopsiyonel_level23click.jpg\', \'\')" onclick="OptionalDetails()" />';
	}
	else{
		$('HirerProfileContent').innerHTML = "Yükleniyor";
	}
}

function OptionalDetails(){
	this.CheckAjax();
	url2send = url+'?mode=profilim.firmaOpDetay';
	xmlHttp.onreadystatechange=_OptionalDetails;
	xmlHttp.open("GET",url2send,true);
	xmlHttp.send(null);
}

function _OptionalDetails(){
	
	if (xmlHttp.readyState==4){ 
		$('HirerProfileContent').innerHTML = xmlHttp.responseText;
		$('CompanyDetails').innerHTML = '<img name="buton_detaylar" src="images/hsirket_level22click.jpg" width="90" height="28" alt=""  onmouseover="ShowPicture(\'buton_detaylar\',\'hsirket_level22over.jpg\', \'pointer\')" onmouseout="ShowPicture(\'buton_detaylar\',\'hsirket_level22click.jpg\', \'\')" onclick="CompanyDetails()" />';
		$('OptionalDetails').innerHTML = '<img name="buton_davetedilenler" src="images/hopsiyonel_level23.jpg" width="120" height="28" alt="">';
	}
	else{
		$('HirerProfileContent').innerHTML = "Yükleniyor";
	}

}


function GetHirerJobs()
{
this.CheckAjax();
	url2send = url+'?mode=hesabim.ikPozisyonlar';
	xmlHttp.onreadystatechange=_GetHirerJobs;
	xmlHttp.open("GET",url2send,true);
	xmlHttp.send(null);
}

function _GetHirerJobs(){
	
	if (xmlHttp.readyState==4){ 
		$('HirerJobsList').innerHTML = xmlHttp.responseText;
	}
	else{
		$('HirerJobsList').innerHTML = "Yükleniyor";
	}

}



function ShowInboxMessage(messageId)
{
	location = 'mesajdetay.php?box=0&message_id=' + messageId;
}

function ShowOutboxMessage(messageId)
{
	location = 'mesajdetay.php?box=1&message_id=' + messageId;
}

function DeleteMessage(boxType, messageId)
{
	if (confirm('Bu mesajı silmek istediğinizden emin misiniz?'))
	{
		location = 'mesajsil.php?box=' + boxType + '&message_id=' + messageId;
	}
}

function SaveCandidate(next)
{
	$('nextAction').value = next;
	$('adayEkleForm').submit();
}

function EditCandidate(cand_email)
{
	location = 'adaydetay.php?email=' + cand_email;
}

function ShowPosition(position_id)
{
	location = 'isdetay.php?position_id=' + position_id;
}

function EditAlert(alert_id)
{
	location = 'haberciekle.php?alert_id=' + alert_id;
}

function DeleteCandidate()
{
	if (confirm('Seçili adayları silmek istediğinizden emin misiniz?'))
	{
		$('hesabimForm').action = "aday_sil.php";
		$('hesabimForm').submit();
	}
}

function DeleteJobList()
{
	if (confirm('Seçili işleri silmek istediğinizden emin misiniz?'))
	{
		$('hesabimForm').action = "is_listesi_sil.php";
		$('hesabimForm').submit();
	}
}

function DeleteJob(id)
{
	if (confirm('Bu pozisyonu silmek istediğinizden emin misiniz?'))
	{
		location = 'pozisyondetay.php?type=delete_position&id=' + id;
	}
}

function SavePosition(next)
{
	$('nextAction').value = next;
	$('pozisyonEkleForm').submit();
}

function EditPosition(id)
{
	location = 'pozisyondetay.php?type=edit_position&id=' + id;
}

function DeleteAction()
{
	if (confirm('Seçili işleri silmek istediğinizden emin misiniz?'))
	{
		$('hesabimForm').action = "action_sil.php";
		$('hesabimForm').submit();
	}
}


function DeleteInboxMessage()
{
	if (confirm('Seçili mesajları silmek istediğinizden emin misiniz?'))
	{
		$('action').value = 'delete';
		$('box').value = '0';
		$('messageForm').submit();
	}
}

function DeleteOutboxMessage()
{
	if (confirm('Seçili mesajları silmek istediğinizden emin misiniz?'))
	{
		$('action').value = 'delete';
		$('box').value = '1';
		$('messageForm').submit();
	}
}

function DeleteAlert()
{
	if (confirm('Seçili habercileri silmek istediğinizden emin misiniz?'))
	{
		$('action').value = 'delete';
		$('alertForm').submit();
	}
}
