

//addLoadListener(initHeroLinks);
//addLoadListener(initDeviceSelector);
//addLoadListener(initScrollListeners);
//addLoadListener(startScroller);
//addLoadListener(startDeviceSelector);
//addLoadListener(initScrollTransformer);
var loopflag=false;
var selm;
var stop_scroll = false ;
var scrollToPos = new Array(2);
function startScroller()
{
 if(location.href.indexOf('?scrollTo=')!=-1)
 {
  var ankerpos = location.href.indexOf('?scrollTo=') + "?scrollTo=".length;
  var anker = location.href.substring(ankerpos);
  setTimeout("godlyScrollToElement2('"+anker+"')",1000);
 }
}
function startDeviceSelector()
{
 if(location.href.indexOf('?device=')>-1)
 {
  var devicepos = location.href.indexOf('?device=') + 8;
  var device = location.href.substring(devicepos);
  showOrHideFeatsForDevice2(device);
 } 
}
function initDeviceSelector()
{
 if($('device_list'))
 {
  var list = $('device_list').getElementsByTagName("a");
  for(var i = 0; i < list.length; i++ ) { attachEventListener(list[i], "click", showOrHideFeatsForDevice, false); }
 }
}

function initHeroLinks()
{
 if($('links_superHero'))
 {
 var list= $('links_superHero').getElementsByTagName("a");
 for(var i = 0; i < list.length; i++ )
 {
  if(list[i].className=="hero_device_link")
  {
    attachEventListener(list[i], "mouseover", heroShow, false);
    attachEventListener(list[i], "mousemove", heroShowMove, false);
    attachEventListener(list[i], "mouseout", heroNoShow, false);
  }
 }
 }
}

function initScrollListeners()
{
 if( (document.URL).indexOf('mio-club') == -1 )
 {
 initScrollCleaner();
 var list = document.getElementsByTagName("a");
 for(var i = 0; i < list.length; i++ )
 {
  if( list[i].href.indexOf('#')!=-1 )
  {
   var link = list[i].href.substring(0,list[i].href.indexOf('#'));
   var pagina = location.href;
   if( location.href.indexOf('#')!=-1 )
   {
    pagina = location.href.substring(0,location.href.indexOf('#'));
   }
   if( location.href.indexOf('?')!=-1 )
   {
    pagina = location.href.substring(0,location.href.indexOf('?'));
   }
   if(link==pagina)
   {
    attachEventListener(list[i], "click", godlyScrollToElement, false);
   }
  }
 }
 initScrollTransformer();
 }
}
function initScrollCleaner()
{
 var list = document.getElementsByTagName("a");
 for(var i = 0; i < list.length; i++ )
 {
  if(location.href.indexOf('?scrollTo=')!=-1)
  {
   var ankerpos = location.href.indexOf('?scrollTo=') + "?scrollTo=".length;
   var anker = location.href.substring(ankerpos);
   list[i].href=list[i].href.replace("?scrollTo="+anker, ""); 
  }
 }
}
function initScrollTransformer()
{
 var list = document.getElementsByTagName("a");
 for(var i = 0; i < list.length; i++ )
 {
  if(( list[i].href.indexOf('#')!=-1 ) && ( list[i].className!="top_link" ))
  {
   list[i].href=list[i].href.replace("#", "?scrollTo="); 
  }
 }
}

