var current_page = "";

function Set_Cookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );

	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}


function go_to_product(prod_id) {
	ajax('products.php?prod_id='+prod_id , 'content', 'true');	
}
function products_open_a(filename, a_id){
	ajax(filename , 'indent');
	$("a[id^=\'prod_a\']").removeClass("active_product");
	$("#prod_a_"+a_id).addClass("active_product");
}
function products_videos() {
	ajax('p_filmy.php' , 'indent');
	$("a[id^=\'prod_a\']").removeClass("active_product");
}

function stristr (haystack, needle, bool) {
    var pos = 0;
 
    haystack += '';
    pos = haystack.toLowerCase().indexOf( (needle+'').toLowerCase() );
    if (pos == -1){
        return false;
    } else{
        if (bool) {
            return haystack.substr( 0, pos );
        } else{
            return haystack.slice( pos );
        }
    }
}

var dest = 0;

function ajax(filename, dest, reload_header) {
	
        if(filename == 'index.php')
            filenma = 'company.php';
        $("#"+dest).load(filename, function(){ initLytebox(); });
        
        //alert("Hash: "+hash+"Filename: "+filename);
		
	var use_actual_header_version = "false";
	if(reload_header == "true") {
		var b=0;
		if(stristr(filename,"company.php")){
			b=1;
		} else if(stristr(filename,"products.php")){
			b=2;
		} else if(stristr(filename,"news.php")){
			b=3;
			use_actual_header_version = "true";
		} else if(stristr(filename,"technology.php")){
			b=4;
		} else if(stristr(filename,"products.php")){
			b=5;
		}
		
		if (use_actual_header_version == "true") {
			ajax('h_' + header_version + '.php?button='+b,'header');
		} else {
			ajax('h_light.php?button='+b,'header');
		}
	}
	window.location.hash = filename;
}

var flash_sound_status = "1";
function flash_sound(set_sound_state){
	flash_sound_status = set_sound_state;
	Set_Cookie('flash_snd', set_sound_state, 1);
}
function flash_sound_off_head() {
	$("#flash_sound").html('&nbsp;')
	ajax('flash_sound.php', 'flash_music', 'false');
}
var to_show;
function showSubcontent(to_show){
	$("td[id^='qnp']").attr('class', 'qn');
	$("div[id^='qn']").hide();
	
	$("#qnp"+to_show).attr('class', 'qn_hover');
	$("#qn"+to_show).show();
}
var max_div=0;
function show_pp(to_show,max_div){
	$("div[id^='pl']").hide();
	$("a[id^='ln']").attr('class', 'l_normal');	
	$("#pl"+to_show).show();
	$("#pl"+to_show).css('display','table-row');
	$("#ln"+to_show).attr('class', 'l_active');
}
function spp(){

	document.getElementById("ln2").style.className = "abc"; 
	
}
var ah_event;
function showAHSubcontent(ah_event){
	$("div[id^='ah']").hide();
	$("#ah"+ah_event).show();
}
function init(){
        ajax('h_normal.php','header');
        ajax('company.php','content');
}

function changeclassname(obj_id) {
	if ($("#"+obj_id).attr('class') == "klasa_off") {
		$("#"+obj_id).attr('class', 'klasa_on');
	} else {
		$("#"+obj_id).attr('class', 'klasa_off');
	}
}


var div_id;
function switch_visibility(div_id){
	$('#'+div_id).slideToggle(300);
}

var cur_div_id
function plist_switch_visibility(div_id){
	$("div[id^='s_g_']").slideUp(300);
	if (div_id != cur_div_id) {
		$('#'+div_id).slideToggle(300);
		cur_div_id = div_id;
	} else {
		cur_div_id = 0;
	}
}

function newsletter_signup(){
	newsletter_form = document.forms["newsletter_form"];
	mail = newsletter_form.elements["news_mail"].value;
	ajax('newsletter.php?a=register&m='+mail,'newsletter_reg');
}

function newsletter_signup_2(){
	newsletter_form = document.forms["newsletter_form"];
	mail = $("#subscribe_mail").val();
	ajax('newsletter.php?a=register&type=2&m='+mail,'newsletter_reg');
}


