/*Copyright ©2006 Tüm hakları saklıdır.
MERKEZ GAZETE DERGİ BASIM YAYINCILIK SANAYİ VE TİCARET A.Ş. */
function ConfirmClose()
{
	var konfirm = confirm("Kapatmak istediğinize emin misiniz?")
	if (konfirm)
		return true;
	else
		return false;
}

function trimNumber(s) {
	s = s.replace(/^\s*/,'').replace(/\s*$/, '');
	return s;
}


function addCommas() {
	var x = document.forms[0];
	var objRegExp  = new RegExp('([0-9]{4})([0-9]{3})([0-9]{2})([0-9]{2})');

	while(objRegExp.test(x.fieldregexp.value)) {
		x.fieldregexp.value = x.fieldregexp.value.replace(objRegExp, '$1 $2 $3 $4');
	}
}

function Cvc2Help() {
  var wid=200,hgt=200;
  var x, y;
  x = (screen.width - wid) >> 1;
  y = (screen.height - hgt) >> 1;
  window.open("cvc2.html",null,"addressbar=0, scroll=no, resizable=no, left="+x+", top="+y+", width="+wid+", height="+hgt);
}

function ShowImage() {
  var wid=400,hgt=508;
  var x, y;
  x = (screen.width - wid) >> 1;
  y = (screen.height - hgt) >> 1;
  window.open("kalem.html",null,"addressbar=0, scroll=no, resizable=no, left="+x+", top="+y+", width="+wid+", height="+hgt);
}


function FormatCreditCard(thisis) {
	var tempstr,newstr,str,i,str2 ;
	i = 0;
	
	thisis.value = trimNumber(thisis.value);
	str = thisis.value;
	
	while ( 20 > i) {
		str = str.replace(" ", "");
		i = i + 1;
	}
	
	if (str.length > 4) 
	{
		tempstr = str;
		newstr = "";
		i = 0;
		while (tempstr.length > 4)
		{
			newstr = newstr + tempstr.substr(0, 4) + " ";
			tempstr = tempstr.substr(4);
		}
		thisis.value = newstr + tempstr;
	}

	return true;
}

isFocus = 0;

function FormatPhoneNumber(thisis) {
	var tempstr,newstr,str,i,str2 ;
	var commapos,aftercomma,commacount;
	i=0;

	if (isFocus == 1)
	{
		isFocus = 0; 
		return false; 
	}
	
	thisis.value = trimNumber(thisis.value);
	str = thisis.value;
	
	while ( 15 > i) {
		str = str.replace(" ", "");
		i = i + 1;
	}
	
	if (str.length > 9) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 4) + " " + tempstr.substr(4, 3) + " " + tempstr.substr(7, 2) + " " + tempstr.substr(9); 
		thisis.value = newstr;
	}
	else if (str.length > 7) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 4) + " " + tempstr.substr(4, 3) + " " + tempstr.substr(7); 
		thisis.value = newstr;
	}
	else if (str.length > 4) 
	{
		tempstr = str;
		newstr = "";
		newstr = tempstr.substr(0, 4) + " " + tempstr.substr(4); 
		thisis.value = newstr;
	}
}

function Only_Numeric(e) {	
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13) return true;  // Enter
	if (whichCode == 44) return true;  // Comma
	if (whichCode > 57 ) return false;
	if (whichCode < 48 && whichCode > 13) return false;
}

function trim(s) {
	s = s.replace(/^\s*/,'').replace(/\s*$/, '');
	return s;
}

function TrimAll(form) {   
    for (var i=0, j=form.elements.length; i<j; i++) {
        myType = form.elements[i].type;
        if (myType == 'text' || myType == 'textarea')
            form.elements[i].value = trim(form.elements[i].value);
    }
}

function checkNum(data) {    
	return data.match(/^[0-9 ]*$/);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	if (CheckForm(form1) == true) {
  	dede = window.open(theURL,winName,features + ',top=100 ,left=300'); 
	dede.focus();
	return true;
	}
	else
	{
	return false;
	}
}

function IsNumeric(strString) {
   return strString.match(/^\d+$/);
}

function IsNumeric2(strString) {
   if(isNaN(strString)) {
   	return false;
   } else {
   	return true;
   }
}

function ClearAll(form)
{
	for( var i = 0, j = form.elements.length; i < j; i++ )
	{
		myType = form.elements[i].type;
		if( myType == 'text' || myType == 'textarea' || myType == 'select-one' )
		{
			form.elements[i].value = "";
		}
	}
}

function CheckEmail(str)
{
	if (document.layers||document.getElementById||document.all)
	{
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (filter.test(str))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	else
	{
		return true;
	}
}

function CheckKKNo(str) {
	return str.match(/^\d{4}( \d{4}){3}$/);
}
