// VARIABLES

// FUNCTIONS

function fGetID(ID){
    return document.getElementById(ID)
}

function Jump(sayfa,deger,obj){
    if(obj.options[obj.selectedIndex].value)
        eval("self.location='"+sayfa+"?"+deger+"="+obj.options[obj.selectedIndex].value+"'")
}

function fHide(sID){  
  obj = typeof(sID)=="object" ? sID : fGetID(sID)
  obj.style.display='none'
}
function fShow(sID){
  obj = typeof(sID)=="object" ? sID : fGetID(sID)
  obj.style.display='block'  
}

function fShowHide(sID){
  obj = typeof(sID)=="object" ? sID : fGetID(sID)
  durum = obj.style.display
  obj.style.display = (durum == "none" || !durum) ? "block" : "none"
}

function fSil(sUpdTable,sUpdKriterValue,sUpdKriterColumn){
  if(confirm("Eminmisiniz?"))
    if(confirm("Son Kararınız?"))
      xajax_fxSil(sUpdTable,sUpdKriterValue,sUpdKriterColumn);
}

function fRemove(sID){
  obj = typeof(sID)=="object" ? sID : fGetID(sID)
  obj.removeNode(true)
}

function fFlash(file,w,h){
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+w+'" height="'+h+'">')
    document.write('<param name="movie" value="'+file+'">')
    document.write('<param name="quality" value="high">')
    document.write('<param name="wmode" value="transparent">')
    document.write('<embed src="'+file+'" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" wmode="transparent">')
    document.write('</embed>')
    document.write('</object>')
}

function fGetPageSize() {
  var xScroll, yScroll;
  if (window.innerHeight && window.scrollMaxY) {  
    xScroll = window.innerWidth + window.scrollMaxX;
    yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    xScroll = document.body.scrollWidth;
    yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    xScroll = document.body.offsetWidth;
    yScroll = document.body.offsetHeight;
  }
  var windowWidth, windowHeight;
  if (self.innerHeight) {  // all except Explorer
    if(document.documentElement.clientWidth){
      windowWidth = document.documentElement.clientWidth; 
    } else {
      windowWidth = self.innerWidth;
    }
    windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  }  
  // for small pages with total height less then height of the viewport
  if(yScroll < windowHeight){
    pageHeight = windowHeight;
  } else { 
    pageHeight = yScroll;
  }  
  // for small pages with total width less then width of the viewport
  if(xScroll < windowWidth){  
    pageWidth = xScroll;    
  } else {
    pageWidth = windowWidth;
  }
  arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
  return arrayPageSize;
};

function fAlert(sContentIn,bClose,noFadeIn){
  sContentMask = '<div id="Mask"></div>'
  $("body").append(sContentMask);
  var arrPageSizes = fGetPageSize();
  var w = arrPageSizes[0]; var h = arrPageSizes[1];
  
  sContent = '<div id="AlertHolder">';
  if(bClose==true)
    sContent += '<div id="close"><img src="/img/close.png" onClick="fAlertClose()"></div>';
  sContent += '<div id="content">'+sContentIn+'</div>';
  sContent += '</div>';
  $("#Mask").append(sContent);
  $("#Mask").css({width:w,height:h})
  if(noFadeIn)
    $("#Mask").show()
  else
    $("#Mask").fadeIn()
}

function fAlertClose(){
  $("#AlertHolder").remove();
  $("#Mask").fadeOut(function(){$("#Mask").remove()});
}

function fIMGMidi(){
  src = $(this).attr("src")
  $("#UrunHolder #Images #Midi").attr("src",src.replace("thumb","midi"))
}

function fIMGBig(obj){
  src = $(this).attr("src")
  srcBig = src.replace("midi","big")
  sContent = "<div style='border:1px solid #CCC;background-color:#FFF'><img src='"+srcBig+"'></div>"
  fAlert(sContent,'1')
}

/* ESC ----------------------------------------------- */
function fESC(e) {
  var kC = (window.event) ? event.keyCode : e.keyCode;
  var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE // MSIE : Firefox
  if(kC==Esc){
    if($('#Mask').length>0)
      $('#Mask').remove();
    if(objAktifMenuItem){
      objAktifMenuItem.style.display = "none"
    }

  }
}

function fSepetUpdate(){
  var sContent = ""
  $("#SepetHolder span[id='Adet'] input").each(function(){
    sContent += $(this).attr("dbID")+","+$(this).val()+"#";
  })
  //alert(sContent)
  xajax_fxSepetUpdate(sContent)
}


$(document).ready(function(){  
  $("#UrunHolder #Images #Thumb img").click(fIMGMidi)
  $("#UrunHolder #Images #Midi").click(fIMGBig)
}
);
