function v_button()
{
 if (document.getElementById("some1").selectedIndex == 0)
    {
     window.open('quisoft_yw.php');
    } 
 if (document.getElementById("some1").selectedIndex == 1)
    {
     window.open('quisoft_jobs.htm');
    } 
 if (document.getElementById("some1").selectedIndex == 2)
    {
     window.open('bings.php?q=pentomino+puzzles&index=0&sa=Search&offsetn=0');
    } 
 if (document.getElementById("some1").selectedIndex == 3)
    {
window.open('quisoft_weather.php?cx=010130974254056933469%3Agmxdqpdwxv0&cof=FORID%3A9&ie=UTF-8&q= &qc=&radio1=0&radio3=0&ddown1=0&ddown3=0&text1=&tc=&radio5=0&fc=0&zip2=&zipind=0&idnumb=0&siteurl =www.pentomino-puzzles.com%2Fquisoft%2Findex.html');
    } 
} 


function home_start()
{
 menu_numb=2;
 d_index=0;
 file_name4="home/home1_"; ext1=".jpg";
 f_set(); sc_change();
}


function dnumb2(d_stats1,d_stats2,d_stats3,d_stats4)
{ 
 var d_stat;
 var d_lenght;
 var d_pos;
 var d_pos1;
 var d_pos2;
 var d_images=document.getElementById("images").value;

 if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();   
  } 
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
  }
 
  xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
       { 
        d_stat=xmlhttp.responseText; 
        d_length=d_stat.length;
        d_pos=d_stat.indexOf(".");        
        document.getElementById("tsolve1").innerHTML=d_stat.substr(0,d_pos);
        d_pos1=d_stat.indexOf(".",d_pos+1);        
        d_pos2=d_stat.substr(d_pos+1,d_pos1-d_pos-1);

//        if (d_pos1 > 9) document.getElementById("solve1").style.left=145-5+'px';
//        if (d_pos1 > 99) document.getElementById("solve1").style.left=145-10+'px';
//        if (d_pos1 > 999) document.getElementById("solve1").style.left=145-15+'px';
//        if (d_pos1 > 9999) document.getElementById("solve1").style.left=145-20+'px';
//        if (d_pos1 > 99999) document.getElementById("solve1").style.left=145-25+'px';
//        if (d_pos1 > 999999) document.getElementById("solve1").style.left=145-30+'px';
        document.getElementById("solve1").innerHTML=d_pos2;

        if (url_copy2 == 0)
           {
            d_images=d_stat.substr(d_pos1+1,d_length-d_pos1-1); 
            document.getElementById("images").value=d_images;
            document.getElementById("image_place").src=d_images;
            document.getElementById("image_avail").style.visibility="hidden";
            url_copy=d_images;  
            url_copy2=1;
           }
       }
  }
        xmlhttp.open("GET","dnumbers.php?d_stats1="+d_stats1+"&"+"d_stats2="+d_stats2+"&"+
       "d_stats3="+d_stats3+"&"+"d_stats4="+d_stats4+"&"+"d_images="+d_images,true);
        xmlhttp.send();  
}



function d_add()
{  
 var d_stat;
 var d_lenght;
 var d_pos;
 var d_pos1;

 var d_stats1=document.getElementById("stats1").innerHTML;
 var d_stats2=document.getElementById("stats2").innerHTML;
 var d_stats3=document.getElementById("stats3").innerHTML;
 var d_stats4=document.getElementById("stats4").innerHTML; 

 if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();   
  } 
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
  }
 
  xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
       {   
        d_stat=xmlhttp.responseText; 
        d_length=d_stat.length;
        d_pos=d_stat.indexOf(".");        
        document.getElementById("tsolve1").innerHTML=d_stat.substr(0,d_pos);
        
        d_pos1=d_stat.substr(d_pos+1,d_length-d_pos-1); 
//        if (d_pos1 > 9) document.getElementById("solve1").style.left=145-5+'px';
//        if (d_pos1 > 99) document.getElementById("solve1").style.left=145-10+'px';
//        if (d_pos1 > 999) document.getElementById("solve1").style.left=145-15+'px';
//        if (d_pos1 > 9999) document.getElementById("solve1").style.left=145-20+'px';
//        if (d_pos1 > 99999) document.getElementById("solve1").style.left=145-25+'px';
//        if (d_pos1 > 999999) document.getElementById("solve1").style.left=145-30+'px';
        document.getElementById("solve1").innerHTML=d_pos1;
       }
  } 
   xmlhttp.open("GET","add_stat.php?d_stats1="+d_stats1+"&"+"d_stats2="+d_stats2+"&"+
   "d_stats3="+d_stats3+"&"+"d_stats4="+d_stats4,true);
   xmlhttp.send();
}


