var isNN = (navigator.appName.indexOf("Netscape") != -1);
var isIE = (navigator.appName.indexOf("Microsoft") != -1);

function win(fileName) 
{
	var myFloater = window.open('','myWindow','scrollbars=yes,resizable=yes,status=no,width=300,height=300');
	myFloater.location.href = fileName;
	if (window.focus) myFloater.focus();
}

function winimage(fileName,width,height) 
{
	var myFloater = window.open('','myWindow','scrollbars=yes,resizable=yes,status=no,width=' + width + ',height=' + height);
	myFloater.location.href = fileName;
}

function getCookie(sName) {
	var aCookie = document.cookie.split('; ');
	for (var i=0; i < aCookie.length; i++) {
		var aCrumb = aCookie[i].split('=');
		if (sName == aCrumb[0]) {
			return unescape(aCrumb[1]);
		}
	}
	return null;
}

function toggleTinyEditors () {
	for (var i = 0; i < editors.length; i++) {
		var id = editors[i].identify();
		if (!tinyMCE.getInstanceById(id)) {
			tinyMCE.execCommand('mceAddControl',false,id);
			document.cookie = 'tinyMCE=on';
		} else {
			tinyMCE.execCommand('mceRemoveControl',false,id);
			document.cookie = 'tinyMCE=off';
		}
	}
}

/**
 * Handles taking user to next page automatically when logging in or
 * registering
 * 
 * Note: Uses prototype!
 * 
 * @param string form ID of form to submit
 * @param string replaceTxt
 */
function autoSubmitForm (form, replaceTxt) {
	var delay = 2000; //time to wait after the page is done loading
	
	Event.observe(window, 'load', function () {
		setTimeout(function () {
			//2 seconds after page is done loading, auto submit the form.
			myForm = $(form);
			if (myForm){
				if (replaceTxt) {
					window.location.replace(replaceTxt);
				}
				myForm.submit();
			}
		}, delay);
	});
}

function morecats(wspan)
{
	 var cats=document.getElementById('cats_'+wspan);
	 var more_link=document.getElementById('ml_'+wspan);
	 if (cats.style.display=='none') {
		 cats.style.display='inline';
		 more_link.innerHTML='<br /><strong>Kapat</strong>';
	 } else {
		 cats.style.display='none';
		 more_link.innerHTML='<strong>Tümünü Göster</strong>';
	 }
}

function isArray(obj) {
	if (obj.constructor.toString().indexOf("Array") == -1)
		return false;
	else
		return true;
}

function getkey(e) {
	if (window.event)
	return window.event.keyCode;
	else if (e)
	return e.which;
	else
	return null;
}

function set_chars(e, goods) {
	var key, keychar;
	key = getkey(e);

	if (key == null) return true;

	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();

	goods = goods.toLowerCase();

	if (goods.indexOf(keychar) != -1)
	return true;

	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
	return true;

	return false;
}

function price_format(a, th) {
	if(th == ''){
		a = parseInt(a) + '';
	}else if(th == ' '){
		a=parseInt(a.replace(/ /g ,''))+ '';
	}else if(th == '.'){
		a=parseInt(a.replace(/\./g ,''))+ '';
	}else if(th == ','){
		a=parseInt(a.replace(/,/g ,''))+ '';
	}
	var b = "";
	if(a.length > 3){
		while( a.length > 3){
			b = th + a.substr(a.length - 3) + b;
			a = a.substr(0,a.length - 3);
		}
		b = a + b;
	}else{
		b = a;
	}
	if(!b || b=='NaN') b='';
	return b;
}

function blockC(e) {

	olay = document.all ? window.event : e;

	tus = document.all ? olay.keyCode : olay.which;

	if(olay.ctrlKey&&(tus==99||tus==67||tus==118||tus==86)) {

		if(document.all) { olay.returnValue = false; } else { olay.preventDefault(); }

	}

}



