

// take tag value in text like xml structure
function fnc_resparxml(f_data, f_par)
{
var s_part1="<"+f_par+">";
var s_part2="</"+f_par+">";
var firstPos=f_data.indexOf(s_part1);
if (firstPos==-1) return "";
var secondPos = f_data.indexOf(s_part2, firstPos + s_part1.length);
if (secondPos ==-1) return "";
return f_data.substring((firstPos + s_part1.length),secondPos);
}

// validates that the field value string has one or more characters in it
function isNotEmpty(elem,mes) {
  var str = elem.value;
    var re = /.+/;
    if(!str.match(re)) {
        alert(mes);
        elem.focus();        
        return false;
    } else {
        return true;
    }
}

//validates that the entry is a positive or negative number
function isNumber(elem,mes) {
  var str = elem.value;
    var re = /^[-]?\d*\.?\d*$/;
    str = str.toString();
    if (!str.match(re)) {
        alert(mes);
		elem.focus();
        return false;
    }
    return true;
}

// validates that the entry is 16 characters long for cc
function isLen16(elem,mes) {
  var str = elem.value;
    var re = /\b.{16}\b/;
    if (!str.match(re)) {
        alert(mes);
        elem.focus();
        return false;
    } else {
        return true;
    }
}

// validates that the entry is formatted as an e-mail address
function isEMailAddr(elem,mes) {
  var str = elem.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        alert(mes);
        elem.focus();
        return false;
    } else {
        return true;
    }
}
// validate that the user made a selection other than default
function isChosen(elem,mes) {
    if (elem.selectedIndex == 0) {
        alert(mes);
        return false;
    } else {
        return true;
    }
}

// validate that the user has checked one of the radio buttons
function isValidRadio(elem,mes) {
    var valid = false;
    for (var i = 0; i < elem.length; i++) {
        if (elem[i].checked) {
            return true;
        }
    }
    alert(mes);
    return false;
}

function focusElement(formName, elemName) {
    var elem = document.forms[formName].elements[elemName];
    elem.focus();
    elem.select();
}

// new member form
function ValidateNewMemberForm(form) {
    if (isNotEmpty(form.isim,"İsim giriniz..")) {
        if (isEMailAddr(form.eposta,"Eposta Adresinizi Giriniz..")) {
        	if (isNotEmpty(form.telnum1,"Telefon Giriniz..")) {
        		return true;
		}
        }
    }
    return false;
}

// input for members
function ValidateMemberInForm(form) {
	if (isEMailAddr(form.eposta,"Eposta Adresinizi Giriniz..")) {
		if (isNotEmpty(form.parola,"Parolanızı Giriniz..")) {		
        	return true;
        	}
    	}
    return false;
}


// input for message
function ValidateMessageForm(form) {
	if (isEMailAddr(form.visitoremail,"Eposta Adresinizi Giriniz..")) {
		if (isNotEmpty(form.visitorname,"İsminizi Giriniz..")) {
			if (isNotEmpty(form.visitorideas,"Mesajınızı Yazınız..")) {
	        	return true;
			}
        	}
    	}
    return false;
}



// searching
function ValidateSearchingForm(form) {
	if (isNotEmpty(form.aranacak,"Aranacak İfadeyi Giriniz..")) {		
		if (isLen3(form.aranacak,"Aranacak İfadeyi Giriniz. En Az 3 karakter gerekiyor.")) {		
        	return true;
        	}
     	}
    return false;
}

// validates that the entry is 3 characters long
function isLen3(elem,mes) {
  var str = elem.value;
    var re = /\b.{3}\b/;
    if (str.length<3) {
        alert(mes);
        elem.focus();
        return false;
    } else {
        return true;
    }
}




// remember Password
function ValidateRememberpassForm(form) {
	if (isEMailAddr(form.eposta,"Eposta Adresinizi Giriniz..")) {
       	return true;
    	}
    return false;
}



// input for members
function ValidateShowOrderForm(form) {
	if (isEMailAddr(form.eposta,"Eposta Adresinizi Giriniz..")) {
		if (isNotEmpty(form.ordnum,"Sipariş Numarasını Giriniz..")) {		
        	return true;
        	}
    	}
    return false;
}


// sales partner form
function ValidateSalesPartnerForm(form) {
    if (isNotEmpty(form.prtisim,"İsim giriniz..")) {
        if (isEMailAddr(form.prteposta,"Eposta Adresinizi Giriniz..")) {
		if (isNotEmpty(form.prtfirma,"Firma İsmi giriniz..")) {
			if (isNotEmpty(form.prtweb,"Web Adresini giriniz..")) {
				if (isNotEmpty(form.prttel,"Telefon giriniz..")) {			
        			return true;
				}
			}
		}
        }
    }
    return false;
}


function ValidateCommentForm(form) {
    if (isNotEmpty(form.prtaciklama,"Açıklama giriniz..")) {
		if (isNotEmpty(form.prtpoint,"Puan giriniz..")) {
			return true;
			}
		}
	return false;
     }


function firstFocus()
{
   if (document.forms.length > 0)
   {
      var TForm = document.forms[0];
      for (i=0;i<TForm.length;i++)
      {
         if ( (TForm.elements[i].type=='text') || (TForm.elements[i].type=='textarea')||
            (TForm.elements[i].type.toString().charAt(0)==''))
         {
            document.forms[0].elements[i].focus();
            break;
         }
      }
   }
}

//================================================================

function checkBoxes(form, check)
{

  for (var c = 0; c < form.elements.length; c++)
    if (form.elements[c].type == 'checkbox')
      form.elements[c].checked = check;
}

//================================================================

//declare global variables
var rowsSelected = 0;
//change the background color of a row when selected and
//also count how many rows are selected
function colorRow(srcElement)
{
  var cb = event.srcElement;
  var curElement = cb;
  var eskirenk = curElement.style.backgroundColor;

  while (curElement && !(curElement.tagName == "TR"))
  {
    curElement = curElement.parentElement;
  }

  if (!(curElement == cb) && (cb.name != "cbxSelectAll"))
  {
    if (cb.checked)
    {
      curElement.style.backgroundColor = "#CEE2FB";
      rowsSelected = rowsSelected + 1;
    }
    else
    {
      curElement.style.backgroundColor = eskirenk;
      rowsSelected = rowsSelected - 1;
    }
  }
}




// JavaScript Document

function toggle (kat) 
{
	if(document.getElementById(kat).style.display == 'block')
		{ 
			document.getElementById(kat).style.display = 'none';
		}
	else
		{
			document.getElementById(kat).style.display = 'block';
		}
}



// change loc for combo box
function click_fornewlocation (newplc)
{
	document.location = newplc;
}



//fatura ve teslimat adresleri aynı

function same_as_billing()
	{
		if(document.frmorderform.samebilling.checked)
		{
		
			document.getElementById('DELIVERY').style.display = 'block';

			

		}
		else
		{
			document.getElementById('DELIVERY').style.display = 'none';


		}
	}





  