function d_stats()
{
 dnumb2(document.getElementById("stats1").innerHTML,
        document.getElementById("stats2").innerHTML,
        document.getElementById("stats3").innerHTML,
        document.getElementById("stats4").innerHTML
       );
}


function game2()
{ 
 var ij=0;
 var numb1,numb2;
 var test;
 var dx,dy;
 var dd,sl,sk; 
 var d1=new Array(0,0,0,0,0,0,0,0,0,0,0,0);
 var d2=new Array(0,1,2,3,4,5,6,7,8,9,10,11);
 var d3=new Array(0,1,2,3,4,5,6,7,8,9,10,11);
 var de=0;
 var df;

if (ch_index == 0)
{
 menu_numb=1; solitaire=0;  
 f_set(); start2(); d_index=1; sc_change(); 
 document.getElementById("home_start1").style.visibility="hidden"; 
 document.getElementById("hint1").style.visibility="visible";
 
 for (sl=1; sl < 17; ++sl)
     { 
      test=document.getElementById(fig[sl]); test.style.cursor='move'; 
     } 

      for (sl=0; sl < 8; ++sl)
          {
      for (sk=0; sk < 8; ++sk)
          {
           test=document.getElementById(div_t[ij+1].id);  
           test.style.visibility="hidden";
           test.style.left=471+sk*34+'px'; 
           test.style.top=151+sl*34+'px'; 
           ++ij;
          }             
          }

 for (sl=1; sl <= d_numb; ++sl)
{
 numb1=Math.round(Math.random()*(12-de));
 if (numb1 == 12-de) numb1=11-de;
 numb2=numb1;
 d_copy1[sl-1]=d2[numb2]; 

 numb1=Math.round(Math.random()*5);
 if (numb1 == 5) numb1=4; 
     test=document.getElementById(fig_array[d2[numb2]*5+numb1]); 
     test.style.background="url('transparent.png')"; 

     dd=parseInt(schemas[d2[numb2]*5+numb1],10);   
     d_copy[sl-1]=dd;
 
     test=document.getElementById(div_t[dd].id);  
     test.style.background="url('fig13.png')";      
     test.style.visibility="visible"; 

     ++de;     
     d1[d2[numb2]]=1; 

     df=0;
     for (sk=0; sk < 12; ++sk)
         { 
          if (d1[sk] == 0) { d2[df]=d3[sk]; ++df; }
         }
}
}
else
    {
     for (sl=0; sl < 12; ++sl)
         { 
          document.getElementById(div_numb[sl].id).style.border="";
         }  
          trash_index=0;
          document.getElementById("trash1").style.border="";
          document.getElementById(div_numb[d_numb-1].id).style.border="1px solid red";
    }
}


function start_sc()
{
 var start1=0; 
 var ij=0;
 var aj;
 var cj="";
 var t;
 
 var file_number;
 var numb1=Math.round(Math.random()*29);
     if (numb1 == 0) numb1=1;
     if (numb1 == 29) numb1=28;
     file_number="schema"+numb1+".txt";

 if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest(); 
  } 
else
  {
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  } 
  xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
      {          
        document.getElementById("schemas1").innerHTML=xmlhttp.responseText;                       
        var datas=document.getElementById("schemas1").innerHTML;        

        for (ij=0; ij < datas.length; ++ij)  
            {     
             t=datas.charAt(ij);
             if (t == "0" || t == "1" || t == "2" || t == "3" || t == "4" || t == "5" 
                                      || t == "6" || t == "7" || t == "8" || t == "9"
                ) 
                 cj=cj+datas.charAt(ij);      
            }
        for (ij=0; ij < 64; ++ij) 
            { 
             schemas[ij]=cj.slice(start1,start1+3);
             start1=start1+3;      
            }         
      }
  }
   xmlhttp.open("GET",file_number,true);
   xmlhttp.send();  
}


function game2a() 
{
 var test;
 var ij=0;

 for (ij=0; ij < d_numb; ++ij)
     { 
      test=document.getElementById(div_t[d_copy[ij]].id);  
      test.style.background="url("+start_2[d_copy1[ij]]+")"; 
     }
}