function heroShow(event)
{
    var target = getEventTarget(event); 
    var elm=$(target.id+"_popup").innerHTML;
    var pic=$(target.id+"_img").src;
    var x=0; var y=0;
    var scrollingPosition = getScrollingPosition();
     if (typeof event.pageX != "undefined" && typeof event.x != "undefined")
     {
       x = event.pageX;
       y = event.pageY;
     }
     else
     {
       x = event.clientX + scrollingPosition[0];
       y = event.clientY + scrollingPosition[1];
     }
  
  
  
 var hero_pop_up;
    if($('hero_pop_up'))
    {
        hero_pop_up=$('hero_pop_up');
    }
    else
    {
        hero_pop_up = document.createElement('div');  
        hero_pop_up.id="hero_pop_up";
        $('ajaxcontainer').appendChild(hero_pop_up);
    }
    hero_pop_up.innerHTML="<div><div class=\"img\"><img src=\""+pic+"\" alt=\"\" /></div><h1>"+target.innerHTML+"</h1><ul>"+elm+"</UL><div style=\"clear:both;display:none;\"></div></div><div class=\"einde\"></div>";
    hero_pop_up.style.display="block";
    hero_pop_up.style.position="absolute";
    var dim = getWidth(hero_pop_up);
 var pos = getPosition(target.parentNode);
 //alert(x);
    hero_pop_up.style.left=(x-180)+"px";
    hero_pop_up.style.top=(y-dim[1]-5)+"px";
    
}
function heroNoShow(event)
{
    var target = getEventTarget(event); 
    var elm=$('hero_pop_up');
    
    elm.style.display="none";
}
function heroShowMove(event)
{
    var target = getEventTarget(event); 
    var elm=$(target.id+"_popup").innerHTML;
    var x=0; var y=0;
    var scrollingPosition = getScrollingPosition();
     if (typeof event.pageX != "undefined" && typeof event.x != "undefined")
     {
       x = event.pageX;
       y = event.pageY;
     }
     else
     {
       x = event.clientX + scrollingPosition[0];
       y = event.clientY + scrollingPosition[1];
     }
    hero_pop_up=$('hero_pop_up');  
    var dim = getWidth(hero_pop_up);
    hero_pop_up.style.left=(x-180)+"px";
    hero_pop_up.style.top=(y-dim[1]-5)+"px";
    
}



