var my_sound=1;
var s_arr=new Array("sounds/my_1.mp3","sounds/my_2.mp3","sounds/my_3.mp3","sounds/my_4.mp3","sounds/my_5.mp3");
var im_arr=new Array("images/hangtal_hallgass_5.jpg", "images/hangtal_hallgass_6.jpg", "images/hangtal_hallgass_7.jpg",
                     "images/tinghsa_hallgass_1.jpg" ,"images/tinghsa_hallgass_2.jpg");

var mand_arr=new Array("images/mandala_3.jpg", "images/mandala_3a.jpg",
                       "images/mandala-2.jpg","images/mandala-2a.jpg", "images/mandala_1.jpg",
                       "images/mandala_galeria_1.jpg","images/mandala_galeria_2.jpg","images/mandala_galeria_3.jpg",
                       "images/mandala_galeria_4.jpg","images/mandala_galeria_5.jpg");

var my_mand=1;
var total_sounds=s_arr.length;
var total_mand=mand_arr.length;

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;
}
            
/*Namespaces*/

var Media = document.Media || {};

// funciones para cookies
            
Media.PlaySound = {
  MSIE: navigator.userAgent.indexOf("MSIE"),
  NETS: navigator.userAgent.indexOf("Netscape"),
  OPER: navigator.userAgent.indexOf("Opera"),
  cookieName:  "cookie_sound_active",
  imgOn: "images/k_1.jpg",
  imgOff: "images/k_1.jpg",
  Sound:  s_arr[my_sound-1] ,
  WriteCookie: function( name, value){
                         var expdate=new Date();
                         expdate.setTime(expdate.getTime()+10*365*24*60*60*1000);
                         document.cookie=name+"="+escape(value)+";expires="+expdate.toGMTString();
               },
  ReadCookie: function(name){
                       var namearg=name+"=";
                       var nlen=namearg.length;
                       var clen=document.cookie.length;
                       var i=0;
                       while(i<clen){
                           var j = i+nlen;
                           if(document.cookie.substring(i,j)==namearg){
                              var endpos= document.cookie.indexOf(";",j);
                              if(endpos==-1) endpos=document.cookie.length;
                              return unescape(document.cookie.substring(j,endpos));
                           }
                           i=document.cookie.indexOf(" ",i)+1;
                           if(i==0) break;
                       }
                       return null;
               },
  OnOffSound: function(img ){
                  newValue=Media.PlaySound.ReadCookie(Media.PlaySound.cookieName)==1||
                           Media.PlaySound.ReadCookie(Media.PlaySound.cookieName)==null?0:1;
                 // img.src=newValue==1?Media.PlaySound.imgOn:Media.PlaySound.imgOff;
                 // Media.PlaySound.WriteCookie(Media.PlaySound.cookieName,newValue);
               },
  SetMediaIE: function(){
                  if((Media.PlaySound.MSIE>-1) || (Media.PlaySoundOPER>-1)){
                     document.write('<bgsound loop="0" name="MediaMyMediaObj" id="MediaMyMediaObj" >');
                  }
              },
  PlayNow: function(){
   //           if(Media.PlaySound.ReadCookie(Media.PlaySound.cookieName)==1 || Media.PlaySound.ReadCookie(
    //          Media.PlaySound.cookieName)==null){
                 obj=MM_findObj("MediaMyMedia");
                 if((Media.PlaySound.MSIE>-1) || (Media.PlaySoundOPER>-1)){
                    obj=MM_findObj("MediaMyMediaObj");
                    obj.src=Media.PlaySound.Sound;
                 }else{
                    obj=MM_findObj("MediaMyMediaDiv");
                    obj.innerHTML='<embed src="'+Media.PlaySound.Sound+'"hidden="true" volume="200" loop="0" type="audio/midi">';
                 }
      //        }
            }
}

//alert(Media.PlaySound.MSIE);

function tonext_my(eza){
if (eza=="gal"){
var my_item=my_get('hangtal_place');
var my_index=my_mand-1;
if (my_index+1<total_mand) my_index++;
else my_index=0;
my_mand= my_index+1;
//alert("tonext utan "+my_sound);
 my_item.src=mand_arr[my_mand-1];
//Media.PlaySound.Sound=s_arr[my_sound-1];
//Media.PlaySound.SetMediaIE();
}else{
var my_item=my_get('hangtal_place');
var my_index=my_sound-1;
if (my_index+1<total_sounds) my_index++;
else my_index=0;
my_sound= my_index+1;
//alert("tonext utan "+my_sound);
 my_item.src=im_arr[my_sound-1]; 
 Media.PlaySound.Sound=s_arr[my_sound-1];
 
}
return false;
}

function toprev_my(eza){
if (eza=="gal"){
var my_item=my_get('hangtal_place');
var my_index=my_mand-1;
if (my_index-1>-1) my_index--;
else my_index=total_mand-1;
my_mand= my_index+1;
 my_item.src=mand_arr[my_mand-1];
//Media.PlaySound.Sound=s_arr[my_sound-1];
}else{
var my_item=my_get('hangtal_place');
var my_index=my_sound-1;
if (my_index-1>-1) my_index--;
else my_index=total_sounds-1; 
my_sound= my_index+1;
 my_item.src=im_arr[my_sound-1];
 Media.PlaySound.Sound=s_arr[my_sound-1];
}
return false;
}


function kekit_my(my_item){
var new_str=my_item.src;
my_item.src=new_str.replace("feher","kek");;
}

function feherit_my(my_item){
var new_str=my_item.src;
my_item.src=new_str.replace("kek","feher");;
}

            
Media.PlaySound.SetMediaIE();

//<a href="#"><img src="images/k_1.jpg" onclick="Media.PlaySound.OnOffSound(this)" border="0" /></a>
 //           <br/>
            
 //           <div name="MediaMyMediaDiv" id="MediaMyMediaDiv" style="margin:0; width:0; height:0;"></div>
 //           <input type="button" value="dame" onclick="Media.PlaySound.PlayNow()"/>
