function initialize() {
  initLightbox();
}

// pariteler.aspx
function getPariteler(lan) { new Ajax.Request( "../includes/pariteler.aspx?dil="+lan, { method: "get", evalScripts: true, onSuccess: pariteler } ); }
function pariteler(transport) { $('dCurrency').innerHTML=transport.responseText; }
// end-pariteler.aspx

// survey.asp
function getSurvey() {
  $('d_survey').innerHTML = "";
  new Ajax.Request( "survey.asp", { method: "get", onSuccess: renderSurvey, onFailure: renderSurvey } );
}
function voteSurvey() {
  var option = "optionID=" + encodeURI( Form.getInputs('frm_vote','radio','optionID').find(function(radio) { return radio.checked; }).value );
  
  var surveyID = $F('surveyID');
  $('d_survey').innerHTML = "";
  new Ajax.Request( "survey.asp?surveyID="+surveyID, { method: "post", postBody: option, onSuccess: renderSurvey, onFailure: renderSurvey } );
}
function renderSurvey(transport) {
  $('d_survey').innerHTML = transport.responseText;
}
function getSurvey2() {
  $('dSurveyLeft').innerHTML = "";
  new Ajax.Request( "survey2.asp", { method: "get", onSuccess: renderSurvey2 } );
}
function voteSurvey2() {
  var option = "optionID=" + encodeURI( Form.getInputs('frm_vote2','radio','optionID2').find(function(radio) { return radio.checked; }).value );
  
  var surveyID = $F('surveyID2');
  $('dSurveyLeft').innerHTML = "";
  new Ajax.Request( "survey2.asp?surveyID="+surveyID, { method: "post", postBody: option, onSuccess: renderSurvey2 } );
}
function renderSurvey2(transport) {
  $('dSurveyLeft').innerHTML = transport.responseText;
}
// end-survey.asp

// search.asp
function searchDate() { window.location.href='search.asp?d='+$F('d1')+'.'+$F('d2')+'.'+$F('d3'); }
// end-search.asp

// comments.asp
function showNewComment() { $('d_newcommentcontainer').show(); $('d_newcommentnotifier').hide(); }

function hideNewComment() { $('d_newcommentcontainer').hide(); }

function sendNewComment() {
  var option
  = "newsID=" + encodeURI($F('newsID'))
  + "&fld_type=" + encodeURI($F('fld_type'))
  + "&fld_name=" + encodeURI($F('txtNewcommentName'))
  + "&fld_mail=" + encodeURI($F('txtNewcommentMail'))
  + "&fld_caption=" + encodeURI($F('txtNewcommentCaption'))
  + "&fld_message=" + encodeURI($F('txtNewcommentMessage')) ;
  
  $('d_newcommentnotifier').show();
  $('d_newcommentnotifier').innerHTML = "<p>Yorumunuz yollaniyor, lutfen bekleyiniz...</p>";
  new Ajax.Request( "comments.asp", { method: "post", postBody: option, onSuccess: renderNewcomment, onFailure: renderNewcomment } );
}
function renderNewcomment(transport) {
  $('d_newcomment').innerHTML = transport.responseText;
}
// end-comments.asp

// counter.aspx
function get_counter() {
  $('d_counter').innerHTML = "";
  new Ajax.Request( "counter.aspx", { method: "get", onSuccess: renderCounter } );
}
function renderCounter(transport) {
  $('d_counter').innerHTML = transport.responseText;
}
// end-counter.aspx

// son dakika
var currentFlashNews=0;
var peFlashNews=null;
var peFlashNewsRefresher=null;

function getFlashNews() {
  $('d_sondakikacontainer').innerHTML = "";
  new Ajax.Request( "sondakika.asp", { method: "get", onSuccess: loadFlashNews } );
  peFlashNewsRefresher=new PeriodicalExecuter(refreshFlashNews, 300);
}

