function Browser(){
  var ua = navigator.userAgent.toLowerCase(); 
  this.Gecko = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
  this.Safari = (ua.indexOf('safari') != - 1);
  this.IE = (ua.indexOf('msie') != -1 && !this.Opera && (ua.indexOf('webtv') == -1) ); 
  this.Firefox = ( (ua.indexOf('firebird/') != -1) || (ua.indexOf('firefox/') != -1) );
  this.IECompatible = ( (ua.indexOf('msie') != -1) && !this.IE);
  this.NSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.NS && !this.Mozilla);
  this.geckoVersion = ( (this.Gecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
  this.equivalentMozilla = ( (this.Gecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
  this.versionMinor = parseFloat(navigator.appVersion); 
  if (this.Gecko && !this.Mozilla) this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
  else if (this.Mozilla) this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
  else if (this.IE && this.versionMinor >= 4) this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
  else if (this.Safari) this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
  this.versionMajor = parseInt(this.versionMinor); 
  this.DOM1 = (document.getElementById);
  this.DOM2Event = (document.addEventListener && document.removeEventListener);
  this.mode = document.compatMode ? document.compatMode : 'BackCompat';
  this.Win = (ua.indexOf('win') != -1);
  this.Mac = (ua.indexOf('mac') != -1);
  this.NS6up = (this.NS && this.versionMajor >= 6);
  this.NS7up = (this.NS && this.versionMajor >= 7);
  this.IE4 = (this.IE && this.versionMajor == 4);
  this.IE5 = (this.IE && this.versionMajor == 5);
  this.IE55 = (this.IE && this.versionMinor == 5.5);
  this.IE5up = (this.IE && this.versionMajor >= 5);
  this.IE6x = (this.IE && this.versionMajor == 6);
  this.IE6up = (this.IE && this.versionMajor >= 6);
}
var is = new Browser();
var browser = is;

var flashVersion = 0;
function getFlashVersion() {
  var latestFlashVersion = 8;
  var agent = navigator.userAgent.toLowerCase(); 
  if (navigator.plugins != null && navigator.plugins.length > 0) {
    var flashPlugin = navigator.plugins['Shockwave Flash'];
    if (typeof flashPlugin == 'object'){ 
      for (var i = latestFlashVersion; i >= 3; i--){
              if (flashPlugin.description.indexOf(i + '.') != -1){
                 flashVersion = i;
                 break;
              }
      }
    }
  }
  else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
    var doc = ''+
      '<scr' + 'ipt language="VBScript"\> \n'+
      'On Error Resume Next \n'+
      'Dim obFlash \n'+
      'For i = ' + latestFlashVersion + ' To 3 Step -1 \n'+
      '  Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n'+
      '  If IsObject(obFlash) Then \n'+
      '    flashVersion = i \n'+
      '    Exit For \n'+
      '  End If \n'+
      'Next \n'+
      '</scr' + 'ipt\> \n';
    document.write(doc);
  } else {flashVersion = flashVersion_DONTKNOW; }
return flashVersion;
}
var flashVersion_DONTKNOW = -1;
function FlashObject(){
  this.ID=this.ID;
  this.maxVersion=this.maxVersion;
  this.SwfFile;
  this.minVersion;
  this.altSwfFile;
  this.altImage;
  this.altImageAddAtribute;
  this.altImageHTML;
  this.width;
  this.height;
  this.menu;
  this.background;
  this.wmode;
  this.flashvars;
  this.scale;
  this.salign;
}
FlashObject.prototype.rnd=function(){
  this.ranNum= Math.random()*255;
    return this.ranNum;
}
FlashObject.prototype.embed=function(){
  var buff;
  if(getFlashVersion()>=this.maxVersion){
    buff=''+
      '<OBJECT ID="'+this.ID+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH='+this.width+' HEIGHT='+this.height+'><PARAM NAME=movie VALUE="'+this.SwfFile+'"><PARAM NAME=menu VALUE='+this.menu+'><param name="wmode" value="'+this.wmode+'"><PARAM NAME="quality" VALUE="high"><PARAM NAME="flashvars" VALUE="'+ this.flashvars +'"><PARAM NAME="bgcolor" VALUE="'+this.background+'"><PARAM NAME="scale" VALUE="'+this.scale+'"><PARAM NAME="salign" VALUE="'+this.salign+'">'+
        '<EMBED name="'+this.ID+'" src="'+this.SwfFile+'" menu="'+this.menu+'" wmode="'+this.wmode+'" quality="high" bgcolor="'+this.background+'"  WIDTH="'+this.width+'" HEIGHT="'+this.height+'" scale="'+this.scale+'" salign="'+this.salign+'" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" swLiveConnect="true"></EMBED>'+
      '</OBJECT>';
  }else if((getFlashVersion()> this.minVersion) && (getFlashVersion()< this.maxVersion) && this.altSwfFile){
    buff=''+
      '<OBJECT ID="'+this.ID+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH='+this.width+' HEIGHT='+this.height+'><PARAM NAME=movie VALUE="'+this.altSwfFile+'"><PARAM NAME=menu VALUE='+this.menu+'<param name="wmode" value="'+this.wmode+'">><PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor" VALUE='+this.background+'>'+
        '<EMBED flashvars="'+ this.flashvars +'" name="'+this.ID+'" src="'+this.altSwfFile+'" menu="'+this.menu+'" wmode="'+this.wmode+'" quality=high bgcolor='+this.background+'  WIDTH='+this.width+' HEIGHT='+this.height+' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" swLiveConnect="true"></EMBED>'+
      '</OBJECT>';
  }else{
    this.altImageAddAtribute ? (buff='<img src="'+this.altImage+'" width="'+this.width+'" height="'+this.height+'" border="0" '+this.altImageAddAtribute+' />'+this.altImageHTML) : (buff='<img src="'+this.altImage+'" width="'+this.width+'" height="'+this.height+'" border="0" />');
  }
  document.write(buff);
}

function getCenter(pw,ph){
  ww=screen.width;
  wh=screen.height;
  lp= (ww-pw)/2;
  tp= (wh-ph)/2;
  return lp, tp;
}

function PopItUp(src,w,h,s,r){
  s ? w=w+17 : -1;
  getCenter(w,h);
  Popwin = window.open(src,"popwin","toolbar=0,width=" + w + ", height=" + h + "; location=0, directories=0, status=1, scrollbars="+s+", menubar=0, resizable="+r+", copyhistory=0");
  Popwin.focus();
}
var newWindow = null;
function PopFull(url, type, strWidth, strHeight){
  
  if (type == "fullScreen"){
    strWidth = screen.availWidth - 10;
    strHeight = screen.availHeight - 40;
  }
  
  Popwin = window.open(url,"popwin","toolbar=0,width=" + strWidth + ", height=" + strHeight + ",top=0,left=0; location=0, directories=0, status=1, scrollbars=0, menubar=0, resizable=1, copyhistory=0");
  Popwin.focus();
}

function simpleWin(myUrl,p_width,p_height,scr){
  if(!p_width) {
    p_width=500;
    p_height=400;  
  }
  
  if (!scr) {
    scr=0;
  }
  myWin = window.open("","","toolbar=0,width=" + p_width + ",height=" + p_height + ",location=0,directories=0, status=0,scrollbars="+scr+",menubar=0,resizable=0,copyhistory=0");
  myWin.location.href = myUrl;
  myWin.focus();
}

function init(){
  if (!document.getElementsByTagName) return;
  imgArray = document.getElementsByTagName("img");
    for (i=0;i<imgArray.length;i++){
      (imgArray[i].alt!=-1)?(imgArray[i].title=imgArray[i].alt): null;
    }
  aArray = document.getElementsByTagName("a");
    for (i=0;i<aArray.length;i++){
      if(aArray[i] && aArray[i].href && !aArray[i].title && aArray[i].childNodes[0]) aArray[i].title=aArray[i].childNodes[0].nodeValue;
    }
}
function externalLinks(){
  if(!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for(var i=0; i<anchors.length; i++){
    var anchor = anchors[i];
    if(anchor.getAttribute("href") && anchor.getAttribute("rel")=="external"){
      anchor.target = "_blank";
    }
  }
}

function ControlSelect(formname,elname){
  if (elname=="ddlKategori"){
    document.getElementById("ddlIngredient").selectedIndex=0;
    document.getElementById("ddlProduct").selectedIndex=0;
  }else if(elname=="ddlIngredient"){
    document.getElementById("ddlKategori").selectedIndex=0;
    document.getElementById("ddlProduct").selectedIndex=0;
  }else if(elname=="ddlProduct"){
    document.getElementById("ddlIngredient").selectedIndex=0;
    document.getElementById("ddlKategori").selectedIndex=0;
  }else{
    document.getElementById("ddlIngredient").selectedIndex=0;
    document.getElementById("ddlProduct").selectedIndex=0;
    document.getElementById("ddlKategori").selectedIndex=0;
  }
}


function getUrl(obj){
  selectedObj=obj.options[obj.selectedIndex];
  selectedObj.value!="blank"? document.location.href=selectedObj.value:null;
  return true;
}

function getWindowHeight(){
  var windowHeight=0;
  if(typeof(window.innerHeight)=='number'){
    windowHeight=window.innerHeight;
  }else{
    if(document.documentElement && document.documentElement.clientHeight) windowHeight=document.documentElement.clientHeight;
    else if(document.body && document.body.clientHeight) windowHeight=document.body.clientHeight;
  }
  return windowHeight;
}

function setFooter(){
  if (document.getElementById){
    var windowHeight=getWindowHeight();
    if (windowHeight>0){
      var contentHeight=document.getElementById('wrapper').offsetHeight;
      var footerElement=document.getElementById('footer');
      var footerHeight =footerElement.offsetHeight;
      if (windowHeight - (contentHeight + footerHeight)>=0) footerElement.style.marginTop=(windowHeight-(contentHeight+footerHeight))+'px';
      else footerElement.style.marginTop='36px';
    }
  }
}





function RandomNews(NewsARR, htmlField){
  var randomArr =  new Array();

  for (i=0;i<NewsARR.length;i++){
    for (j=0;j<NewsARR[i][0];j++){
      randomArr.push(i);
    }
  }
  
  randomNews = Math.floor(Math.random() * (randomArr.length))
  
  document.getElementById(htmlField).innerHTML = NewsARR[randomArr[randomNews]][1];
}


// Haber Metinleri
    var quotes = new Array();
    
      quotes[1] = "<h3>MagiClick's Works Continue to Receive International Acclaim</h3><p><img src=\"_i/news/oneclub.gif\" alt=\" \" width=\"110\" height=\"84\" border=\"0\" vspace=\"5\" align=\"right\">The AI Pharma Web Site has been selected to appear in the <strong>One Show Rx Exhibition</strong> hosted by The One Club New York.<br><br>A total of 425 entries from 12 countries took part in the judged exhibition displaying the <strong>best pharmaceutical advertising of the year</strong>. </p><p>From 65 entries in the interactive category only 12 were selected for the exhibition and the AI Pharma Web Site were the only entry selected in the \"<strong>Direct to Consumer Interactive- Corporate Web Site</strong>\" category.</p>";

      quotes[2] = "<h3>MagiClick recieves 2 awards at the 2006 IMA</h3><p>MagiClick Digital Solutions won 2 awards at the 2006 Interactive Marketing Awards organized by the Istanbul-based Marketing Management Institute.</p><p>MagiClick received the grand prize in the \"Advergaming\" category with the \"Escape from Artemis\" online adventure game created for Efes Pilsen, and the Jury Special Prize with the game-banner set created for Fortis Bank. The e-bulletin campaigns created by MagiClick for HSBC Bank and Siemens Medical Solutions have also been recognized as finalists in the e-mail marketing category..</p>";
      
      quotes[3] = "<h3>Escape from Artemis!</h3><p><br><a href=\"http://www.dreaminefes.com\"  target=\"_blank\"><img src=\"_i/news/artemis.jpg\" alt=\"\" width=\"127\" height=\"117\" border=\"0\" vspace=\"5\" align=\"right\"></a>Evil bandits kidnap the famous beer maker Anatolius' daughter Efelia and hide her in a hidden room under the Artemis Temple. In exchange for her freedom they demand the secret recipe of <b>Efes</b>. Your mission is to penetrate the temple and rescue Efelia...</p><p>Visit the newly launched international web site of the <a href=\"http://www.dreaminefes.com\"  target=\"_blank\">Efes Pilsener</a> brand created by MagiClick to play the 30+ room isometric adventure game <b>Escape from Artemis</b>."

      quotes[4] = "<h3>MagiClick Receives 6 Awards at WebAward 2006</h3><p><img src=\"_i/news/webaward.gif\" align=\"right\">MagiClick Digital Solutions wins <strong>6</strong> awards at the US-based Web Marketing Association's WebAward 2006 Competition.</p><p>MagiClick receives an \"Outstanding Web Site\" award for the <a href=\"http://www.diyabetdunyasi.com\" target=\"_blank\" class=\"small\">Diabetes Portal</a> built for GlaxoSmithKline and \"Standard of Excellence\" awards for <a href=\"http://www.gulf.com.tr\" target=\"_blank\" class=\"small\">GulfOil</a>, <a href=\"http://www.rocakale.com.tr\" target=\"_blank\" class=\"small\">RocaKale</a>, <a href=\"http://www.denizbank.com.tr\">Denizbank</a>, <a href=\"http://www.bilimpharma.com/en/\" target=\"_blank\" class=\"small\">Bilim Pharma</a> and <a href=\"http://www.otokar.com.tr/en/\" target=\"_blank\" class=\"small\">Otokar</a> web site projects, thereby becoming one of the most successful agencies that took part in this year's competition.</p>";
      
    // Haberlerin sayfada görünme yoğunluğu ..
    // 10 Sayfada mutlaka gözükür..
    // Eğer iki haberin ağırlığı 10 atanırsa, diğerleri 0 olmalıdır...  
    var percents = new Array();

      percents[1] = 1;
      percents[2] = 1;

      percents[3] = 0;
      percents[4] = 1;
    var haber1 = ""
    var haber2 = ""
    
    var news = new Array();
    var k = 0;  // Ağırlıklandırılmış haber listesindeki giriş sayısı olacak bu da..
    
function getRandom(a)
{
  for (i = 0; i <= quotes.length; i++){
    if (percents[i]==10){

    }
    else if(0<percents[i]<10){
        for (j=0; j<percents[i]; j++){
            news[k]=quotes[i];
            k = k+1;
        }
        
    }
    }
    
     var index = Math.floor(Math.random() * news.length);
     if (news.length==0){
    return ("rastegele haber yok");
  } else {
    haber1 = news[index];
  }
  
  var index2 = Math.floor(Math.random() * news.length);
  if (haber1==news[index2]){
    index2 = index+8;//En buyuk Degeri burayada yazmali
    if (index2>19){
      index2=0;
      haber2 = news[index2];
    }else{
      haber2 = news[index2];
    }
  }else{
    if (news.length==0){
      return ("rastegele haber yok");
    } else {
      haber2 = news[index2];
    }
  }



document.getElementById("haberA").innerHTML = haber1;
document.getElementById("haberB").innerHTML = quotes[3];
}



window.onload=function(){
  init();
  externalLinks();
  //setFooter();
}
window.onresize=function(){
  //setFooter();
}
