/* MM */

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_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];}
}

/* Set class name */

function setClassName(divname,classnamee) {
	
		if(document.getElementById(divname)!= null) {
			
			document.getElementById(divname).className = classnamee;
			
		}
		
}

/* Switch lang */

function jump_to(ctl,idx) {
    if (idx != "0") {
        ppwin = window.open (ctl.options[idx].value, "_self");
        // ppwin.focus();
    }
}

/* Left links js */

function go_ll(p_ll) {
		window.location = 'index.php?p=' + p_ll;
}

function go_lls(p_lls,n_ll) {
		window.location = 'index.php?p=' + p_lls + '&n=' + n_ll;
}

/* Div show/hide */

function shd(shdl) {
    var whichLayer='sendf_form';
    if (document.getElementById) {
        // this is the way the standards work
        var style2 = document.getElementById(whichLayer).style;
        style2.display = style2.display? "":"block";
    } else if (document.all) {
        // this is the way old msie versions work
        var style2 = document.all[whichLayer].style;
        style2.display = style2.display? "":"block";
    } else if (document.layers) {
        // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
        style2.display = style2.display? "":"block";
    }
}

function shdz(shdl) {
    var whichLayer='game_form';
    if (document.getElementById) {
        // this is the way the standards work
        var style2 = document.getElementById(whichLayer).style;
        style2.display = style2.display? "":"block";
    } else if (document.all) {
        // this is the way old msie versions work
        var style2 = document.all[whichLayer].style;
        style2.display = style2.display? "":"block";
    } else if (document.layers) {
        // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
        style2.display = style2.display? "":"block";
    }
}

/* Empty field */

function emptyfield() {
    document.getElementById('email').value = "";
}

/* Sendf ajax */

function sendf() {
  var xmlHttp;

  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        //alert("Your browser does not support AJAX!");
        window.location = "inc/ajax_error.php";
        return false;
        }
      }
    }
    
     xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        
        }
      }

    xmlHttp.open("GET",document.URL + '&mailtoafriend=' + document.getElementById('email').value,true);
    xmlHttp.send(null);
    
    document.getElementById('sendf_form').innerHTML = "Thanks.";
}

/* Navigator ajax */

function navigatorx(ofsm) {
	
  var xmlHttp;
  
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        // alert("Your browser does not support AJAX!");
        window.location = "inc/ajax_error.php";
        return false;
        }
      }
    }
    
    /*
    alert(1);
    if (window.XMLHttpRequest){ //Mozilla, Firefox, Opera 8.01, Safari
         alert(2);
    	xmlHttp = new XMLHttpRequest(); 
    	 alert(3);
	} else if(window.ActiveXObject) { //IE
	    alert(4);
    	xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
    	alert(5);
	} else { //Older Browsers
    	alert("Your Browser does not support Ajax!");
	}
    alert(6);
    */
     
     xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
           document.getElementById('echo1').innerHTML = xmlHttp.responseText;
           // div_height();
        }
      }

    ofsm = decode64(ofsm);
    xmlHttp.open("GET", ofsm + '&ajax' ,true);
    xmlHttp.send(null);
    
}


// decode 64

function decode64(input) {
	
	 var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}


/* Td style height

function div_height() {
    document.getElementById('techo1').height = '600px';
}

*/

/* WOW Clean */

var flg1=0; var flg2=0; var flg3=0;
function clrfld (fld) {
	if (fld==1) {if (flg1==0) {document.getElementById('namez').value=''; flg1=1; document.getElementById('namez').focus();} }
	if (fld==2) {if (flg2==0) {document.getElementById('emailz').value=''; flg2=1; document.getElementById('emailz').focus();} }
	if (fld==3) {if (flg3==0) {document.getElementById('messagez').value=''; flg3=1; document.getElementById('messagez').focus();} }
}

function dopost() {
	if (document.getElementById('namez').value.length < 3) {document.getElementById('namez').focus(); alert ("Please fill all required fields."); return;}
	if (document.getElementById('emailz').value.length < 7) {document.getElementById('emailz').focus(); alert ("Please fill all required fields."); return;}
	if (document.getElementById('messagez').value.length < 2) {document.getElementById('messagez').focus(); alert ("Please fill all required fields."); return;}
	if (flg1 && flg2 && flg3) {
        upb = document.getElementById('upButton');
        upb.value = "Wait ...";
        upb.disabled = true;

	   document.odform.submit()
	} else {alert ("Please fill all required fields.");};
}
