function setValue(id,val) {
	e = document.getElementById(id);
	e.value = val;
}

function submitForm(id){
	document.getElementById(id).submit()
}

function applyFilter(deger) {
	var yaz = new String();
	var numaralar = "0123456789.";
	var chars = deger.value.split("");
	for (i = 0; i < chars.length; i++) {
		if (numaralar.indexOf(chars[i]) != -1) yaz += chars[i];
	}
	if (deger.value != yaz) deger.value = yaz;
}

function urljump_byApply(url,text) 
{ 
    if (confirm(text)) 
    { 
        top.window.location = url; 
    } 
} 

function urljump(url){
	top.window.location = url;
}

function urljump_select(source,url,key){
	id = source.options[source.selectedIndex].value;
	urljump(url+'?'+key+'='+id);
}


function expandit(curobj, hide) {
	if(document.getElementById(curobj)) {
  		folder=document.getElementById(curobj).style;
	} else {
		if(ns6==1||operaaa==true) {
			folder=curobj.nextSibling.nextSibling.style;
		} else {
			folder=document.all[curobj.sourceIndex+1].style;
		}
   }
	if(folder.display=="none")
	{
		folder.display="";
	} else {
		folder.display="none";
	}
	if(hide) {
		var hide_objects = hide.split(",");
		for(i=0; i<hide_objects.length; i++) {
			hide_objects[i]=hide_objects[i].replace(/^\s*(.*)/, "$1");
			hide_objects[i]=hide_objects[i].replace(/(.*?)\s*$/, "$1");
			if(document.getElementById(hide_objects[i])) {
				hidden=document.getElementById(hide_objects[i]).style;
				if(hidden.display=="") {
					hidden.display="none";
				}
			}
		}
	}
}

function checkMail(field) {
	good = false;
	// Note: The next expression must be all on one line...
	//       allow no spaces, linefeeds, or carriage returns!
	var goodEmail = field.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

	if (goodEmail){
  		good = true;
	}else{
   		good = false;
   }
   return good;
}

function order_form_control(form_id){
	form = document.getElementById(form_id);
	name = form.name.value;
	address = form.address.value;
	tel = form.tel.value;
	gsm = form.gsm.value;
	mail = form.mail.value;
	
	vals = '';
	apply = true;
	if(name.length < 4){
		vals+= 'İsim alanı geçersiz\n';
		apply = false;
	}
	if(address.length < 10){
		vals+= 'Adres alanı geçersiz\n';
		apply = false;
	}
	if(tel.length < 7 && gsm.length < 7){
		vals+= 'Bir sabit telefon veya mobil telefon belirtin\n';
		apply = false;
	}
	if(!checkMail(mail)){
		vals+= 'E-posta alanı geçersiz\n';
		apply = false;
	}
	
	if(!apply){
		text = 'Geçersiz Alanlar\n\n' + vals;
		alert(text);
	}else{
		form.submit();
	}
}

function contact_form_control(form_id){
	form = document.getElementById(form_id);
	name = form.name.value;
	tel = form.tel.value;
	gsm = form.gsm.value;
	mail = form.mail.value;
	msg = form.msg.value;
	
	vals = '';
	apply = true;
	if(name.length < 4){
		vals+= 'İsim alanı geçersiz\n';
		apply = false;
	}
	if(msg.length < 15){
		vals+= 'Mesaj uzunluğu çok kısa\n';
		apply = false;
	}
	if(tel.length < 7 && gsm.length < 7){
		vals+= 'Bir sabit telefon veya mobil telefon belirtin\n';
		apply = false;
	}
	if(!checkMail(mail)){
		vals+= 'E-posta alanı geçersiz\n';
		apply = false;
	}
	
	if(!apply){
		text = 'Geçersiz Alanlar\n\n' + vals;
		alert(text);
	}else{
		form.submit();
	}
}

function login_form_control(form_id){
	form = document.getElementById(form_id);
	username = form.username.value;
	password = form.password.value;
	
	vals = '';
	apply = true;
	if(username.length < 4){
		vals+= 'Kullanıcı geçersiz\n';
		apply = false;
	}
	if(password.length < 4){
		vals+= 'Şifre geçersiz\n';
		apply = false;
	}
	
	if(!apply){
		text = 'Geçersiz Alanlar\n\n' + vals;
		alert(text);
	}else{
		form.submit();
	}
}

function login_reg_form_control(form_id){
	form = document.getElementById(form_id);
	username = form.newusername.value;
	password = form.newpassword.value;
	password2 = form.newpassword2.value;
	
	vals = '';
	apply = true;
	if(username.length < 4){
		vals+= 'Kullanıcı geçersiz\n';
		apply = false;
	}
	if(password != '' && password != password2){
		vals+= 'Şifreler biribiri ile uyuşmuyor\n';
		apply = false;
	}
	
	if(password != '' && password.length < 4){
		vals+= 'Şifre geçersiz\n';
		apply = false;
	}
	
	if(!apply){
		text = 'Geçersiz Alanlar\n\n' + vals;
		alert(text);
	}else{
		form.submit();
	}
}

function module_selection(sel,t){
	ind = sel.selectedIndex;
	tar = document.getElementById(t);
	val = sel.options[ind].value;
	
	old = tar.value;
	old_html = res.innerHTML;
	
	txt = old+val;
	html = old_html+"<li>"+val+"</li>";
	mtxt = txt;
	
	mtxt = mtxt.replace("<br>","");
	mtxt = mtxt.replace("<li>","");
	mtxt = mtxt.replace("</li>","");
	mtxt = mtxt.replace("<span class='content_orange'>","");
	mtxt = mtxt.replace("</span>","");
	
	tar.value = mtxt;
	
	res.innerHTML = html;
	sel.selectedIndex = 0;
}

function arrange_modules(sel){
	ind = sel.selectedIndex;
	val = sel.options[ind].value;
	
	/*v7_div = document.getElementById("v7_div");
	sql_div = document.getElementById("sql_div");
	sql8_div = document.getElementById("sql8_div");
	efw_div = document.getElementById("efw_div");
	*/
	if(val == "ETA 7 For Graphics"){
		v7_div.className = "show";
		sql_div.className = "hide";
		sql8_div.className = "hide";
		efw_div.className = "hide";
	}
	if(val == "ETA For Windows"){
		v7_div.className = "hide";
		sql_div.className = "hide";
		sql8_div.className = "hide";
		efw_div.className = "show";
	}
	if(val == "ETA-8 SQL"){
		v7_div.className = "hide";
		sql_div.className = "hide";
		sql8_div.className = "show";
		efw_div.className = "hide";
	}
	if(val == "ETA SQL"){
		v7_div.className = "hide";
		sql_div.className = "show";
		sql8_div.className = "hide";
		efw_div.className = "hide";
	}
}