function show_contacts(type, start, middle, end)
{
	if(type == 'm')
	{
		window.document.write('<a href="mailto:'+start+'@'+middle+'.'+end+'" >'+start+'@'+middle+'.'+end+'</a>');
	}
	else if (type == 'c')
	{
		window.document.write('<a href="callto:+'+start+middle+'" >+'+start+' '+middle+'</a>');
	}
}


function show_page_head(is_first_page, show_only_menu)
{
	document.write('<div class="main_menu" >');
	document.write('<a href="index.html">Sākumlapa</a> | ');
    document.write('<a href="about.html">Par Guru</a> | ');
    document.write('<a href="galleries.html">Galerijas</a> | ');
    document.write('<a href="videos.html">Video</a> | ');
    document.write('<a href="links.html">Noderīgas saites</a> | ');
    document.write('<a href="http://www.dharmanathi.ru/content/blogcategory/7/30/lang,ru/" target="_blank">Guru Parampara</a> |&nbsp;');
    document.write('<a href="private_tuition.html" >Nodarbības</a> |&nbsp;');
    document.write('<a href="satsangi.html" >Satsangi</a> |&nbsp;');
	document.write('<a href="mandir.html" >Mandir</a> |&nbsp;');
    play_background_music();
    document.write('</div>');

    if(show_only_menu != true)
    {
        document.write('<div class="head_box" >');

        if(is_first_page==true)
        {
    	    document.write('<img onclick="window.location.href=\'index.html\';" src="img/fp_top.jpg" class="guru_img" />');
    	    document.write('<p class="big_head_title" style="margin-bottom: 20px;" >Om Shiva Goraksha Yogi Jay !</p>');
    	    document.write('<img onclick="window.location.href=\'index.html\';" src="img/guru_jogi.jpg" class="guru_img" />');
    	    document.write('<p class="big_head_title">Jay Guru Matsjendranath Maharaj Jay !</p>');
    	    document.write('<p class="small_head_title">Šī ir Guru Latvijas skolnieku mājas lapa</p>');
	    }
	    else
	    {
    	    document.write('<img onclick="window.location.href=\'index.html\';" src="img/guru_jogi.jpg" class="guru_img" />');
    	    document.write('<p class="big_head_title">Guru Yogi Matsyendranatha Maharadža</p>');
    	    document.write('<p class="small_head_title">Latvijas skolnieku mājas lapa</p>');
	    }

        document.write('<!-- <p class="small_head_title">(Guru Nathu Tradīcijā)</p> -->');
        document.write('</div>');
    }
}

function play_background_music()
{
	document.write('<object height="15" width="15" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" hspace="0" vspace="0" border="0">');
	document.write('<param value="/music/mp3_player.swf" name="movie">');
	document.write('<param value="high" name="quality">');
	document.write('<param value="allowscriptaccess" name="always">');
	document.write('<param value="false" name="menu">');
	document.write('<param value="transparent" name="wmode">');
	document.write('<param value="song_name=Jai_Goraksha.mp3&amp;song_volume=0.05" name="flashvars">');
	document.write('<embed src="/music/mp3_player.swf" quality="high" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" height="15" width="15" wmode="transparent" allowscriptaccess="always" play="true" menu="false" flashvars="song_name=Jai_Goraksha.mp3&amp;song_volume=0.05" />');
	document.write('</object>');
}

function mp3_player_mute(cmd)
{
	var cokie_name = 'background_music';

	if(cmd==0)
	{
		// paly background music
		eraseCookie(cokie_name);
	}
	else if (cmd==1)
	{
		// background music mute
		createCookie(cokie_name,1,7);
	}
	else if (cmd==2)
	{
		// detect wether play or not
		return readCookie(cokie_name);
	}
}

function close_ad()
{
    var cookie_name = 'first_page_ad';

    createCookie(cookie_name, 1, 1);
    if(document.getElementById('first_page_ad') != null)
    {
        document.getElementById('first_page_ad').style.display = 'none';
    }
}

function show_ad()
{
    var cookie_name = 'first_page_ad';

    // show only once each day
    if(readCookie(cookie_name) != 1)
    {
        document.write('<div id="first_page_ad" style="position: absolute; top: 100px; text-align: center;" ><div style="margin-left: auto; margin-right: auto; width: 300px; height: 190px; padding: 10px; border: 2px solid #000; background-color: #fff; color: #000; line-height: 1.4em; " ><div style="height: 10px; text-align: right; color: #000; margin-bottom: 10px;"><a href="javascript: close_ad();" style="color: #000; font-weight: bold;" >[X]</a></div><div onclick="window.location.href=\'/private_tuition.html\';" style="cursor: pointer;"><b>KLASISKĀ HATHA YOGA</b><br />pieredzējusi praktizējoša skolotāja<br />PRIVĀTĀS NODARBĪBAS<br />vai nelielās grupās<br />jebkuram līmenim<br />bērniem<br />klusajā centrā Rīgā</div></div></div>');
    }
}

function createCookie(name,value,days)
{
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return true; //return c.substring(nameEQ.length,c.length);
	}
	return false;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