function showOrHideFeatsForDevice(event)
{
  var target = getEventTarget(event); 
 var loper=target.parentNode;
 var teller=0;
 loper=loper.previousSibling; if(loper) if(loper.tagName!="LI") loper=loper.previousSibling;
 while(loper) {
  loper.firstChild.className=""; 
  teller=teller+1;
  loper=loper.previousSibling; if(loper) if(loper.tagName!="LI") loper=loper.previousSibling;
 }
 loper=target.parentNode;
 loper=loper.nextSibling; if(loper) if(loper.tagName!="LI") loper=loper.nextSibling;
 while(loper) {
  loper.firstChild.className=""; 
  loper=loper.nextSibling; if(loper) if(loper.tagName!="LI") loper=loper.nextSibling;
 }
 target.className="this_device"; 
 var verplaatsing= -84 * teller;
 //$("product_name_choise").style.background="url(img/devices/Mio-C520-features-headers.gif) transparent no-repeat 3px "+ (verplaatsing) +"px";
 $("product_name_choise").style.background=$("product_name_choise").style.backgroundImage+" transparent no-repeat 3px "+ (verplaatsing) +"px";
 var elementFeats = deviceFeat[target.innerHTML];
 var allFeats = deviceFeat["All"];
 for(var i = 0; i < allFeats.length; i++ )
 {
   if(komtElementVoor(allFeats[i],elementFeats))
   {
    updateFeatElement(allFeats[i], true);
   }
   else
   {
    updateFeatElement(allFeats[i], false);
   }
 }
 setTimeout("verwijderHiders()",500);
}
function showOrHideFeatsForDevice2(elm)
{
 var elementFeats = deviceFeat["Mio "+elm ];
 var allFeats = deviceFeat["All"];
 for(var i = 0; i < allFeats.length; i++ )
 {
   if(komtElementVoor(allFeats[i],elementFeats))
   {
    updateFeatElement(allFeats[i], true);
   }
   else
   {
    updateFeatElement(allFeats[i], false);
   }
 }
 setTimeout("verwijderHiders()",500);
}
function updateFeatElement(elm, show)
{
 if(show)
 {
  if( $(elm).getAttribute("class")=="feature_device_specific" )
  {
   updatingDiv(elm);
   $(elm).setAttribute("class","");
   $(elm).className="";
   $(elm+"Mini").setAttribute("class","");
   $(elm+"Mini").className="";
  }  
 }
 else
 {
  if( $(elm).getAttribute("class")!="feature_device_specific" )
  {
   updatingDiv(elm);
   $(elm).className="feature_device_specific";
   $(elm).setAttribute("class","feature_device_specific");
   $(elm+"Mini").className="no_feature_anymore";
   $(elm+"Mini").setAttribute("class","no_feature_anymore");
   zetVanachter2(elm,"Mini");
   zetVanachter2(elm,"");
   //alert(elm);
  }
 }
}
function updatingDiv(elm)
{
 var div = $(featDivUpdateConnection[elm]);
 if($(div.id+"Hider"))
 { 
  $(div.id+"Hider").style.display="block";
  $(div.id+"HiderFront").style.display="block";
 }
 else
 {   
  var hiddenElement = document.createElement("div");
  hiddenElement.setAttribute("id", div.id+"Hider");
  hiddenElement.setAttribute("class", "Hider");
  var stijl = hiddenElement.style;
  stijl.position="absolute";
  var pos = getPosition(div);
  var dim  = getWidth(div);
  stijl.width=dim[0]+"px";
  stijl.height=dim[1]+"px";
  stijl.left=pos[0]+"px";
  stijl.top=pos[1]+"px";
  stijl.backgroundColor="#fff";
  stijl.filter = "alpha(opacity=70)";
  stijl.opacity = (0.7);
        stijl.MozOpacity = (0.7);
   stijl.KhtmlOpacity = (0.7);
  
  $('ajaxcontainer').appendChild(hiddenElement );
  
  
  var loader = document.createElement("div");
  loader.setAttribute("id", div.id+"HiderFront");
  loader.setAttribute("class", "Hider");
  loader.innerHTML = " Sorting List..";
  stijl=loader.style;
  stijl.position="absolute";
  
  var mijndim = getWidth(loader);
  stijl.left=pos[0] + (dim[0]/2) - (mijndim[0]/2) - 50 + "px";
  stijl.top= pos[1] + (dim[1]/2) - (mijndim[1]/2) + "px";
  stijl.backgroundColor="#fff";
  stijl.border="1px solid #ccc";
  stijl.padding="3px";
  $('ajaxcontainer').appendChild(loader);
 }
}
function zetVanachter(elm)
{
  var par = $(elm+"Mini").parentNode.parentNode;
  var div = par.removeChild($(elm+"Mini").parentNode);
  par.appendChild(div);
}
function zetVanachter2(elm,prefix)
{
  var par = $(elm+prefix);
  while(par.tagName!="UL") par=par.parentNode;
  var child = $(elm+prefix);
  while(child.tagName!="LI") child=child.parentNode;
  var div = par.removeChild(child);
  par.appendChild(div);
  //alert(par.tagName);
}
function verwijderHiders()
{
 var list = $('ajaxcontainer').getElementsByTagName("div");
 for(var i = 0; i < list.length; i++ )
 {
  if( list[i].getAttribute("class")=="Hider")
  {
   list[i].style.display="none";
  }
 } 
}
function komtElementVoor(elm, arr)
{
 var vlag = false;
 for(var i = 0; i < arr.length; i++ ) {
  if(arr[i]==elm)
  {
   vlag=true;
   return vlag;
  }
 }
 return vlag;
}
function getClickedScrollTo(event)
{
 var target = getEventTarget(event);
 var elm;
 while((target.tagName!="A")&&(target.tagName!="a"))
 {
  target=target.parentNode; 
 }
 if(target.getAttribute("href").indexOf("/")==-1)
  elm=$((target.getAttribute("href")).substring(1,(target.getAttribute("href")).length));
 else
 {
  var begin=target.getAttribute("href").indexOf("?scrollTo=");
  var elem=target.getAttribute("href").substring(begin+"?scrollTo=".length);
  elm=$(elem);
 }
 return elm;
}
function godlyScrollToElement(event)
{
 var elm = getClickedScrollTo(event);
 
 var scrollPos=getScrollingPosition();
 var elmPos=getPosition(elm);
 var teller;
 var eenheid;
 if(scrollPos[1]<elmPos[1])
 {
   eenheid=0.1;
   teller=1;
 }
 else
 {
   eenheid=-0.1;
   teller=-1;
 }
 var midHoogte=scrollPos[1]+((elmPos[1]-scrollPos[1])/2);
 var safety=scrollPos[1];
 var stopFlag=false;
 while(((scrollPos[1]<elmPos[1]-teller)||(scrollPos[1]>elmPos[1]+teller))&&(stopFlag==false))
 {
  scrollBy(0,teller);
  scrollPos=getScrollingPosition(elm);
  if(safety==scrollPos[1])
  {
   stopFlag=true;
  }
  safety=scrollPos[1];
  if(eenheid>0)
  {
   if(scrollPos[1]<midHoogte)
   {
    teller=teller+eenheid;
   }
   else
   {
    teller=teller-eenheid; 
    if(teller<=0)teller=1;
   }
  }
  else
  {
   if(scrollPos[1]>midHoogte)
   {
    teller=teller+eenheid;
   }
   else
   {
    teller=teller-eenheid; 
    if(teller>=0)teller=-1;
   }
  }
 }
 if(elm)
 {
  //if(elm.id!="rightcolumn") magicHighLight(elm);
 }
 return false;
}
function godlyScrollToElement2(target)
{
 scrollTo(0,0);
 var elm = $(target);
 var teller=1;
 var eenheid;
 var scrollPos=getScrollingPosition(elm);
 var elmPos=getPosition(elm);
 if(scrollPos[1]<elmPos[1])
 {
   eenheid=0.1;
   teller=1;
 }
 else
 {
   eenheid=-0.1;
   teller=-1;
 }
 var midHoogte=scrollPos[1]+((elmPos[1]-scrollPos[1])/2);
 var safety=scrollPos[1];
 var stopFlag=false;
 while((scrollPos[1]<elmPos[1]-teller)&&(stopFlag==false))
 {
  scrollBy(0,teller);
  scrollPos=getScrollingPosition(elm);
  if(safety==scrollPos[1])
  {
   stopFlag=true;
  }
  safety=scrollPos[1];
  if(scrollPos[1]<midHoogte)
  {
   teller=teller+0.1;
  }
  else
  {
   teller=teller-0.1; 
   if(teller<=0)teller=1;
  }
 }
 //magicHighLight(elm);
 return false;
}
function magicHighLight(elm)
{
 loopFlag=true;
 //elm.className="highlight";
 naarGrijs(elm,"255");
 //selm=elm;
 //setTimeout("verwijderHighLightClass(selm)",500);
}
function verwijderHighLightClass(elm)
{
 elm.className="";
}
function keerKleurTerug(elm,waarde)
{
 res = parseInt(waarde);
 res=res+5;
 waarde=""+res;
 var letter="0";
 if(res<100) letter=waarde;
 else
 {
  switch(res)
  {
   case 10: letter="A";;break;
   case 11: letter="B";break;
   case 12: letter="C";break;
   case 13: letter="D";break;
   case 14: letter="E";break;
   case 15: letter="F";break;
  }
  letter=d2h(res);
 }
 var kleur="#"+letter+letter+letter;
 //alert(res+" / "+letter+" / "+kleur);
 elm.style.backgroundColor=kleur;
 if(waarde>245)
 {
  elm.className="";
 }
 if(waarde<250)
 {
  //setTimeout("keerKleurTerug(elm,waarde)",1000);
  selm=elm;
  setTimeout("keerKleurTerug(selm,'"+res+"')",100);
 }
 else
 {
  if(loopFlag==false)
  {
   elm.style.backgroundColor="#fff";
   elm.style.backgroundColor="transparant";
  }
  else
  {
   loopFlag=false;
   selm=elm;
   setTimeout("naarGrijs(selm,\"255\")",30);
  }
 }
}

