function dochoosen(idsi,aranacak){
	var cont = document.getElementById(aranacak);
	var myObjColl = getElementsByClassName('itemselected', 'img', cont);
	for (i = 0, j = myObjColl.length; i < j; i++) {
		myObjColl[i].className = "itemselect";
	}
	target = document.getElementById(idsi); 
	target.className = "itemselected";
	chooseOption('chooseModel',idsi);

//alert(idsi);
}

function changecolor(){
	this.style.color ='#FFF';
}

function changecolor2(){
	this.style.color = '#CCC';
}

function getHighlight(){
	mycontainer = document.getElementById('ssscontainer').getElementsByTagName('p');
	//alert(mycontainer.length);
	for(i=0; i< mycontainer.length; i++){
		mycontainer[i].onmouseover = changecolor;
		mycontainer[i].onmouseout = changecolor2;
	}
}

//My Dynamic Content
//SwitchContent("errorapply", "section/dynamic.aspx@opview=apply&errorURL="+url);

var enableCache = true;
var jsCache = new Array();
var dynamicContent_ajaxObjects = new Array();

function ajax_showContent(divId,ajaxIndex,url){
	document.getElementById(divId).innerHTML = dynamicContent_ajaxObjects[ajaxIndex].response;
	if(enableCache){
		jsCache[url] = 	dynamicContent_ajaxObjects[ajaxIndex].response;
	}
	dynamicContent_ajaxObjects[ajaxIndex] = false;
}

function collapseSiteMap(idsi,aranacak){
	var cont = document.getElementById(aranacak);
	var myObjColl = getElementsByClassName('acik', 'p', cont);
	for (i = 0, j = myObjColl.length; i < j; i++) {
		myObjColl[i].className = "gizli";
	}
	target = document.getElementById(idsi); 
	target.className = "acik";
	showThis(idsi);
}

//Config Renkler 

function chooseRim(jant){
	document.getElementById('sagjant').src = 'configurator/arac/jant_'+jant+'.gif';
	document.getElementById('soljant').src = 'configurator/arac/jant_'+jant+'.gif';
	document.getElementById('RimBig').src = 'configurator/arac/jant_'+jant+'_b.jpg';
	document.getElementById('jantText').innerHTML = document.getElementById('jant'+jant).title;
	ConfiguratorRightSection('jant',jant);
}

function mainExternalColor(renk,model){
	//alert(renk);
	document.getElementById('renkbuyuk').style.background = 'url(configurator/arac/'+renk+'.jpg)';
	var alttext = document.getElementById(renk).title;	
	document.getElementById('renkaciklamasi').innerHTML = alttext;
	
	InteriorColor(renk,model);
	ConfiguratorRightSection('disrenk', renk);
}

function InteriorColor(extColor, model){
	SwitchContent('IntColorList','interiorExtModelColors@model='+model+'&extColor='+extColor);
}

function SetInteriorColorBig(intColor){
	//alert(intColor);
	var alttext = document.getElementById(intColor).title;
	document.getElementById('IntColorBig').style.background = 'url(configurator/arac/'+intColor+'.jpg)';
	document.getElementById('IntColorText').innerHTML = alttext;
	ConfiguratorRightSection('icrenk', intColor);
}

function showLoader(action){
	switch(action){
		case 'ac':
			document.getElementById('mainconfig').style.display = 'none';
			document.getElementById('indicator_loading').style.display = 'block';
		break;
		case 'kapat':
			document.getElementById('mainconfig').style.display = 'block';
			document.getElementById('indicator_loading').style.display = 'none';
		break;
	}
}

function close(div1,div2){
	document.getElementById(div1).style.display= 'none';
	document.getElementById(div2).style.display= 'block';
}

function noCache(uri){return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567)};


function showThis(whitch){
	document.getElementById(whitch).style.display = 'inline';
}
function ConfiguratorRightSection(opview,data){
	url = noCache('configurator_right_session.aspx@opview='+opview+'&'+opview+'='+data);
	//alert(url);
	//alert(url);
	divId = 'conf_session';
	if(enableCache && jsCache[url]){
		document.getElementById(divId).innerHTML = jsCache[url];
		return;
	}	
	var ajaxIndex = dynamicContent_ajaxObjects.length;

	dynamicContent_ajaxObjects[ajaxIndex] = new sack();
	document.getElementById(divId).innerHTML = 'Seçiminiz Kaydediliyor...';
	dynamicContent_ajaxObjects[ajaxIndex].requestFile = url;
	dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_showContent(divId,ajaxIndex,url); };
	dynamicContent_ajaxObjects[ajaxIndex].runAJAX();	
}

var myselected;
function chooseOption(opview,choosen){
	switch(opview){
		case 'chooseCar':
			SwitchContent('mainconfig','step2@model='+ choosen);
			ConfiguratorRightSection('model','1');
		break;
		case 'chooseModel':
			//alert();
		//	SwitchContent('configurator_right','selectedModel@model='+choosen.substr(6));
			myselected = choosen.substr(6);
			ConfiguratorRightSection('motor',myselected);
		break;
		case 'colorSelect':
			//alert(myselected);
			SwitchContent('mainconfig','step3@model='+ myselected);
			ConfiguratorRightSection('motor',myselected);
		break;
		case 'hardware':
			SwitchContent('mainconfig','hardware@model='+ myselected);
		break;
	}
}

function bayiiResimLeri(bayii){
	var myLink = document.getElementById('bayiiresimLink');
	myLink.href = 'bayiiResim.aspx@ResimID='+bayii;
	myLink.style.display= 'inline';
}

