function check()
{	
	if(document.aramaform.kelime.value.length<3)
	{		
		alert("Arama için girdiğiniz kelime en az 3 harften oluşmalı!");
		return false;
	}	
	return true;
}		

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function remove_con(o)
	{
	o.value = "";
	}

function valemail(email_value)
	{
	reExp2 = new RegExp("[\\w\_-]+@[\\w\_-]+\\.[\\w\_-]+");
	if (!(reExp2.test(email_value)))
		{
		alert("Email format not correct!");
		return false;
		}
	return true;
	}

function addfav()
	{
	if (document.all)
		{
		window.external.AddFavorite("http://www.bursasoftbilgisayar.com","BursaSoft Bilgisayar")
		}
	}

function HokusFokus(Degis){
	if (!Degis.base) Degis.base = Degis.value
	if (Degis.value == Degis.base) Degis.value = "";
	else if (Degis.value == "") Degis.value = Degis.base;
}

function show_popup(url,hwin,hwidth,hheight)
{
  window.open(url,
              hwin,
              "height="+hheight+",width="+hwidth+",startx=100,starty=100,resizable=1,scrollbars=1,toolbar=0");
}

function popup_window( url, id, width, height )
{
	popup = window.open( url, id, 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=no,width=' + width + ',height=' + height + ',left=50,top=50' );
	popup.focus();
}
function LogoffControl() {
	return confirm('Kontrol panelinden çıkmak istediğinizden eminmisiniz?');
}

/*
Strip whitespace from the beginning and end of a string
Input : a string
*/
function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

/*
Make sure that textBox only contain number
*/
function checkNumber(textBox)
{
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	
	textBox.value = trim(textBox.value);
/*	if (textBox.value.length == 0) {
		textBox.value = 0;		
	} else {
		textBox.value = parseInt(textBox.value);
	}*/
}

/*
	Check if a form element is empty.
	If it is display an alert box and focus
	on the element
*/
function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}

/*
	Set one value in combo box as the selected value
*/
function setSelect(listElement, listValue)
{
	for (i=0; i < listElement.options.length; i++) {
		if (listElement.options[i].value == listValue)	{
			listElement.selectedIndex = i;
		}
	}	
}


function SetTypeValue(v)
{
	if (v == 1) 
	{
	 		window.document.frmCheckout.txtShippingCompanyName.disabled = true;
			window.document.frmCheckout.txtShippingFirstName.disabled = false;
			window.document.frmCheckout.txtShippingLastName.disabled = false;

	 		window.document.frmCheckout.txtPaymentVergiDaire.disabled = true;
	 		window.document.frmCheckout.txtPaymentVergiNo.disabled = true;

	 		window.document.frmCheckout.txtPaymentCompanyName.disabled = true;
			window.document.frmCheckout.txtPaymentFirstName.disabled = false;
			window.document.frmCheckout.txtPaymentLastName.disabled = false;
		
	}
	else
	{
	 		window.document.frmCheckout.txtShippingCompanyName.disabled = false;
			window.document.frmCheckout.txtShippingFirstName.disabled = true;
			window.document.frmCheckout.txtShippingLastName.disabled = true;

	 		window.document.frmCheckout.txtPaymentVergiDaire.disabled = false;
	 		window.document.frmCheckout.txtPaymentVergiNo.disabled = false;

	 		window.document.frmCheckout.txtPaymentCompanyName.disabled = false;
			window.document.frmCheckout.txtPaymentFirstName.disabled = true;
			window.document.frmCheckout.txtPaymentLastName.disabled = true;
		
	}
	
}

function setShippingInfo(isChecked)
{
	with (window.document.frmCheckout) {
		if (isChecked) {
			txtShippingFirstName.value  = txtRegisteredFirstName.value;
			txtShippingLastName.value   = txtRegisteredLastName.value;
			txtShippingAddress.value    = txtRegisteredAddress.value;
			txtShippingPhone.value      = txtRegisteredPhone.value;
			txtShippingMobilePhone.value= txtRegisteredMobilePhone.value;
			txtShippingState.value      = txtRegisteredState.value;			
			txtShippingCity.value       = txtRegisteredCity.value;
			txtShippingPostalCode.value = txtRegisteredPostalCode.value;
/*			
			txtShippingFirstName.readOnly  = true;
			txtShippingLastName.readOnly   = true;
			txtShippingAddress1.readOnly   = true;
			txtShippingAddress2.readOnly   = true;
			txtShippingPhone.readOnly      = true;
			txtShippingState.readOnly      = true;			
			txtShippingCity.readOnly       = true;
			txtShippingPostalCode.readOnly = true;			
*/			
		} else {
			txtShippingFirstName.readOnly  = false;
			txtShippingLastName.readOnly   = false;
			txtShippingAddress.readOnly   = false;
			txtShippingPhone.readOnly      = false;
			txtShippingMobilePhone.readOnly= false;
			txtShippingState.readOnly      = false;			
			txtShippingCity.readOnly       = false;
			txtShippingPostalCode.readOnly = false;			
			
			txtShippingFirstName.value  = '';
			txtShippingLastName.value   = '';
			txtShippingAddress.value   = '';
			txtShippingPhone.value      = '';
			txtShippingMobilePhone.value= '';
			txtShippingState.value      = '';			
			txtShippingCity.value       = '';
			txtShippingPostalCode.value = '';
			
			
			txtPaymentFirstName.readOnly  = false;
			txtPaymentLastName.readOnly   = false;
			txtPaymentAddress.readOnly   = false;
			txtPaymentPhone.readOnly      = false;
			txtPaymentMobilePhone.readOnly= false;
			txtPaymentState.readOnly      = false;			
			txtPaymentCity.readOnly       = false;
			txtPaymentPostalCode.readOnly = false;			
			
			txtPaymentFirstName.value  = '';
			txtPaymentLastName.value   = '';
			txtPaymentAddress.value   = '';
			txtPaymentPhone.value      = '';
			txtPaymentMobilePhone.value= '';
			txtPaymentState.value      = '';			
			txtPaymentCity.value       = '';
			txtPaymentPostalCode.value = '';


			window.document.frmCheckout.chkSame.checked=false;
			

		}
	}
}