function naarGrijs(elm,waarde)
{
 res = parseInt(waarde);
 res=res-5;
 waarde=""+res;
 var letter="0";
 if(res<100) letter=waarde;
 else
 {
  switch(res)
  {
   case 10: letter="A";;break;
   case 11: letter="B";break;
   case 12: letter="C";break;
   case 13: letter="D";break;
   case 14: letter="E";break;
   case 15: letter="F";break;
  }
  letter=d2h(res);
 }
 var kleur="#"+letter+letter+letter;
 //alert(res+" / "+letter+" / "+kleur);
 elm.style.backgroundColor=kleur;
 if(waarde<245)
 {
  elm.className="highlight";
 }
 if(waarde>232)
 {
    //alert(elm.id);
    selm=elm;
  //setTimeout("keerKleurTerug(elm,waarde)",1000); 
  setTimeout("naarGrijs(selm,'"+res+"')",30);
 }
 else
 {
  keerKleurTerug(elm,"232");
 }
}
































function addLoadListener(fn)
{
 if (typeof window.addEventListener != 'undefined')
 {
   window.addEventListener('load', fn, false);
 }
 else if (typeof document.addEventListener != 'undefined')
 {
   document.addEventListener('load', fn, false);
 }
 else if (typeof window.attachEvent != 'undefined')
 {
   window.attachEvent('onload', fn);
 }
 else
 {
   var oldfn = window.onload;
   if (typeof window.onload != 'function')
   {
     window.onload = fn;
   }
   else
   {
     window.onload = function()
     {
       oldfn();
       fn();
     };
   }
 }
}
function attachEventListener(target, eventType, functionRef, capture)
{
 if (typeof target.addEventListener != "undefined")
 {
  target.addEventListener(eventType, functionRef, capture);
 }
 
 else if (typeof target.attachEvent != "undefined")
 {
  target.attachEvent("on" + eventType, functionRef);
 }
 
 else
 {
  eventType = "on" + eventType;
  if (typeof target[eventType] == "function")
  {
   var oldListener = target[eventType];
   target[eventType] = function()
        {
           oldListener();
           return functionRef();
        };
     }
     else
     {
        target[eventType] = functionRef;
     }
  }
}
function detachEventListener(target, eventType, functionRef, capture)
{
 if (typeof target.removeEventListener != "undefined")
 {
   target.removeEventListener(eventType, functionRef, capture);
 }
 else if (typeof target.detachEvent != "undefined")
 {
   target.detachEvent("on" + eventType, functionRef);
 }
 else
 {
   target["on" + eventType] = null;
 }
}
function getEventTarget(ev)
{
 if (typeof ev == "undefined") {
     ev = window.event;
  }
var e = window.event ? window.event : ev;
 var t = e.target ? e.target : e.srcElement;
return t;
}
function getPosition(theElement)
{
 var positionX = 0;
 var positionY = 0;
 while (theElement != null)
 {
   positionX += theElement.offsetLeft;
   positionY += theElement.offsetTop;
   theElement = theElement.offsetParent;
 }
 return [positionX, positionY];
}
function getWidth(theElement)
{
 var out = [theElement.offsetWidth, theElement.offsetHeight];
 return out;
}
function getElementsByAttribute(attribute, attributeValue)
{
 var elementArray = new Array();
 var matchedArray = new Array();
 if (document.all)
 {
   elementArray = document.all;
 }
 else
 {
   elementArray = document.getElementsByTagName("*");
 }
 for (var i = 0; i < elementArray.length; i++)
 {
   if (attribute == "class")
   {
     var pattern = new RegExp("(^| )" +
         attributeValue + "( |$)");
     if (pattern.test(elementArray[i].className))
     {
       matchedArray[matchedArray.length] = elementArray[i];
     }
   }
   else if (attribute == "for")
   {
     if (elementArray[i].getAttribute("htmlFor") ||
         elementArray[i].getAttribute("for"))
     {
       if (elementArray[i].htmlFor == attributeValue)
       {
         matchedArray[matchedArray.length] = elementArray[i];
       }
     }
   }
   else if (elementArray[i].getAttribute(attribute) ==
       attributeValue)
   {
     matchedArray[matchedArray.length] = elementArray[i];
   }
 }
 return matchedArray;
}
function getElementsByAttribute(attribute, attributeValue, elm)
{
 var elementArray = new Array();
 var matchedArray = new Array();
 if (document.all)
 {
   elementArray = document.all;
 }
 else
 {
   elementArray = elm.getElementsByTagName("*");
 }
 for (var i = 0; i < elementArray.length; i++)
 {
   if (attribute == "class")
   {
     var pattern = new RegExp("(^| )" +
         attributeValue + "( |$)");
     if (pattern.test(elementArray[i].className))
     {
       matchedArray[matchedArray.length] = elementArray[i];
     }
   }
   else if (attribute == "for")
   {
     if (elementArray[i].getAttribute("htmlFor") ||
         elementArray[i].getAttribute("for"))
     {
       if (elementArray[i].htmlFor == attributeValue)
       {
         matchedArray[matchedArray.length] = elementArray[i];
       }
     }
   }
   else if (elementArray[i].getAttribute(attribute) ==
       attributeValue)
   {
     matchedArray[matchedArray.length] = elementArray[i];
   }
 }
 return matchedArray;
}