function TestDrives(divId,url){
	if(enableCache && jsCache[url]){
		document.getElementById(divId).innerHTML = jsCache[url];
		return;
	}	
	var ajaxIndex = dynamicContent_ajaxObjects.length;
	dynamicContent_ajaxObjects[ajaxIndex] = new sack();
	dynamicContent_ajaxObjects[ajaxIndex].requestFile = url;
	dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_showContent(divId,ajaxIndex,url); };
	dynamicContent_ajaxObjects[ajaxIndex].runAJAX();	
}

function SwitchContent(divId,url){
	url = "doconfig.aspx@opview="+url;
	if(enableCache && jsCache[url]){
		document.getElementById(divId).innerHTML = jsCache[url];
		return;
	}	
	var ajaxIndex = dynamicContent_ajaxObjects.length;

	dynamicContent_ajaxObjects[ajaxIndex] = new sack();
	document.getElementById(divId).innerHTML = 'Yükleniyor...';
	dynamicContent_ajaxObjects[ajaxIndex].requestFile = url;
	dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_showContent(divId,ajaxIndex,url); };
	dynamicContent_ajaxObjects[ajaxIndex].runAJAX();	
}


//By Class Name Function
function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;    
  var objColl = (strTag == '*' && document.all) ? document.all : objContElm.getElementsByTagName(strTag);
  var arr = new Array();                              
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';   
  var arrClass = strClass.split(delim);    
  for (i = 0, j = objColl.length; i < j; i++) {                         
    var arrObjClass = objColl[i].className.split(' ');   
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (k = 0, l = arrObjClass.length; k < l; k++) {
      for (m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]); 
          break comparisonLoop;
        }
      }
    }
  }
  return arr; 
}

//Open Picture Window
function PictureWin(theURL,winName,features) {
  window.open('imagePop.aspx@image='+theURL,winName,features);
}
//Open Normal Window
function NewPop(theURL,winName,features) {
  window.open(theURL,winName,features);
}

//function popupac(model, tablo){
//	url = 'modeltables.aspx@opview='+tablo+'@model='+model+'.aspx';
//	NewPop(url,'modeltable','status=yes,scrollbars=yes,width=540,height=600');
//}

function popupac(tablo){
	var url = 'modeltables_'+ tablo +'.aspx';
	NewPop(url, 'modeltable','status=yes,scrollbars=yes,width=540,height=600');
}

//Musteri Hizmetleri Form Kontrolleri
function isEMailAddr() {
    var str = document.musteriform.email.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
       // alert("Verify the e-mail address format.");
        //setTimeout("focusElement('" + elem.musteriform.name + "', '" + elem.name + "')", 0);
        return false;
    } else {
        return true;
    }
}

function checkSendtoFriend(){
	myform = document.sendtoFriend;
	myalert = Array();
	var countit = 0;
	if(myform.isim.value.length < 3){
		myalert[countit++] = 'Lütfen isminizi yazınız.\n';
	}if(myform.eposta.value.length < 8){
		myalert[countit++] = 'Lütfen e-posta adresinizi yazınız.\n';
	}if(myform.aisim.value.length < 3){
		myalert[countit++] = 'Lütfen alıcı ismini yazınız.\n';
	}if(myform.aeposta.value.length < 8){
		myalert[countit++] = 'Lütfen alıcı email adresini yazınız.\n';
	}
	if(myalert.length > 0){
		alerttext = 'Formda hatalar bulunuyor: \n\n';
		for(i=0; i< myalert.length; i++){
			if(myalert[i].length > 5){
				alerttext += myalert[i];
			}
		}
		alert(alerttext);
	}else{
		myform.submit();
	}
}






/** Yaromat **/
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 YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){
	//Telefon Eklendi
	var myform = document.testsurusu;
	if(myform.istel.value.length < 10 && myform.ceptel.value.length < 10 && myform.evtel.value.length < 10){
		s = s+'* Telefon bilgilerinden en az bir tanesini girmeniz gerekmektedir.\n';
	}	  
	  alert('Lütfen alttaki alanlari doldurunuz:\t\t\t\t\t\n\n'+s)
	}
  document.MM_returnValue = (s=='');
}


/** Scroll **/
function verifyCompatibleBrowser(){ 
    this.ver=navigator.appVersion 
    this.dom=document.getElementById?1:0 
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
 
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
    return this 
} 
bw=new verifyCompatibleBrowser() 
var speed=30 
var loop, timer 
function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight 
    this.up=MoveAreaUp;this.down=MoveAreaDown; 
    this.MoveArea=MoveArea; this.x; this.y; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 
function MoveArea(x,y){ 
    this.x=x;this.y=y 
    this.css.left=this.x 
    this.css.top=this.y 
} 
function MoveAreaDown(move){ 
	if(this.y>-this.scrollHeight+objContainer.clipHeight){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".down("+move+")",speed) 
	} 
} 
function MoveAreaUp(move){ 
	if(this.y<0){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".up("+move+")",speed) 
	} 
} 
function PerformScroll(speed){ 
	if(initialised){ 
		loop=true; 
		if(speed>0) objScroller.down(speed) 
		else objScroller.up(speed) 
	} 
} 
function CeaseScroll(){ 
    loop=false 
    if(timer) clearTimeout(timer) 
} 
var initialised; 
function InitialiseScrollableArea(){ 
    objContainer=new ConstructObject('divContainer') 
    objScroller=new ConstructObject('divContent','divContainer') 
    objScroller.MoveArea(0,0) 
    objContainer.css.visibility='visible' 
    initialised=true; 
} 