function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		anaSayfa_over = newImage("images/anaSayfa-over.gif");
		hakkimizda_over = newImage("images/hakkimizda-over.gif");
		hizmetlerimiz_over = newImage("images/hizmetlerimiz-over.gif");
		referanslarimiz_over = newImage("images/referanslarimiz-over.gif");
		mevzuat_over = newImage("images/mevzuat-over.gif");
		linkler_over = newImage("images/linkler-over.gif");
		iletisim_over = newImage("images/iletisim-over.gif");
		preloadFlag = true;
	}
}

//News
var interval;
yukseklik=0; 
ust=yukseklik;
HrCursor=0;
HrCursorTop=0;
dikeyuzunluk=200
speed=75
waitingspeed=1000

function ayarla()
{
	yukseklik=document.all.news.offsetHeight;				
	if (document.all('hr0')!=null)
	{HrCursorTop=document.all('hr0').offsetTop;	
	}				
	if (yukseklik==0) {setTimeout("ayarla()",60)};				
}

function dongu()
{
	if (ust<=-yukseklik) {ust=dikeyuzunluk};
	if (scrolling) 
	{
	ust=ust-1;
	document.all.news.style.top=ust;
	}
	if (ust==-HrCursorTop)
	{	
	cursorchange();
	interval=setTimeout("dongu()",waitingspeed)
	}
	else
	{
	interval=setTimeout("dongu()",speed)
	}
}

function cursorchange()
{
	HrCursor=HrCursor+1;
	if (document.all('hr'+HrCursor)!=null)
	{ HrCursorTop=document.all('hr'+HrCursor).offsetTop;	
	}
	else
	{
	HrCursor=0;
	HrCursorTop=0;
	if (document.all('hr0')!=null)
		{HrCursorTop=document.all('hr0').offsetTop;
		}
	}				
}

function NewsWrite(SubDikeyuzunluk,SubSpeed,SubWaitingspeed)
{
dikeyuzunluk=SubDikeyuzunluk
speed=SubSpeed
waitingspeed=SubWaitingspeed
scrolling=true
document.all('news').innerHTML='<label onmousemove="javascript:scrolling=false;" onmouseout="javascript:scrolling=true;" > '
  + document.all('news').innerHTML +'</label>'
ayarla();
dongu();	
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function mOvr(src,clrOver) {
    if (!src.contains(event.fromElement)) {
	  //src.style.cursor = 'hand';
	  src.bgColor = clrOver;	  
	}
  }

 function mOut(src,clrIn) {
		if (!src.contains(event.toElement)) {
			src.style.cursor = 'default';
			src.bgColor = clrIn;
		}
  }

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

 function ShowHideBlock(blockId)
        {
            if (document.getElementById(blockId).style.display == "block")
            {
                document.getElementById(blockId).style.display = "none";
            }
            else
            {
                document.getElementById(blockId).style.display = "block";
            }
        }

function openDocument(docURL, w, h) {
 var opt='scrollbars=no,toolbar=no,status=no,menubar=no,width='+w+',height='+h+',left=100,top=100';
 imgWin = window.open(docURL,'',opt);
}

function getScreenSize() {
    var screenW = 1024, screenH = 768;
    if (parseInt(navigator.appVersion)>3) {
    screenW = screen.width;
    screenH = screen.height;
    }
    else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled()) {
        var jToolkit = java.awt.Toolkit.getDefaultToolkit();
        var jScreenSize = jToolkit.getScreenSize();
        screenW = jScreenSize.width;
        screenH = jScreenSize.height;
    }
    return new Array(screenW, screenH);
}

function popImage(pictureID) 
        {
            var screen = getScreenSize();
            var opt='scrollbars=no,width=150,height=100,left=100,top=100';
            
            imgWin = window.open('','',opt);
            with (imgWin.document) {
                    writeln('<html><head><title>...</title><style type="text/css">body { margin: auto; margin:0; padding: 0;}</style>');
                    writeln('<sc'+'ript type="text/javascript">');
                    writeln('function resizePopup() {');
                    writeln('width = document.images[0].width ; ');
                    writeln('height = document.images[0].height ; ');
                    writeln('if ('+ screen[0]+' < width || '+screen[1]+' < height) { width = '+screen[0]+'/2; height='+screen[1]+'/2; document.images[0].width = width; document.images[0].height = height;}');
                    writeln('window.resizeTo(width+10, height+70);');
                    writeln('if (window.innerWidth) { window.innerWidth = width ; window.innerHeight = height; }');
                    writeln('}');
                    writeln('</s' + 'cript>');
                    writeln('</head><body bgcolor="#ffffff" onload="resizePopup();">')
                    writeln('<img src="/Picture/PictureHandler.ashx?pictureID='+pictureID+'&thumb=yes&height=500" onclick="window.close();" border="0" style="position: absolute; left: 0px; top: 0px; cursor: pointer;"/></body></html>');
                    close();
            }
        }
        
 function change_picture(img_name, img_src) 
        {
            var image = document.getElementById(img_name);
            image.setAttribute("src", img_src);            
        }  
                 