function getScrollingPosition()
{
 var position = [0, 0];
 if (typeof window.pageYOffset != 'undefined')
 {
  position = [window.pageXOffset, window.pageYOffset];
 }
 else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0)
 {
  position = [document.documentElement.scrollLeft, document.documentElement.scrollTop];
 }
 else if (typeof document.body.scrollTop != 'undefined')
 {
  position = [document.body.scrollLeft, document.body.scrollTop];
 }
 return position;
}
function getElementStyle(elemID, IEStyleProp, CSSStyleProp) {
    var elem = document.getElementById(elemID);
    if (elem.currentStyle) {
        return elem.currentStyle[IEStyleProp];
    } else if (window.getComputedStyle) {
        var compStyle = window.getComputedStyle(elem, "");
        return compStyle.getPropertyValue(CSSStyleProp);
    }
    return "";
}
function d2h(d) {return d.toString(16);}
function h2d(h) {return parseInt(h,16);}

function getViewPortSize()
{
 var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 } 
 var dim = new Array(2);
 dim[0]=viewportwidth;
 dim[1]=viewportheight;
 return dim;
 
}
function scrolltop(){
    if(stop_scroll ==true){
        scroll(scrollToPos[0],scrollToPos[1]) ;
    }
}




function replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;
    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;
    var newstr = string.substring(0,i) + by;
    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);
    return newstr;
}

