/**
 * Preverjama e-mail ..... IZPISE ALERT
 */
function emailCheckAndDrzava(emailStr, drzava) {
if(drzava!=null) {
   if(drzava==0) {
     alert("Please insert your country!");
      return false;
   } 
}

var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("The e-mail address you entered is not valid")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]


if (user.match(userPat)==null) {

    alert("The username doesn't seem to be valid.")
    return false
}


var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {

	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
    return false
}


var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}


return true;
}//Fine function emailCheckAndDrzava (emailStr)

//--------------------------------------------------------------------------------------------------------

function emailCheck(emailStr) {

var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("The e-mail address you entered is not valid")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]


if (user.match(userPat)==null) {

    alert("The username doesn't seem to be valid.")
    return false
}


var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {

	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
    return false
}


var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}


return true;
}//Fine function emailCheck (emailStr)

//***************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------
//***************************************************************************************************************

/**
 * Preverjama e-mail ..... BREZ ALERTA
 */
function emailCheck_no (emailStr) {

var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	//alert("The e-mail address you entered is not valid")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]


if (user.match(userPat)==null) {

    //alert("The username doesn't seem to be valid.")
    return false
}


var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {

	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        //alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
	//alert("The domain name doesn't seem to be valid.")
    return false
}


var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   //alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

if (len<2) {
   var errStr="This address is missing a hostname!"
   //alert(errStr)
   return false
}


return true;
}//Fine function emailCheck (emailStr)


//***************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------
//***************************************************************************************************************

function popUp(URL) {

 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=526,height=400,left = 100,top = 100');");
 
}//Fine function popUp(URL) {

//***************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------
//***************************************************************************************************************

function popUpFrenk(URL) {

 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=506,height=470,left = 100,top = 100');");
 
}//Fine function popUp(URL) {

//***************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------
//***************************************************************************************************************
   
function popUpBrowser(URL) {

 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "'   );");
 
}//Fine function popUpBrowser(URL) {

//***************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------
//***************************************************************************************************************

function NajdiSliko() {
  
   //Najdemo iz URLja katero sliko moremo nalozit ....
   var docurl=""+document.location;
   var zac = docurl.indexOf('?slika=',0);
   var slika = unescape(docurl.substring(zac+7,docurl.length));
   //Nastavimo zeljeno sliko ...
   mojaSlika = new Image();
   mojaSlika.src = "../images/" + slika;
   document.kkk.src = mojaSlika.src;  
   
}//Fine function NajdiSliko() {

//***************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------
//***************************************************************************************************************
function VerifNumero(fieldName) {
var vejica=0;

  if (fieldName != "")
  { 
  	for (var i = 0; i < fieldName.length ; i++)
    { 	 var charFild=fieldName.charAt(i)
		  if ((charFild<"0") || (charFild>"9"))
          {  if ((charFild!="/") && (charFild!="-") && (charFild!=" ") && (charFild!="+") && (charFild!="(") && (charFild!=")"))
             { return false; }
          }
    } return true;
  }	else {
  return false; }

}//Fine  function VerifNumero(fieldName)

//***************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------
//***************************************************************************************************************

