var min=10;
var max=14;
function increaseFontSize()
{
	var p=document.getElementsByTagName('body');
   for(i=0;i<p.length;i++)
	{
      if(p[i].style.fontSize)
		{
         var s=parseInt(p[i].style.fontSize.replace("px",""));
      }
		else
		{
         var s=11;
      }
      if(s!=max)
		{
         s+=1;
      }
      p[i].style.fontSize=s+"px"
   }
}

function decreaseFontSize()
{
   var p=document.getElementsByTagName('body');
   for(i=0;i<p.length;i++)
	{
      if(p[i].style.fontSize)
		{
         var s=parseInt(p[i].style.fontSize.replace("px",""));
      }
		else
		{
         var s=11;
      }
      if(s!=min)
		{
         s-=1;
      }
      p[i].style.fontSize=s+"px"
   }
}


function set_metatags(title, keywords, description)
{
   metatags=document.getElementsByTagName("meta");

   for(cnt=0; cnt<metatags.length; cnt++)
    {
      var name=metatags[cnt].getAttribute("name");
      var content=metatags[cnt].getAttribute("content");

      // Update the Title meta tag
      if(metatags[cnt].getAttribute("name")=="Title" && title!="")
         metatags[cnt].setAttribute("content", title);

      // Update the Keywords meta tag
      if(metatags[cnt].getAttribute("name")=="keywords" && keywords!="")
         metatags[cnt].setAttribute("content", keywords);


      // Update the Description meta tag
      if(metatags[cnt].getAttribute("name")=="description" && description!="")
         metatags[cnt].setAttribute("content", description);

    }
}