function chkFrmOKTech()
{
if (chkFrmTech())
{
    document.getElementById("registration").submit();
}
}
function chkFrmOKNonTech()
{
var sendForm = false;
if (chkFrmNonTech())
{
sendForm = true;
}
return sendForm;

}
function chkFrmOKNonTech2()
{
if (chkFrmNonTech2())
{
    document.getElementById("registration").submit();
}
}
function showErr(str)
{
 var objId = "err_" + str ;
 var errObj = document.getElementById(objId);
 errObj.style.display="";  
}
function chkOne(colId)
{
 hideAllErr();
 if (document.getElementById(colId).value=="")
 {
  showErr(colId);
  return false;
 }else{
  hideErr(colId);
}
}
function chkOneEmail(colId)
{
 if (!isEmail(document.getElementById(colId).value))
 {
  showErr(colId);
  return false;
 }else{
  hideErr(colId);
}
}
function hideAllErr()
{    
 var errObj = document.getElementsByName("error_msg");

 //alert(errObj.length);
 for(var i=0;i<errObj.length;i++)
 {
  errObj[i].style.display="none";  
 }
}

function hideErr(str)
{
 var objId = "err_" + str ;
 var errObj = document.getElementById(objId);
 errObj.style.display="none";  
}

function chkFrmNonTech()
{
    var fieldsOK = true;

    /*Hide errors*/    
    hideErr("first_name");
    hideErr("last_name");
    hideErr("email");
    hideErr("subject");
    hideErr("comment");

   
    if (document.getElementById("comment").value=="")
    {
      showErr("comment");
      document.getElementById("comment").focus();
      fieldsOK = false;
    }
    if (document.getElementById("subject").value=="")
    {
      showErr("subject");
      document.getElementById("subject").focus();
      fieldsOK = false;
    }
    if (!isEmail(document.getElementById("email").value))
    {
      showErr("email");
      document.getElementById("email").focus();
      fieldsOK = false;
    }
    if (document.getElementById("last_name").value=="")
    {
      showErr("last_name");
      document.getElementById("last_name").focus();
      fieldsOK = false;
    }
    if (document.getElementById("first_name").value=="")
    {
      showErr("first_name");
      document.getElementById("first_name").focus();
      fieldsOK = false;
    }
    return fieldsOK;
}