function Order_Chek() {

var err = false;
var err_s = "";
var bala = false;
var mail = true;
var tel = true;

//PiecesDJBasic
//bala=false;
//if(document.Order_Form.PiecesDJBasic.value == "") bala = true;
//if(bala==false && document.Order_Form.PiecesDJBasic.value.trim == "") bala = true;
//if(bala==false && !VerifNumero(document.Order_Form.PiecesDJBasic.value)) bala = true;
//if(bala) {
// err = true;
// err_s = err_s + "\n" + "Pieces of Dj Basic not a number.";
// tel = false;
//}

//PiecesDJProfessional
//bala=false;
//if(document.Order_Form.PiecesDJProfessional.value == "") bala = true;
//if(bala==false && document.Order_Form.PiecesDJProfessional.value.trim == "") bala = true;
//if(bala==false && !VerifNumero(document.Order_Form.PiecesDJProfessional.value)) bala = true;
//if(bala) {
// err = true;
// err_s = err_s + "\n" + "Pieces of Dj Professional not a number.";
// tel = false;
//}

//PiecesDjKeyboard
//bala=false;
//if(document.Order_Form.PiecesDjKeyboard.value == "") bala = true;
//if(bala==false && document.Order_Form.PiecesDjKeyboard.value.trim == "") bala = true;
//if(bala==false && !VerifNumero(document.Order_Form.PiecesDjKeyboard.value)) bala = true;
//if(bala) {
// err = true;
// err_s = err_s + "\n" + "Pieces of DjKeyboard not a number.";
// tel = false;
//}

//PiecesUSBSundCard
//bala=false;
//if(document.Order_Form.PiecesUSBSundCard.value == "") bala = true;
//if(bala==false && document.Order_Form.PiecesUSBSundCard.value.trim == "") bala = true;
//if(bala==false && !VerifNumero(document.Order_Form.PiecesUSBSundCard.value)) bala = true;
//if(bala) {
// err = true;
// err_s = err_s + "\n" + "Pieces of Dual USB Sund Card not a number.";
// tel = false;
//}


//Naslov
bala=false;
if(document.Order_Form.Address.value == "") bala = true;
if(bala==false && document.Order_Form.Address.value.trim == "") bala = true;
if(bala) {
 err = true;
 err_s = err_s + "\n" + "Please, specifiy postal address.";
}

//Ime 
bala=false;
if(document.Order_Form.Name.value == "") bala = true;
if(bala==false && document.Order_Form.Name.value.trim == "") bala = true;
if(bala) {
 err = true;
 err_s = err_s + "\n" + "Please, specifiy first name.";
}

//Priimek
bala=false;
if(document.Order_Form.LastName.value == "") bala = true;
if(bala==false && document.Order_Form.LastName.value.trim == "") bala = true;
if(bala) {
 err = true;
 err_s = err_s + "\n" + "Please, specifiy last name.";
}

//telefon
bala=false;
if(document.Order_Form.Telephone.value == "") bala = true;
if(bala==false && document.Order_Form.Telephone.value.trim == "") bala = true;
if(bala) {
 err = true;
 err_s = err_s + "\n" + "Please, specify phone number ( including area code ).";
 tel = false;
}

//telefon ce so samo stevilke
if( tel ) {
 if(!VerifNumero(document.Order_Form.Telephone.value)) {
  err = true;
  err_s = err_s + "\n" + "Phone number contains illegal character(s).";
 }
}//Fine if( tel )


//mail
bala=false;
if(document.Order_Form.Email.value == "") bala = true;
if(bala==false && document.Order_Form.Email.value.trim == "") bala = true;
if(bala) {
 err = true;
 err_s = err_s + "\n" + "Please, specifiy email address.";
 mail = false;
}


//Ce pravilen mail
if( mail ) {
 if(!emailCheck_no(document.Order_Form.Email.value)) {
  err = true;
  err_s = err_s + "\n" + "Bad email adress.";
 }
}//Fine if( mail )


//Country
bala=false;
if(document.Order_Form.Country.value == "") bala = true;
if(bala==false && document.Order_Form.Country.value == 0) bala = true;
if(bala) {
 err = true;
 err_s = err_s + "\n" + "Please, select your country.";
}

if ( err == false ) {
 //document.Order_Form.action="http://www.ihug.com.au/cgi-bin/mailto"
 document.Order_Form.submit();
 return true;
}
else { 
 alert(err_s); 
 return false;
}


}//Fine function Order_Chek() {