function MM_swapImgRestore()
{
   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()
{
   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)
{
   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_swapImage()
{
   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 clearForm()
{
   for(i=0;i<document.getElementById('form').elements.length;i++)
   {
      if(document.getElementById('form').elements[i].type=="text" || document.getElementById('form').elements[i].type=="password") { document.getElementById('form').elements[i].value=""; }
   }
}

function popupWindow(mypage, myname, w, h, scroll)
{
   var winl=(screen.width - w) / 2;
   var wint=(screen.height - h) / 2;
   winprops='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
   win=window.open(mypage, myname, winprops)
   if(parseInt(navigator.appVersion)>=4){ win.window.focus(); }
}

function askProceed(lang)
{
   var confRes;
   if(lang=='greek'){ confRes=confirm("Για την ασφάλεια της συναλλαγής σας θα συνδεθείτε στο σύστημα συναλλαγών της ALPHA BANK."); }
   else{ confRes=confirm("For security reasons you will be redirected to ALPHA BANK transaction system."); }

   if(confRes)
   {
      document.getElementById('form1').action.value='send';
      document.getElementById('form1').submit();
   }
   else
   {
      location.href='index.php?option=shop';
   }
}

function calcPrice(lang)
{
   var percost=0;
   var cost_off=0;
   var cost=0;
   var count=document.getElementById("count").value;

   if(isNaN(count))
   {
      if(lang=='greek')
      {
         document.getElementById('perprice').innerHTML="0";
         document.getElementById('price_off').innerHTML="Μη έγκυρος αριθμός.";
         document.getElementById('price').innerHTML="Μη έγκυρος αριθμός.";
      }
      else
      {
         document.getElementById('perprice').innerHTML="0";
         document.getElementById('price_off').innerHTML="Invalid number";
         document.getElementById('price').innerHTML="Invalid number";
      }
   }
   else
   {
      if(count>=0 && count<=250000)
      {
			var currentTime = new Date();
			var month = currentTime.getMonth() + 1 ;
			var monthe = month.toString();
			var year = currentTime.getFullYear();
			var yeare = year.toString();
        	var mydate = yeare + '-' + monthe;
        	var Ddate = mydate.toString();

         if(count>=500 && count <1000)
         {
            percost=0.053;
            cost_off=Math.round(count * percost * 100)/100;
            cost=Math.round(cost_off * 1.23 * 100)/100;
         }
         else if(count>=1000 && count<5000)
         {
            percost=0.052;
            cost_off=Math.round(count * percost * 100)/100;
            cost=Math.round(cost_off * 1.23 * 100)/100;
         }
         else if(count>=5000 && count<10000)
         {
            percost=0.050;
            cost_off=Math.round(count * percost * 100)/100;
            cost=Math.round(cost_off * 1.23 * 100)/100;
         }
         else if(count>=10000 && count<20000)
         {
            percost=0.048;
            cost_off=Math.round(count * percost * 100)/100;
            cost=Math.round(cost_off * 1.23 * 100)/100;
         }
         else if(count>=20000 && count<50000)
         {
            percost=0.046;
            cost_off=Math.round(count * percost * 100)/100;
            cost=Math.round(cost_off * 1.23 * 100)/100;
         }
         else if(count>=50000 && count<100000)
         {
            percost=0.045;
            cost_off=Math.round(count * percost * 100)/100;
            cost=Math.round(cost_off * 1.23 * 100)/100;
         }
         else if(count>=100000 && count<=250000)
         {
            percost=0.044;
            cost_off=Math.round(count * percost * 100)/100;
            cost=Math.round(cost_off * 1.23 * 100)/100;
         }

         cost = Math.round(cost*100)/100;

         document.getElementById('perprice').innerHTML = percost;
         document.getElementById('price_off').innerHTML = cost_off;
         document.getElementById('price').innerHTML = cost;

         var costStr = cost.toString();

         document.getElementsByName('charge')[0].value = costStr;
      }
      else if(count>250000)
      {
         if(lang=='greek')
         {
            document.getElementById('perprice').innerHTML="0";
            document.getElementById('price_off').innerHTML="<a href='index.php?option=contact' class='green'>επικοινωνήστε</a> μαζί μας για ακόμη χαμηλότερες χρεώσεις";
            document.getElementById('price').innerHTML="<a href='index.php?option=contact' class='green'>επικοινωνήστε</a> μαζί μας για ακόμη χαμηλότερες χρεώσεις";
         }
         else
         {
            document.getElementById('perprice').innerHTML="0";
            document.getElementById('price_off').innerHTML="Invalid number of credits.";
            document.getElementById('price').innerHTML="Invalid number of credits.";
         }
      }
   }
}

function trySubmit(lang, type)
{
   document.getElementById('form').action.value='send';
   document.getElementById('form').submit_type.value=type;
   document.getElementById('form').submit();
}

function keytrySubmit(lang)
{
	if((event.which && event.which==13) || (event.keyCode && event.keyCode==13)){
		trySubmit(lang);
		return false;
	}
}

///////////////////////////////show-hide/////////////////////
function ShowHide()
{
	if(document.getElementById && document.getElementsByTagName && document.createTextNode)
	{
		window.onload=initShowHide;
	}
}

function initShowHide()
{
   // Hide all toggleable sections with JavaScript for the highly improbable case that CSS is disabled
   // Note that in this case the 'flash of visible content' still will occur
   // For testing purposes you can add the following code to disable CSS: document.getElementsByTagName('link')[0].disabled = true;
   hide();
   var toggle=document.getElementById('viewContent');
   var as=toggle.getElementsByTagName('a');
   for(var i=0; i<as.length; i++)
   {
      as[i].onclick=function()
      {
         show(this);
         return false;
      }
   }
}

function show(s)
{
   hide();
   var id=s.href.match(/#(\w.+)/)[1];
   document.getElementById(id).style.display='block';
}

function hide()
{
   var toggleable=document.getElementById('viewContent').getElementsByTagName('div');
   for(var i=0; i<toggleable.length; i++){ toggleable[i].style.display='none'; }
}
/////////////////////////////////////////////////////////////////