function setPaymentInfo(isChecked)
{
	with (window.document.frmCheckout) {
		if (isChecked) {
			txtPaymentCompanyName.value  = txtShippingCompanyName.value;
			txtPaymentFirstName.value  = txtShippingFirstName.value;
			txtPaymentLastName.value   = txtShippingLastName.value;
			txtPaymentAddress.value   = txtShippingAddress.value;
			txtPaymentPhone.value      = txtShippingPhone.value;
			txtPaymentMobilePhone.value= txtShippingPhone.value;
			txtPaymentState.value      = txtShippingState.value;			
			txtPaymentCity.value       = txtShippingCity.value;
			txtPaymentPostalCode.value = txtShippingPostalCode.value;
/*			
			txtPaymentFirstName.readOnly  = true;
			txtPaymentLastName.readOnly   = true;
			txtPaymentAddress1.readOnly   = true;
			txtPaymentAddress2.readOnly   = true;
			txtPaymentPhone.readOnly      = true;
			txtPaymentState.readOnly      = true;			
			txtPaymentCity.readOnly       = true;
			txtPaymentPostalCode.readOnly = true;
*/						
		} else {
			txtPaymentFirstName.readOnly  = false;
			txtPaymentLastName.readOnly   = false;
			txtPaymentAddress.readOnly   = false;
			txtPaymentPhone.readOnly      = false;
			txtPaymentMobilePhone.readOnly= false;
			txtPaymentState.readOnly      = false;			
			txtPaymentCity.readOnly       = false;
			txtPaymentPostalCode.readOnly = false;			
			
			txtPaymentCompanyName.value  = '';
			txtPaymentFirstName.value  = '';
			txtPaymentFirstName.value  = '';
			txtPaymentLastName.value   = '';
			txtPaymentAddress.value   = '';
			txtPaymentPhone.value      = '';
			txtPaymentMobilePhone.value= '';
			txtPaymentState.value      = '';			
			txtPaymentCity.value       = '';
			txtPaymentPostalCode.value = '';

		}
	}
}


function checkShippingAndPaymentInfo()
{
	with (window.document.frmCheckout) {
	 
	 
		if(FaturaTuru[1].checked)
		{
			if (isEmpty(txtShippingCompanyName, 'Firma Adını Giriniz')) {
			return false;
			}
			else if (isEmpty(txtPaymentCompanyName, 'Faturadaki Firma Adını Giriniz')) {
			return false;
			}
			else if (isEmpty(txtPaymentVergiDaire, 'Firma Vergi Dairesi Adını Giriniz')) {
			return false;
			}
			else if (isEmpty(txtPaymentVergiNo, 'Firma Vergi Numarasını Giriniz')) {
			return false;
			}
		
		}
		else if(FaturaTuru[0].checked)
		{
			if (isEmpty(txtShippingFirstName, 'Adı Giriniz')) {
				return false;
			} 
			else if (isEmpty(txtShippingLastName, 'Soyadı Giriniz')) {
				return false;
			} 
			else if (isEmpty(txtPaymentFirstName, 'Adı Giriniz')) {
				return false;
			} else if (isEmpty(txtPaymentLastName, 'Soyadı Giriniz')) {
				return false;
			} 
			
		}
		else if (isEmpty(txtShippingAddress, 'Teslimat Adresini Giriniz')) {
			return false;
		} else if (isEmpty(txtShippingAddress, 'Teslimat Adresini Giriniz')) {
			return false;
		} else if (isEmpty(txtShippingState, 'Teslimat Adresinin İlçesini Giriniz')) {
			return false;
		} else if (isEmpty(txtShippingCity, 'Teslimat Adresinin Şehir Bilgisini Giriniz')) {
			return false;
		} else if (isEmpty(txtShippingPostalCode, 'Teslimat Adresinin Posta Kodunu Giriniz')) {
			return false;
		} else if (isEmpty(txtShippingPhone, 'Telefon Numarasını Giriniz')) {
			return false;
		} else if (isEmpty(txtPaymentAddress, 'Fatura Adresini Giriniz')) {
			return false;
		} else if (isEmpty(txtPaymentPhone, 'Telefon Numarasını Giriniz')) {
			return false;
		} else if (isEmpty(txtPaymentState, 'Fatura Adresinin İlçe Bilgisini Giriniz')) {
			return false;
		} else if (isEmpty(txtPaymentCity, 'Fatura Adresinin Şehir Bilgisini Giriniz')) {
			return false;
		} else if (isEmpty(txtPaymentPostalCode, 'Fatura Adresinin Posta Kodunu Giriniz')) {
			return false;
		} else {
			return true;
		}
	}
}