function isEmail(str) 
{ 
 var email = str; 
 var pattern = /^([a-zA-Z0-9_\.-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 
 flag = pattern.test(email); 
 if(flag) 
     return true; 
 else 
     return false; 
}
function isDate(str)
{ 
 var reg = /^(\d+)-(\d{1,2})-(\d{1,2})$/; 
 var r = str.match(reg); 
 if(r==null)return false; 
 r[2]=r[2]-1; 
 var d= new Date(r[1], r[2],r[3]); 
 if(d.getFullYear()!=r[1])return false; 
 if(d.getMonth()!=r[2])return false; 
 if(d.getDate()!=r[3])return false; 
 return true;
} 
function isMobile(str)
{
 var sMobile = str; 
 var pattern = /^(13)(\d{9})$/; 
 flag = pattern.test(sMobile); 
 if(flag) 
     return true; 
 else 
     return false; 
}






// 3dviewpopup
function threeDviewpopup(model,width,height,prefix)
{
   createThreeDviewpopup(model,width,height,prefix);
   return false;
}
function closeThreeDview()
{
 $('ajaxcontainer').innerHTML="";
}
function createThreeDviewpopup(model,width,height,prefix)
{
    var elm = document.createElement("div");
    elm.id="fader"; var stijl=elm.style;
    stijl.position="absolute"; stijl.display="block";
    stijl.left="0px";stijl.top="0px";
    stijl.filter = "alpha(opacity=70)"; stijl.opacity = "0.7";stijl.MozOpacity = "0.7"; stijl.KhtmlOpacity = "0.7";
    stijl.backgroundColor="#000";
    stijl.width=document.body.parentNode.scrollWidth+"px";
    stijl.height=document.body.parentNode.scrollHeight+"px";
    $('ajaxcontainer').appendChild(elm);
 attachEventListener($('fader'), "click", closeThreeDview, false);
    elm = document.createElement("div");
    elm.id="threeDviewpopupBox"; stijl=elm.style;
    stijl.position="absolute"; stijl.display="block";
 stijl.left="0px"; stijl.top="0px";
 
 var dim = getViewPortSize();
 stijl.left=(dim[0]-width)/2 + "px";
 stijl.top=getScrollingPosition()[1]+(dim[1]-height)/2 + "px";
    stijl.width=width+"px";
    stijl.height=height+"px";
    $('ajaxcontainer').appendChild(elm);
    $('threeDviewpopupBox').innerHTML=getPopUpSource(model,width,height,'applet',prefix);

    elm = document.createElement("div");
    elm.id="threeDviewCloseButton"; stijl=elm.style;
    stijl.position="absolute"; stijl.display="block";stijl.cursor="pointer";stijl.padding="5px";
 stijl.left="0px"; stijl.top="0px";
    elm.innerHTML="close";
    $('ajaxcontainer').appendChild(elm);
    var bleh = getWidth(elm);
    dim = getViewPortSize();
 stijl.left=((dim[0]-width)/2)+width - bleh[0] + "px";
 stijl.top=getScrollingPosition()[1]+(dim[1]-height)/2 - bleh[1]+1 + "px";
    stijl.backgroundColor="#fff";
    attachEventListener($('threeDviewCloseButton'), "click", closeThreeDview, false);
}
function getPopUpSource(model,width,height,type,prefix)
{
    var source="";
    if(type=="applet")
    {
        source= '<applet height="'+height+'" width="'+width+'" mayscript="" codebase="." code="com.wirefusion.player.AppletPlayer" name="'+model+'"><param value="Created by http://www.web3d.co.uk" name="info"/><param value="/3D_models/'+prefix+model+'/'+model+'/loadgfx.jar,/3D_models/'+prefix+model+'/wf-player/startup8.jar,/3D_models/'+prefix+model+'/wf-player/core8.jar,/3D_models/'+prefix+model+'/wf-player/3D_Scene-5.04.jar,/3D_models/'+prefix+model+'/'+model+'/classes.jar" name="archive"/><param value="Registered version" name="license"/><param value="5.0.20.883" name="version"/><param value="/3D_models/'+prefix+model+'/'+model+'/" name="resourcefolder"/><param value="preload.jar" name="preloadfile"/><param value="6021-25" name="regid"/><param value="Other Java presentations are already running. To maximize performance and stability, it is recommended that you close them before proceeding. Would you like to pause this presentation until you have closed them?" name="runalonemessage"/><param value="135420-wfloadbg.gif" name="loadbgimage"/><param value="107270-wfloadbar.gif" name="loadbarimage"/>You need Java(tm) to view this presentation. <a href="http://www.java.com">Download Java</a></applet>'; 
    }
    else
    {
        source='<embed height="'+height+'" width="'+width+'" name="plugin" src="http://eu.mio.com/media/overview/moov-en.swf" type="application/x-shockwave-flash"/>';
    }
 return source;
}
function $(id) { return document.getElementById(id); }


function activateProductFlashMovie()
{
    createFlashpopup();
    return false;
}

function createFlashpopup()
{
    var width=512;
    var height=324;
    var elm = document.createElement("div");
    elm.id="fader"; var stijl=elm.style;
    stijl.position="absolute"; stijl.display="block";
    stijl.left="0px";stijl.top="0px";
    stijl.filter = "alpha(opacity=70)"; stijl.opacity = "0.7";stijl.MozOpacity = "0.7"; stijl.KhtmlOpacity = "0.7";
    stijl.backgroundColor="#000";
    stijl.width=document.body.parentNode.scrollWidth+"px";
    stijl.height=document.body.parentNode.scrollHeight+"px";
    $('ajaxcontainer').appendChild(elm);
 attachEventListener($('fader'), "click", closeThreeDview, false);
    elm = document.createElement("div");
    elm.id="threeDviewpopupBox"; stijl=elm.style;
    stijl.position="absolute"; stijl.display="block";
 stijl.left="0px"; stijl.top="0px";
 
 var dim = getViewPortSize();
 stijl.left=(dim[0]-width)/2 + "px";
 stijl.top=getScrollingPosition()[1]+(dim[1]-height)/2 + "px";
    stijl.width=width+"px";
    stijl.height=height+"px";
    stijl.backgroundColor="#fff";
    $('ajaxcontainer').appendChild(elm);
    $('threeDviewpopupBox').innerHTML=getPopUpSource("all",width,height,'flash');

    elm = document.createElement("div");
    elm.id="threeDviewCloseButton"; stijl=elm.style;
    stijl.position="absolute"; stijl.display="block";stijl.cursor="pointer";stijl.padding="5px";
 stijl.left="0px"; stijl.top="0px";
    elm.innerHTML="close";
    $('ajaxcontainer').appendChild(elm);
    var bleh = getWidth(elm);
    dim = getViewPortSize();
 stijl.left=((dim[0]-width)/2)+width - bleh[0] + "px";
 stijl.top=getScrollingPosition()[1]+(dim[1]-height)/2 - bleh[1]+1 + "px";
    stijl.backgroundColor="#fff";
    attachEventListener($('threeDviewCloseButton'), "click", closeThreeDview, false);   

}














//optional accessories
    function httpR()
    {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
          // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
 else
 {
  return http_request;
 }
    }

 function loadOptionalAccessories()
 {
  url="htt"+"p://"+location.host+"/inc/optionalAccessories.php";
  http_request=httpR();
  var dev=devicename.replace(/ Series/,"");
  if(dev.indexOf("Moov")==-1) dev="Mio "+dev;
  if(dev=="Mio C510E")dev="Mio C510";
  var parameters="device="+dev;
  http_request.onreadystatechange = loadOptionalAccessoriesHandler;
  http_request.open('POST', url, true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);
 }

function loadOptionalAccessoriesOld()
 {
  url="htt"+"p://"+location.host+"/inc/optionalAccessoriesOld.php";
  http_request=httpR();
  var dev=devicename.replace(/ Series/,"");
  if(dev.indexOf("Moov")==-1) dev="Mio "+dev;
  if(dev=="Mio C510E")dev="Mio C510";
  var parameters="device="+dev;
  http_request.onreadystatechange = loadOptionalAccessoriesHandler;
  http_request.open('POST', url, true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);
 }

 
 function loadOptionalAccessoriesHandler()
 {
  if (http_request.readyState == 4)
  {
           if (http_request.status == 200)
   {
              result = http_request.responseText;
                    if(result!="")
                    {
                        $('popularAcs').innerHTML = $('popularAcs').innerHTML + result;
                    }
         }

  } 
 }
 
 

function replaceProdName(elId, prodName){
    while(document.getElementById(elId).innerHTML.indexOf("***")!= -1){
        var medDescript = document.getElementById(elId).innerHTML;
        medDescript = medDescript.replace("***",prodName);
        document.getElementById(elId).innerHTML = medDescript;
    }
}


$(document).ready(function(){
	$(".productTextReadMore").hide();		
	$('.read-more').click(function() {
		$(".productTextReadMore").toggle(300);
		return false;
	});						
});