function game2b() 
{
 var test;
 var ij=0;

 for (ij=0; ij < d_numb; ++ij)
     {
      test=document.getElementById(div_t[d_copy[ij]].id); 
      test.style.background="url('fig16.png')"; 
     }
}

function ch_game2()
{
 var ij=0;
 var test;
 var sl,sk;

  if (ch_index == 0)
     {  
      start2(); 
      quisoft_image();
      for (ij=0; ij < 12; ++ij)
          { 
           test=document.getElementById(div_numb[ij].id);  
           test.style.background="url("+start_2[ij]+")"; 
          }
      change_frag();
      solitaire=0; menu_numb=1;
 
      ch_index=1; 
      ij=0;
      document.getElementById("hint1").style.visibility="hidden";
      document.getElementById("trash1").style.border="";
      trash_index=0;
      document.getElementById("shuffle2").style.visibility="visible";
      document.getElementById("trash1").style.visibility="visible";
      document.getElementById("fig57").style.visibility="visible";
      document.getElementById("fig57").style.zIndex=1002;
      layer1.style.visibility="visible";
 
      ij=0;
      for (sl=0; sl < 8; ++sl)
          {
      for (sk=0; sk < 8; ++sk)
          {
           test=document.getElementById(div_t[ij+1].id);  
           test.style.background="url('shadow1.jpg')"; 

           test.style.left=471+sk*34+'px'; 
           truck_t[ij]=682-(471+sk*34);
           test.style.top=151+sl*34+'px';  
           test.style.zIndex=2001;
           test.style.visibility="visible";
           test.style.cursor="pointer";  
           ++ij; 
          } 
          }  
           document.getElementById(div_numb[d_numb-1].id).style.border="1px solid red";   
           document.getElementById("home_start1").style.visibility="hidden";      
           document.getElementById("fig17").style.visibility="hidden"; 
           document.getElementById("grid").style.background="url('grid.jpg')";
     } 
     else 
         {
          for (ij=0; ij < 12; ++ij)
              { 
               test=document.getElementById(div_numb[ij].id);  
               test.style.background="url("+div_numbf[ij]+")";
              }
           if (hl_index == 0)        
              { 
               menu_numb=1; solitaire=0;  
               f_set(); start2(); d_index=1; sc_change(); 
              }
          ch_index=0; hl_index=0;
          document.getElementById(div_numb[d_numb-1].id).style.border=""; 
          document.getElementById("trash1").style.visibility="hidden";
          document.getElementById("shuffle2").style.visibility="hidden";
          document.getElementById("fig57").style.visibility="hidden";
          document.getElementById("fig57").style.left=682+'px';    
          layer1.style.visibility="hidden";
          layer1.style.top=150+"px";
          layer1.style.left=470+"px";

          a[57]=682; a3[57]=0;

          for (ij=0; ij < 64; ++ij)
              {
               test=document.getElementById(div_t[ij+1].id); 
               test.style.visibility="hidden";
               test.style.zIndex=1;
               test.style.background="url('fig16.png')"; 
              }
          ij=0;
          for (sl=0; sl < 8; ++sl)
              {
          for (sk=0; sk < 8; ++sk)
              {
               test=document.getElementById(div_t[ij+1].id);  
               test.style.left=471+sk*34+'px'; 
               test.style.top=151+sl*34+'px';  
               test.style.cursor="default";
               ++ij; 
              } 
              }
         }
}


function change_back(id_number)
{
 var test;

if (ch_index == 1)
{
 test=document.getElementById(div_t[id_number].id);  
 if (trash_index == 1) test.style.background="url('shadow1.jpg')";
 else                     
     test.style.background="url("+start_2[d_numb-1]+")"; 
}
}


function trash2()
{
 trash_index=1; 
 document.getElementById("trash1").style.border="1px solid red";
 document.getElementById(div_numb[d_numb-1].id).style.border="";
}


function hide1()
{
 var ij=0;
 var test;

 for (ij=1; ij <= 64; ++ij)
     {
      test=document.getElementById(div_t[ij].id);  
      test.style.visibility="hidden";
     }
}


function hide_s()
{
 var ij=0;
 var test;

 for (ij=1; ij <= 64; ++ij)
     {
      test=document.getElementById(div_t[ij].id);  
      test.style.visibility="visible";
     }
}


