// dropdown select location change

function selsub(Url) {
  Url=document.subsites.sites[document.subsites.sites.selectedIndex].value;
  document.location = Url;
}

function updateParent(links) {
    opener.location = links;
    self.close();
    return false;
}

function openChild(file, window) {
    childWindow=open(file, window, 'resizable=no,width=400,height=400');
    if (childWindow.opener == null) childWindow.opener = self;
}
	
function openExternalLink(href, target) {
  var newwin;
  var file = 'cikis_uyarisi.php?url=' + encodeURIComponent(href) + '&target=' + encodeURIComponent(target);
  //var checkme;
  if(href != "http://akademika.org/")
  {
    //alert("uyarılı");
    //newwin = window.open('cikis_uyarisi.php?url=' + encodeURIComponent(href) + '&target=' + encodeURIComponent(target),'openlink');
	//openwin('cikis_uyarisi.php?url=' + encodeURIComponent(href) + '&target=' + encodeURIComponent(target), 300, 400);
	
	openChild(file, 'win2');
  }
  else
  {
    //alert("uyarısız");
    //newwin = window.open(href,'openlink');
	//openwin('cikis_uyarisi.php?url=' + encodeURIComponent(href) + '&target=' + encodeURIComponent(target), 300, 400);
	
	openChild(file, 'win2');
  }
  //newwin.focus();
}

function setupExternalLinks() {
  var links = document.getElementsByTagName('a');
  for (var i = links.length; i != 0; i--) {
    var a = links[i-1];
    if (!a.href) continue;

    if (a.href.indexOf('http') != -1 && a.href.indexOf(window.location.hostname) == -1 && !excludeUrl(a.href))
	{
      a.onclick = function() {
                openExternalLink(this.hreflang, this.target);
                return false;
            }
	  a.hreflang = a.href;
	  a.href = "#";
    }
  }
}

function excludeUrl(url){
  var excludeUrls = Array(
              'http://www.akademika.org',
			  'http://akademika.org',
			  'http://www.sanofi-aventis.com.tr'
              );

  for(var l = 0; l < excludeUrls.length; l++){
    if(url.indexOf(excludeUrls[l]) == 0){
      return true;
    }
  }

  return false;
}
