﻿function ctrlform(fid){
	mycon = document.getElementById(fid);
	if(mycon.value != ""){
		mycon.className = 'inform2';
	}else{
		mycon.className = 'inform';
	}
}

function exitPage(){
	soru = confirm("Tender CMS den çıkmak istiyor musunuz?");
	if(soru){
		location = "index.php?page=logout";
	}
}
function navopen(nid,name){
	document.form.navid.value = nid;
	nid = 'navid' + nid;
	fajax(nid,'form','snid.php');
	document.form.menuheader.value = name;
	showhidenav(nid);
}
function showhidenav(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
		if(el.style.display != "inline"){ 
			el.style.display = "inline";
		}else{
			el.style.display = "none";
		}
	}
}
function consents(){
	if(document.form.consent.value == 1){
		document.form.consent.value = 0;
		document.getElementById("consentimg").src = "images/incorrect.gif";
		document.getElementById("consentxt").innerHTML = "Pasif";
	}else{
		document.form.consent.value = 1;
		document.getElementById("consentimg").src = "images/correct.gif";
		document.getElementById("consentxt").innerHTML = "Aktif";
	}
	
}
function onlyname(a){
	var fileAndPath = document.getElementById(a).value;
	var lastPathDelimiter = fileAndPath.lastIndexOf("\\");
	var fileNameOnly = fileAndPath.substring(lastPathDelimiter+1);
	document.form2.fname.value = fileNameOnly;
}
function onlyname2(a){
	var fileAndPath = document.getElementById(a).value;
	var lastPathDelimiter = fileAndPath.lastIndexOf("\\");
	var fileNameOnly = fileAndPath.substring(lastPathDelimiter+1);
	document.form3.vname.value = fileNameOnly;
}
function deletenews(adv,i,y){
	soru = confirm("Veriyi silmek istiyor musunuz?");
	if(soru){
		window.location = "index.php?page=" + adv + "&" + adv + "=list&newsid=" + y + "&nid=" + i ;
	}
}
function deletecnt(adv,i){
	soru = confirm("Veriyi silmek istiyor musunuz?");
	if(soru){
		window.location = "index.php?page=" + adv + "&" + adv + "=list&did=" + i ;
	}
}
function urldecode( str ) {  
    var histogram = {}, histogram_r = {}, code = 0, str_tmp = [];
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urlencode.
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    
    for (replace in histogram) {
        search = histogram[replace]; // Switch order when decoding
        ret = replacer(search, replace, ret) // Custom replace. No regexing   
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);
 
    return ret;
}

function jumpit(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}