function change_magicmagnify_big_picture(anchor_name, img_src) 
        {
            document.getElementById(anchor_name).href=img_src;
            document.getElementById(anchor_name).setAttribute("class", "MagicMagnifyPlus"); 
            MagicMagnifyPlus.refresh();            
        }                   

var pictureID;
function set_pictureID(tmpID) 
{
    pictureID = tmpID;
}

function popImage2() 
{
    var screen = getScreenSize();
    var opt='scrollbars=no,width=150,height=100,left=100,top=100';
    
    imgWin = window.open('','',opt);
    with (imgWin.document) {
            writeln('<html><head><title>...</title><style type="text/css">body { margin: auto; margin:0; padding: 0;}</style>');
            writeln('<sc'+'ript type="text/javascript">');
            writeln('function resizePopup() {');
            writeln('width = document.images[0].width ; ');
            writeln('height = document.images[0].height ; ');
            writeln('if ('+ screen[0]+' < width || '+screen[1]+' < height) { width = '+screen[0]+'/2; height='+screen[1]+'/2; document.images[0].width = width; document.images[0].height = height;}');
            writeln('window.resizeTo(width+10, height+70);');
            writeln('if (window.innerWidth) { window.innerWidth = width ; window.innerHeight = height; }');
            writeln('}');
            writeln('</s' + 'cript>');
            writeln('</head><body bgcolor="#ffffff" onload="resizePopup();">')
            writeln('<img src="../Picture/PictureHandler.ashx?pictureID='+pictureID+'&thumb=yes&height=500" onclick="window.close();" border="0" style="position: absolute; left: 0px; top: 0px; cursor: pointer;"/></body></html>');
            close();
    }
}
            
function popImage3(image_path) 
{
    var screen = getScreenSize();
    var opt='scrollbars=no,width=150,height=100,left=100,top=100';
    
    imgWin = window.open('','',opt);
    with (imgWin.document) {
            writeln('<html><head><title>...</title><style type="text/css">body { margin: auto; margin:0; padding: 0;}</style>');
            writeln('<sc'+'ript type="text/javascript">');
            writeln('function resizePopup() {');
            writeln('width = document.images[0].width ; ');
            writeln('height = document.images[0].height ; ');
            writeln('if ('+ screen[0]+' < width || '+screen[1]+' < height) { width = '+screen[0]+'/2; height='+screen[1]+'/2; document.images[0].width = width; document.images[0].height = height;}');
            writeln('window.resizeTo(width+10, height+70);');
            writeln('if (window.innerWidth) { window.innerWidth = width ; window.innerHeight = height; }');
            writeln('}');
            writeln('</s' + 'cript>');
            writeln('</head><body bgcolor="#ffffff" onload="resizePopup();">')
            writeln('<img src="'+image_path+'" onclick="window.close();" border="0" style="position: absolute; left: 0px; top: 0px; cursor: pointer;"/></body></html>');
            close();
    }
}
        
function SelectIt (idVal) 
{ 
    var frm = document.forms[0];
    // Loop through all elements
    for (i=0; i<frm.length; i++) 
    {
        if (idVal.indexOf ('SelectThis') != -1) 
        {
            if(frm.elements[i].checked == false) 
            {
                frm.elements[1].checked = false;
            }
        }
    }

}                 
                 
                 

/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
    if(document.getElementById){
        var el = document.getElementById(obj);
        var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
        if(el.style.display != "block"){ //DynamicDrive.com change
            for (var i=0; i<ar.length; i++){
                if (ar[i].className=="submenu") //DynamicDrive.com change
                    ar[i].style.display = "none";
            }
            el.style.display = "block";
        }
        else{
            el.style.display = "none";
        }
    }
}

function SwitchMenu2(obj){
    if(document.getElementById){
        var el = document.getElementById(obj);
        var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
        if(el.style.display != "block"){ //DynamicDrive.com change           
            el.style.display = "block";
        }
        else{
            el.style.display = "none";
       }
    }
}

function SwitchMenu3(obj, obj_header){
    if(document.getElementById){
        var el = document.getElementById(obj);        
        var header = document.getElementById(obj_header);        
        if(el.style.display != "block"){ 
            var ar = document.getElementById("master_menu").getElementsByTagName("div"); 
            for (var i=0; i<ar.length; i++){
                if (ar[i].className=="sub_product_category_list") 
                    ar[i].style.display = "none";
                if ((ar[i].className=="product_category_list_selected") || (ar[i].className=="product_category_list")) 
                    ar[i].className="product_category_list";
            }
            el.style.display = "block";
            header.className = "product_category_list_selected";
        }
        else{
            el.style.display = "none";
            header.className = "product_category_list";
        }
    }
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate                 