//***************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------
//***************************************************************************************************************

 function PoisciKajZeliNarocit() {
  var url=""+document.location;
  //alert(url);
  var zac = "";
  var url_1 = "";
  var konc = "";
  
  for(var k=0; k<=url.length; k++)
  url = url.replace('+',' ');
  
  zac = url.indexOf('?PiecesDJBasic=',0);
  url_1 = url.substring(zac+15,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.PiecesDJBasic.value = unescape(url_1.substring(0,konc));
 
 /*
  zac = url.indexOf('PiecesDJAdvanced=',0);
  url_1 = url.substring(zac+17,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.PiecesDJAdvanced.value = unescape(url_1.substring(0,konc));
 */
 
  zac = url.indexOf('PiecesDJProfessional=',0);
  url_1 = url.substring(zac+21,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.PiecesDJProfessional.value = unescape(url_1.substring(0,konc));
  
  zac = url.indexOf('PiecesDjKeyboard=',0);
  url_1 = url.substring(zac+17,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.PiecesDjKeyboard.value = unescape(url_1.substring(0,konc));
  
  zac = url.indexOf('PiecesDjKeyboardExtended=',0);
  url_1 = url.substring(zac+25,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.PiecesDjKeyboardExtended.value = unescape(url_1.substring(0,konc));

  zac = url.indexOf('PiecesUSBSundCard=',0);
  url_1 = url.substring(zac+18,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.PiecesUSBSundCard.value = unescape(url_1.substring(0,konc));
  
  zac = url.indexOf('HASI=',0);
  url_1 = url.substring(zac+5,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.HASI.value = unescape(url_1.substring(0,konc));

  zac = url.indexOf('HASI_Service_To_Do=',0);
  url_1 = url.substring(zac+19,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.HASI_Service_To_Do.value = unescape(url_1.substring(0,konc));
  
  zac = url.indexOf('Address=',0);
  url_1 = url.substring(zac+8,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.Address.value = unescape(url_1.substring(0,konc));
 
  //zac = url.indexOf('prihajam=',0);
  //url_1 = url.substring(zac+9,url.length);
  //konc = url_1.indexOf('&',0);
  //document.kiki.prihajam.value = unescape(url_1.substring(0,konc));
 
  zac = url.indexOf('Name=',0);
  url_1 = url.substring(zac+5,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.Name.value = unescape(url_1.substring(0,konc));

  zac = url.indexOf('LastName=',0);
  url_1 = url.substring(zac+9,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.LastName.value = unescape(url_1.substring(0,konc));

  zac = url.indexOf('Company=',0);
  url_1 = url.substring(zac+8,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.Company.value = unescape(url_1.substring(0,konc));
  
  zac = url.indexOf('Telephone=',0);
  url_1 = url.substring(zac+10,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.Telephone.value = unescape(url_1.substring(0,konc));

  zac = url.indexOf('Email=',0);
  url_1 = url.substring(zac+6,url.length);
  konc = url_1.indexOf('&',0);
  document.kiki.Email.value = unescape(url_1.substring(0,konc));
  
  zac = url.indexOf('Country=',0);
  url_1 = url.substring(zac+8,url.length);
  document.kiki.Country.value = url_1;
  
  
 // if( document.kiki.prihajam.value == "da" ) {
 //  document.kiki.action="http://homepages.ihug.com.au/cgi-bin/mailto";
 //  document.kiki.prihajam.value = "ne";
  //} else { 
  // alert("ne");
  // document.location.replace('thanks.html'); }
  
  
 }//Fine  function PoisciKajZeliNarocit()
 
 
//***************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------
//***************************************************************************************************************

function miki() {
/*
   document.kiki.action="http://homepages.ihug.com.au/cgi-bin/mailto";
   document.kiki.submit();
   alert("miki=" + document.kiki.prihajam.value );
   document.kiki.action="thanks.html";
   document.location.replace('thanks.html');
   document.kiki.submit();
*/

/*
 if( document.kiki.prihajam.value == "da" ) {
   document.kiki.action="http://homepages.ihug.com.au/cgi-bin/mailto";
   document.kiki.prihajam.value = "ne";
   document.kiki.submit();
 } else { 
   alert("ne");
   document.kiki.action="thanks.html";
   document.location.replace('thanks.html'); }
*/
   
  
//  if( document.kiki.prihajam.value == "ne" ) {
 //  document.kiki.action="thanks.html";
 //  document.location.replace('thanks.html'); 
 // }
 
 //document.location.replace('thanks.html');
 //document.kiki.action="http://homepages.ihug.com.au/cgi-bin/mailto";
 //document.kiki.submitFrame();
}


function Konj() {
 //  document.kiki.action="http://homepages.ihug.com.au/cgi-bin/mailto";
 //  document.kiki.submit();
}

//***************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------
//***************************************************************************************************************


//Mete puntini e virgole 2000.23 = 2.000,23
function decRoundSlo(x, mesta) {
x= TogliVirg(x);

 //preverimo ce je negativno in odnesemo minus
 var neg=0;
 var st=parseFloat(x);
 if(st < 0) { neg=1; st=Math.abs(st); }


 var niz = ""+ Math.round(x * Math.pow(10, mesta));
 if(niz == "0") return "0";

 var l = 0;
 var izid = ",";
 var leng = niz.length;

 //za st. manjsa od 0.09
 if(leng < mesta)
 { l = mesta - leng;
   for(var k=0; k<l; k++)
   izid = izid + "0";

   return izid+niz;
 }

 l = leng - mesta;
 //Vstavi decimalno vejico
 if(mesta != 0)
  izid = "," + niz.substring(l, niz.length);
 else
  izid="";

 //Vstavi piko na vsaka tri cela mesta
 for(l-=3; l>0; l-=3)
  izid = "." + niz.substring(l,l+3) + izid;

 izid = niz.substring(0, l+3) + izid;

 if(neg == 1) izid = "-" + izid;
 return(izid);
}//Fine  function decRoundSlo(x, mesta)

//***************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------
//***************************************************************************************************************

//Togli virgole e puntini
function TogliVirg(orig) {
var len = orig.length;
var sest = "";
var i = 0;

	for(i=0; i<len; i++) {
     if(orig.substring(i,i+1) == ".") { continue; }
	 sest = sest + orig.substring(i,i+1);
	}
    return sest.replace(',' , '.');

}//Fine function TogliVirg(orig)



// add nbinc 2003.12.06 for update form
function Update_Chek() {   
var err = false;
var err_s = "";
var bala = false;
var mail = true;
var tel = true;

//Ime 
bala=false;
if(document.Order_Form.Name.value == "") bala = true;
if(bala==false && document.Order_Form.Name.value.trim == "") bala = true;
if(bala) {
 err = true;
 err_s = err_s + "\n" + "Please, specifiy first name.";
}

//Priimek
bala=false;
if(document.Order_Form.LastName.value == "") bala = true;
if(bala==false && document.Order_Form.LastName.value.trim == "") bala = true;
if(bala) {
 err = true;
 err_s = err_s + "\n" + "Please, specifiy last name.";
}

//telefon
bala=false;
if(document.Order_Form.Telephone.value == "") bala = true;
if(bala==false && document.Order_Form.Telephone.value.trim == "") bala = true;
if(bala) {
 err = true;
 err_s = err_s + "\n" + "Please, specify phone number ( including area code ).";
 tel = false;
}

//telefon ce so samo stevilke
if( tel ) {
 if(!VerifNumero(document.Order_Form.Telephone.value)) {
  err = true;
  err_s = err_s + "\n" + "Phone number contains illegal character(s).";
 }
}

//mail
bala=false;
if(document.Order_Form.Email.value == "") bala = true;
if(bala==false && document.Order_Form.Email.value.trim == "") bala = true;
if(bala) {
 err = true;
 err_s = err_s + "\n" + "Please, specifiy email address.";
 mail = false;
}


//Ce pravilen mail
if( mail ) {
 if(!emailCheck_no(document.Order_Form.Email.value)) {
  err = true;
  err_s = err_s + "\n" + "Bad email adress.";
 }
}

//Country
bala=false;
if(document.Order_Form.Country.value == "") bala = true;
if(bala==false && document.Order_Form.Country.value == 0) bala = true;
if(bala) {
 err = true;
 err_s = err_s + "\n" + "Please, select your country.";
}

if ( err == false ) {
 //document.Order_Form.action="http://www.ihug.com.au/cgi-bin/mailto"
 document.Order_Form.submit();
 return true;
}
else { 
 alert(err_s); 
 return false;
}

} // end add nbinc