function refreshFlashNews() {
  peFlashNews.stop();
  $('d_sondakikacontainer').setStyle({ 'top': "0 px" });
  currentFlashNews=0;
  new Ajax.Request( "sondakika.asp", { method: "get", onSuccess: loadFlashNews } );
}

function loadFlashNews(transport) {
  $('d_sondakikacontainer').innerHTML=transport.responseText;
  peFlashNews=new PeriodicalExecuter(changeFlashNews, 5);
}

function changeFlashNews() {
  $('d_sondakikacontainer').setStyle({ 'top': (- (currentFlashNews * 28)) + " px" });
  if (++currentFlashNews==5) currentFlashNews=0;
}
// end-sondakika

// mainpage
var imgMainOld = 0;
var peMainPicture=null;

function imgMainShow(p) {
  $('imgMain'+imgMainOld).hide();
  $('imgMain'+p).show();
  imgMainOld=p;
  if (peMainPicture!=null) peMainPicture.stop();
}

function changePicture() {
  $('imgMain'+imgMainOld).hide();
  if ($('imgBtn'+imgMainOld).hasClassName('imgBtnSelected')) $('imgBtn'+imgMainOld).removeClassName('imgBtnSelected');
  imgMainOld++;
  if ($('imgMain'+imgMainOld)==null) imgMainOld=0;
  $('imgMain'+imgMainOld).show();
  if (!$('imgBtn'+imgMainOld).hasClassName('imgBtnSelected')) $('imgBtn'+imgMainOld).addClassName('imgBtnSelected');
}

function startMainPictureChange() { peMainPicture=new PeriodicalExecuter(changePicture, 3); }

function refreshPagePeriodically() { new PeriodicalExecuter(refreshPage, 180); }

function refreshPage() { window.location.reload(); }
//end-mainpage

// photogaleries.asp
function tofriend_show() { $('tofriend_link').hide(); $('tofriend_success').hide(); $('tofriend_frmcontainer').show(); }

function tofriend_send() {
  new Ajax.Request( "sendtofriend.asp?ID="+$F('tofriendID'), { method: "post", postBody: "fld_mail="+encodeURI($F('tofriend_txt')), onSuccess: tofriend_success, onFailure: tofriend_failure } );
  $('tofriend_frmcontainer').hide();
  $('tofriend_wait').show();
}

function tofriend_success(transport) { $('tofriend_wait').hide(); $('tofriend_success').show(); }

function tofriend_failure(transport) { $('tofriend_wait').hide(); $('tofriend_failure').show(); }
// end-photogaleries.asp

// sliding adv
function JSFX_FloatTopRight() {
  var startX = 890, startY = 10;
  var ns = (navigator.appName.indexOf("Netscape") != -1);
  var d = document;
  var px = document.layers ? "" : "px";
  function ml(id) {
    var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
    if(d.layers)el.style=el;
    el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};
    el.x = startX; el.y = startY;
    return el;
  } 

  window.stayTopRight=function() {
    var pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
    var dY = (pY > startY) ? pY + 10 : startY;
    ftlObj.y += (dY - ftlObj.y)/8;
    ftlObj.sP(ftlObj.x, ftlObj.y);

    setTimeout("stayTopRight()", 20);
  }
  ftlObj = ml("adv_right");
  stayTopRight();
}
// end-sliding adv

function limitText(obj, maxLength) {
  if (obj.value.length >= maxLength) obj.value = obj.value.substring(0, maxLength);
  temp = $('charCount').innerHTML.split(':');
  $('charCount').innerHTML = temp[0] + ': ' + (maxLength - obj.value.length).toString();
}

function addToFavorites() {
	var urlAddress = "http://www.haberalanya.com";
	var pageName = ".:: Haber Alanya ::. [ Haberin dogru adresi ]";
	if (window.external) {
		window.external.AddFavorite(urlAddress, pageName) 
	} else {
		alert("Sorry! Your browser doesn't support this function."); 
	}
}
