$txt_missing_email8 = "Nėra adreso";
$txt_missing_email7 = "Domeno Vardo išplėtimas yra blogas";
$txt_missing_email6 = "Domeno Vardas yra blogas";
$txt_missing_email5 = "Gavėjo IP Adresas tra blogas";
$txt_missing_email4 = "Vardas yra blogas";
$txt_missing_email3 = "Domeno varde yra blogų simbolių";
$txt_missing_email2 = "Varde yra blogų simbolių";
$txt_missing_email1 = "E-pašto adresas blogas";
$txt_missing_email   = "Prašau įrašyti savo E-pašto adresą!";
$txt_missing_name   = "Prašau įvesti vardą";
$txt_missing_address   = "Prašau įvesti adresą!";
$txt_missing_city   = "Prašau įvesti miestą pavadinimą!";
$txt_missing_zip    = "Prašau įvesti pašto indeksą";
$txt_missing_num   = "Prašau įvesti numerį!";
$txt_missing_country   = "Prašau įvesti šalį!";
$txt_wrong_quantity   = "Blogas kiekis";

function emailCheck (emailStr) {

if(emailStr == "") {

    alert ($txt_missing_email);

    return false;

}

var checkTLD=1;
var knownDomsPat=/^(com|net|org|lt|ru|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
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($txt_missing_email1); return false;}

var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert($txt_missing_email2);

return false;

} }

for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert($txt_missing_email3);
return false;
} }

if (user.match(userPat)==null) {
alert($txt_missing_email4);
return false; }

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert($txt_missing_email5);
return false;
} }
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert($txt_missing_email6);
return false;
}
}

if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert($txt_missing_email7);
return false;
}
if (len<2) {
alert($txt_missing_email8);
return false;
}
}

function checkmail(theForm)
{
   if (emailCheck(theForm.email.value) == false)
                {
    theForm.email.focus();
                return(false);
                }
        return (true);
}

function getCookieVal (offset) {

var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {

var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}

return null;
}

function cset(bus) {
document.cookie = 'kainos' + '=' + bus;
kokis = GetCookie('kainos');
if (kokis != bus) alert('Pas Jus uždrausti sausainiukai (cookies)');
}

function gset(bus,ka) {
document.cookie = 'grup' + '=' + bus;
kokis = GetCookie('grup');
if (kokis != bus) alert('Pas Jus uždrausti sausainiukai (cookies)');
parent.location.href=ka;
}

function setCookie(NameOfCookie, value, expiredays)
{

var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

// The next line stores the cookie, simply by assigning
// the values to the "document.cookie" object.
// Note the date is converted to Greenwich Mean time using
// the "toGMTstring()" function.

document.cookie = NameOfCookie + "=" + escape(value) +
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}


function popupnr(mylink, windowname, refocus)
{
var mywin, href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
   mywin = window.open(href, windowname, 'width=640,height=330,determined,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
// if we just opened the window
if (
   mywin.closed ||
   (! mywin.document.URL) ||
   (mywin.document.URL.indexOf("about") == 0)
   )
   mywin.location=href;
else if (refocus)
   mywin.focus();
return false;
}



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;

}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);

}



function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function cset(bus) {
document.cookie = 'kainos' + '=' + bus;
kokis = GetCookie('kainos');
if (kokis != bus) alert('Pas Jus uždrausti sausainiukai (cookies)');
 }
 
 
function trinti(num) {
parent.location.href = "index.php?me=kr&ka="+num;
 }

function keisti(num,vnt) {
parent.location.href = "index.php?me=kr&kan="+num+"&vnt="+vnt;
 }


function popup(mylink)

{
if (!window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
   window.open(href, '_blank', 'width=640,height=330,determined,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');



return false;

}



function form_validator(theForm)
{
   if (emailCheck(theForm.email.value) == false)
                {
    theForm.email.focus();
                return(false);
                }
           if(theForm.phone.value == "") {
                 alert($txt_missing_num);
                 theForm.phone.focus();
                 return(false);
        }
        if(theForm.name.value == "") {
                 alert($txt_missing_name);
                 theForm.name.focus();
                 return(false);
        }
        return (true);
}

function alterError(value) {
                if (value<=0.99)
                  {
                        newPounds = '0';
                  } else {
                        newPounds = parseInt(value);
                  }
                newPence = parseInt((value+.0008 - newPounds)* 100);
                if (eval(newPence) <= 9) newPence='0'+newPence;
                newString = newPounds + '.' + newPence;
                return (newString);
        }

 function newWin(url,wName,attributes) {
     var newWindow = window.open(url,wName,attributes);}


 