function shuff1()
{
 var ij;
 var tb;
 var test;

 document.getElementById("shuffle2").style.visibility="visible";
 for (ij=0; ij < 64; ++ij)
     { 
      test=document.getElementById(fig_array[ij]); 
      tb=document.getElementById(div_t[parseInt(schemas[ij],10)].id);  
      test.style.background=tb.style.background; 
     }
}


function hide_l()
{
 var ij;

 ch_index=1;
 hl_index=1;
 ch_game2();
}


function dnumb_init()
{ 
 var numb1,numb2,numb3,numb4;

     numb2=16+Math.round(Math.random()*112);
     move_f1(2,numb2);
     numb3=16+Math.round(Math.random()*112);
     move_f1(3,numb3);   
     numb4=16+Math.round(Math.random()*112);
     move_f1(4,numb4);
     numb1=16+Math.round(Math.random()*112);
     move_f1(1,numb1);
 
     dnumb2(numb1,numb2,numb3,numb4);
}


function move_f1(favind_copy,numb_copy)
{ 
 var qi='q'+favind_copy; 
 var si='stats'+favind_copy; 

 a[56]=280+numb_copy-16;

 if (numb_copy > 99) 
    {
      if (favind_copy == 1 || favind_copy == 3) document.getElementById(qi).style.left=2+'px';
      if (favind_copy == 2 || favind_copy == 4) document.getElementById(qi).style.left=36+'px';
    }
 else 
    {
     if (favind_copy == 1 || favind_copy == 3) document.getElementById(qi).style.left=7+'px';
     if (favind_copy == 2 || favind_copy == 4) document.getElementById(qi).style.left=41+'px';
    }
     document.getElementById(qi).innerHTML=numb_copy;  
     document.getElementById(si).innerHTML=numb_copy;  
     fnumb[favind_copy]=numb_copy;  	  
     document.getElementById(fig[56]).style.left=a[56]+'px'; 
     af[favind_copy]=a[56];
}


function hint_n1()
{
 var t_show,ij; 
 var top_show,left_show;
 var str1=navigator.userAgent;

 for (ij=1; ij <= 16; ++ij)
     {
      document.getElementById(fig[ij]).style.visibility="hidden";
     }
 for (ij=0; ij < 64; ++ij)
     {
      t_show=parseFloat(schemas[ij]);
      top_show=150+34*(Math.ceil(t_show/8)-1);     
      left_show=470+34*(t_show-((Math.ceil(t_show/8)-1)*8+1));
      document.getElementById(div_t[ij+1].id).style.top=top_show+'px'; 
      document.getElementById(div_t[ij+1].id).style.left=left_show+'px'; 
      document.getElementById(div_t[ij+1].id).style.visibility="visible";
     }
      if (str1.search("Chrome") == -1)
         {
          document.getElementById("gg_description").style.visibility="visible"; 
          document.getElementById("qsmiley").style.visibility="hidden";
          document.getElementById("qsmiley_down").style.visibility="visible";
         } 
}


function hint_n2()
{
 var t_show,ij; 
 var top_show,left_show;
 var str1=navigator.userAgent;

 for (ij=1; ij <= 16; ++ij)
     {
      document.getElementById(fig[ij]).style.visibility="visible";
     }
 for (ij=0; ij < 64; ++ij)
     {
      document.getElementById(div_t[ij+1].id).style.visibility="hidden";
     }
      if (str1.search("Chrome") == -1)
         {
          document.getElementById("gg_description").style.visibility="hidden"; 
          document.getElementById("qsmiley").style.visibility="visible";
          document.getElementById("qsmiley_down").style.visibility="hidden";
         }
}


function quisoft_image()
{ 
 document.getElementById("quisoft1").style.visibility="hidden";
 document.getElementById("quisoft2").style.visibility="visible"; 
}


function hint_image()
{
 document.getElementById("quisoft1").style.visibility="visible"; 
 document.getElementById("quisoft2").style.visibility="hidden";
}


function solved_mario()
{ 
 if (index_solved == 1) document.getElementById(s_layer1.id).style.visibility="visible";
 else  
{
 s_layer1=document.createElement("img");
 s_layer1.id="s_layer2";
 s_layer1.style.visibility="visible";
 s_layer1.style.position="absolute";
 s_layer1.style.top=170+"px";
 s_layer1.style.left=120+"px";
 s_layer1.src="mario.png"; 
 document.body.appendChild(s_layer1); 
 index_solved=1;
}
}

