function previewanddisplaycode()
{
    var fc=document.getElementById("inputframecolor").value.toLowerCase();
    var tac=document.getElementById("inputtextareacolor").value.toLowerCase();
    var tc=document.getElementById("inputtextcolor").value.toLowerCase();
    var fatc=document.getElementById("inputtextcolorinframe").value.toLowerCase();
    var lng=document.getElementById("inputlanguage").value;
    var timeint=document.getElementById("inputseconds").value;
    var wid=document.getElementById("inputwidth").value;
    var stb=document.getElementById("TopBar").value;
    var sbb=document.getElementById("BottomBar").value;
    var ski=document.getElementById("KuralInfo").value;
    var skt=document.getElementById("KuralTamil").value;
  
    var strPattern = /^[0-9 a-f]{6}$/i  ; 
   if(timeint<5)
   {
      timeint=5;
      document.getElementById("inputseconds").value=5;
   }
   if(timeint>300)
   {
      timeint=300;
      document.getElementById("inputseconds").value=300;
   }
   
      if(strPattern.test(fc) && strPattern.test(tac) && strPattern.test(tc) && strPattern.test(fatc))
     {
      document.getElementById("yourcode").value="<div id=\"thirukuraldiv\"><script type=\"text/javascript\" src=\"http://e-infotainment.com/applications/thirukural-widget/v1/js/kuralform.js?fc="+fc+"&tac="+tac+"&tc="+tc+"&fatc="+fatc+"&lng="+lng+"&timeint="+timeint+"&wid="+wid+"&stb="+stb+"&sbb="+sbb+"&skt="+skt+"&ski="+ski+"\"><\/script><noscript>Your browser does not have javascript enabled. To get the code for displaying thirukural in your webpage, go <a href=\"http://e-infotainment.com/applications/thirukural-widget\">here<\/a><\/noscript><script type=\"text/javascript\" src=\"http://e-infotainment.com/applications/thirukural-widget/v1/js/kuralscript.js\" ><\/script><\/div>";
      document.getElementById("kural_tarea").style.background="#"+tac;
      document.getElementById("kural_tarea").style.color="#"+tc;
     document.getElementById("kural_tarea").style.borderColor="#"+tac;
      document.getElementById("kural_allinputs").style.color="#"+fatc;
     document.getElementById("kural_thirukural").style.background="#"+fc;
     document.getElementById("kural_allinputs").style.background="#"+fc;
     document.getElementById("kural_linktome").style.color="#"+fatc;

     document.getElementById("kural_secsfield").value=timeint;
     document.getElementById("kural_thirukural").style.width=wid;
     document.getElementById("kural_lan").options[0].value="default";
     document.getElementById("kural_lan").options[0].text=lng;
     if(wid=="400px")
     {
             document.getElementById("kural_tarea").style.fontSize="12px";
             document.getElementById("kural_thirukural").style.fontSize="15px";
     }
     if(wid=="460px")
    {
             document.getElementById("kural_tarea").style.fontSize="13px";
             document.getElementById("kural_thirukural").style.fontSize="16px";
     }
     if(wid=="560px")    
    {
             document.getElementById("kural_tarea").style.fontSize="14px";
             document.getElementById("kural_thirukural").style.fontSize="17px";
      }
     if(stb=="yes")
             document.getElementById("kural_allinputs").style.display="block";
     else
             document.getElementById("kural_allinputs").style.display="none";
     if(ski=="yes")
             document.getElementById("kural_info").value="Hide Info";
     else
             document.getElementById("kural_info").value="Show Info";
     if(sbb=="yes")
             document.getElementById("kural_linkandnext").style.display="block";
     else
             document.getElementById("kural_linkandnext").style.display="none";
               
    }
     else
      document.getElementById("yourcode").value="You have entered an invalid Hex color code";
}
