// stores the reference to the XMLHttpRequest object
var xmlHttp = createXmlHttpRequestObject(); 

// retrieves the XMLHttpRequest object
function createXmlHttpRequestObject() 
{	
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // if running Internet Explorer
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try 
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)
 
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}

function newsForm(){
	var nFs = document.forms["newsletterForm"];
	document.getElementById("popup_news_form").style.visibility = "visible";
	document.getElementById("popup_news_form").style.width = "400px";
	document.getElementById("popup_news_form").style.height = "230px";
	document.getElementById("popup_news_form").style.marginTop = "30px";
	document.getElementById("popup_news_form").style.marginLeft = "130px";
	document.getElementById("popup_news_form").style.border = "2px solid #b87600";
	document.getElementById("popup_news_form").style.padding = "10px";
	document.forms["nff"].usr_name.value = nFs["usr_name"].value;
	document.forms["nff"].usr_email.value = nFs["usr_email"].value;
	var str = nFs["usr_email"].value;
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str)){
		}
	else{
		alert("You have to enter valid e-mail address!");
		document.forms["nff"].usr_email.focus();
		}
	}
function closeNewsForm(){
	document.getElementById("popup_news_form").style.visibility = "hidden";
	document.getElementById("popup_news_form").style.width = "0px";
	document.getElementById("popup_news_form").style.height = "0px";
	document.getElementById("popup_news_form").style.marginTop = "0px";
	document.getElementById("popup_news_form").style.marginLeft = "0px";
	document.getElementById("popup_news_form").style.border = "0px solid #b87600";
	document.getElementById("popup_news_form").style.padding = "0px";
	}

function validateNewsForm(){
	
	var formFinalStatus = 1;
	var nFfinal = document.forms["nff"];
	
	if(nFfinal["usr_name"].value == ""){
		alert("Enter your name please!");
		document.forms["nff"].usr_name.focus();
		formFinalStatus = 0;
		return false;
		}
	var str = nFfinal["usr_email"].value;
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str)){
		formFinalStatus = 1;
		}
	else{
		alert("You have to enter a valid e-mail address!");
		document.forms["nff"].usr_email.focus();
		formFinalStatus = 0;
		return false;
		}
	
	
	if(document.forms['nff'].news_prg.checked == false && document.forms['nff'].news_ny.checked == false){
		alert("Check at least one bar's location!");
		formFinalStatus = 0;
		return false;		
		}
	else{
		formFinalStatus = 1;
		if(document.forms['nff'].news_prg.checked == true){
			var nwUsrPrg = 1;
			}
		else{
			var nwUsrPrg = 0;
			}
		if(document.forms['nff'].news_ny.checked == true){
			var nwUsrNy = 1;
			}
		else{
			var nwUsrNy = 0;
			}
		}
	
	if(formFinalStatus == 1){
		var nwUsrName = nFfinal["usr_name"].value;
		var nwUsrEmail = nFfinal["usr_email"].value;
		
		process(nwUsrName,nwUsrEmail,nwUsrPrg,nwUsrNy);
		}
	}

function process(nwUsrName,nwUsrEmail,nwUsrPrg,nwUsrNy)
{
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
    xmlHttp.open("GET", "/js/validate_newsletter.php?usr_name="+nwUsrName+"&usr_email="+nwUsrEmail+"&usr_prg="+nwUsrPrg+"&usr_ny="+nwUsrNy, true);
    xmlHttp.onreadystatechange = handleServerResponse;
    xmlHttp.send(null);
  }
  else
    // if the connection is busy, try again after one second  
    setTimeout('process(nwUsrName,nwUsrEmail,nwUsrPrg,nwUsrNy)', 1000);
}

function handleServerResponse() 
{
  if (xmlHttp.readyState == 4) 
  {
    if (xmlHttp.status == 200) 
    {      
      myResult = xmlHttp.responseText;
      document.getElementById("popup_news_form").innerHTML = myResult;
    } 
    else 
    {
      alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}

function checkContactForm(){
	var objF = document.forms['sendemail'];
	
	if(objF["formfield[usr_name]"].value == ""){
		alert("Your name is required!");
		objF["formfield[usr_name]"].focus();
		return false;
		}
	if(objF["formfield[usr_email]"].value == ""){
		alert("Your e-mail is required!");
		objF["formfield[usr_email]"].focus();
		return false;
		}
	var str = objF["formfield[usr_email]"].value;
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (!filter.test(str)){
		alert("You have to enter a valid e-mail address!");
		objF["formfield[usr_email]"].usr_email.focus();
		return false;
		}
	if(objF["formfield[message]"].value == ""){
		alert("You didn't write any message!");
		objF["formfield[message]"].focus();
		return false;
		}
		
	}
	
function SetCookie(cookieName,cookieValue,nDays) {
			var today = new Date();
			var expire = new Date();
			if (nDays==null || nDays==0) nDays=1;
			expire.setTime(today.getTime() + 3600000*24*nDays);
			document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString();
			}
		function playMusic(){
			//document.getElementById("myFlash").SetVariable("player:jsPause", "");
			document.getElementById("myFlash").SetVariable("player:jsPlay", "");
			document.getElementById("music_controler").innerHTML = '<a href="javascript:pauseMusic();"><img src="../img/music_pause.gif" width="25" height="20" alt="Pause music" /></a>';
			SetCookie("music_status", 1, 365);
			}
		function pauseMusic(){
			document.getElementById("myFlash").SetVariable("player:jsPause", "");
			document.getElementById("music_controler").innerHTML = '<a href="javascript:playMusic();"><img src="../img/music_play.gif" width="25" height="20" alt="Play music" /></a>';
			//document.cookie = ("music_status", '0');
			SetCookie("music_status", 0, 365);
			}	

var realDivSize;
var actualDivSize = '';
var startDivMargin = '0';
var activePicNum = '0';
var prevActivePicNum = '0';
var totalPicNum = '0';
function resizeDiv(divSize){
	realDivSize = divSize;
	//if(realDivSize <= 625) document.getElementById("button_right").src = "../img/arr_r_off.gif";
	}
function form_clear(fieldName){
	fieldName.value = "";
	}
	
function showGallPhoto(photoNum, photoNote, photoCount){
	activePicNum = photoCount; 
	totalPicNum = (xPicId.length - 1);
	document.getElementById("photo_box").innerHTML = '<img src="../gallery/'+barName+'_'+photoNum+'.jpg" style="border: 2px solid #b87600;" alt="'+photoNote+'" /><br />'+photoNote;
	
	if(activePicNum == 0){
		x = activePicNum;
		x++;
		yPicId = xPicId[x];
		yPicNote = xPicNote[yPicId];
		yPicCount = x;
		
		document.getElementById("paging").innerHTML = '<span style="color: #808080;">&laquo; Preview</span> | <a href="javascript:showGallPhoto(\''+yPicId+'\',\''+yPicNote+'\',\''+yPicCount+'\');" style="color: #ffcc00;">Next &raquo;</a>';
		}
		
		
	if((activePicNum > 0)&&(activePicNum < totalPicNum)){
		y = activePicNum;
		p = y-1;
		y++;
		yPicId = xPicId[y];
		yPicNote = xPicNote[yPicId];
		yPicCount = y;
		
		mPicId = xPicId[p];
		mPicNote = xPicNote[mPicId];
		
		document.getElementById("paging").innerHTML = '<a href="javascript:showGallPhoto(\''+mPicId+'\',\''+mPicNote+'\',\''+p+'\');" style="color: #ffcc00;">&laquo; Preview</a> | <a href="javascript:showGallPhoto(\''+yPicId+'\',\''+yPicNote+'\',\''+yPicCount+'\');" style="color: #ffcc00;">Next &raquo;</a>';
		}
		
		
	if(activePicNum == totalPicNum){
		y = activePicNum;
		p = y-1;
				
		mPicId = xPicId[p];
		mPicNote = xPicNote[mPicId];
		
		document.getElementById("paging").innerHTML = '<a href="javascript:showGallPhoto(\''+mPicId+'\',\''+mPicNote+'\',\''+p+'\');" style="color: #ffcc00;">&laquo; Preview</a> | <span style="color: #808080;">Next &raquo;</span>';
		}
	
	}
	
	
	
	
function showPressPhoto(photoNum, photoNote, photoCount){
	activePicNum = photoCount; 
	totalPicNum = (xPicId.length - 1);
	document.getElementById("photo_box").innerHTML = '<img src="../press/'+barName+'_'+photoNum+'.jpg" style="border: 2px solid #b87600;" alt="'+photoNote+'" />';
	
	if(activePicNum == 0){
		x = activePicNum;
		x++;
		yPicId = xPicId[x];
		yPicNote = xPicNote[yPicId];
		yPicCount = x;
		
		document.getElementById("paging").innerHTML = '<span style="color: #808080;">&laquo; Preview</span> | <a href="javascript:showPressPhoto(\''+yPicId+'\',\''+yPicNote+'\',\''+yPicCount+'\');" style="color: #ffcc00;">Next &raquo;</a>';
		}
		
		
	if((activePicNum > 0)&&(activePicNum < totalPicNum)){
		y = activePicNum;
		p = y-1;
		y++;
		yPicId = xPicId[y];
		yPicNote = xPicNote[yPicId];
		yPicCount = y;
		
		mPicId = xPicId[p];
		mPicNote = xPicNote[mPicId];
		
		document.getElementById("paging").innerHTML = '<a href="javascript:showPressPhoto(\''+mPicId+'\',\''+mPicNote+'\',\''+p+'\');" style="color: #ffcc00;">&laquo; Preview</a> | <a href="javascript:showPressPhoto(\''+yPicId+'\',\''+yPicNote+'\',\''+yPicCount+'\');" style="color: #ffcc00;">Next &raquo;</a>';
		}
		
		
	if(activePicNum == totalPicNum){
		y = activePicNum;
		p = y-1;
				
		mPicId = xPicId[p];
		mPicNote = xPicNote[mPicId];
		
		document.getElementById("paging").innerHTML = '<a href="javascript:showPressPhoto(\''+mPicId+'\',\''+mPicNote+'\',\''+p+'\');" style="color: #ffcc00;">&laquo; Preview</a> | <span style="color: #808080;">Next &raquo;</span>';
		}
	
	
	
	}
var timerLeft = 0;
var timerRight= 0;

function timer(timerSide){
	if(timerSide == "l"){
		timerLeft = 1;
		}
	if(timerSide == "r"){
		timerRight = 1;
		}
	}
function galleryScrollRight(){
	startDivMargin = (startDivMargin-4);
	actualDivSize = (600-realDivSize);
	if((startDivMargin > actualDivSize)&(timerRight == 0)){
		document.getElementById("gallery_tn").style.marginLeft = startDivMargin+"px";
		document.getElementById("button_left").src = "../img/arr_l_on.gif";
		setTimeout('galleryScrollRight()',30);
		timerLeft = 0;
		}
	else{
		if(startDivMargin > actualDivSize){
			}
		else{
			document.getElementById("button_right").src = "../img/arr_r_off.gif";
			}
		timerRight= 0;
		}
	}
	
function galleryScrollLeft(){
	startDivMargin = (startDivMargin+4);
	actualDivSize = 0;
	if((startDivMargin <= actualDivSize)&(timerLeft == 0)){
		document.getElementById("gallery_tn").style.marginLeft = startDivMargin+"px";
		document.getElementById("button_right").src = "../img/arr_r_on.gif";
		setTimeout('galleryScrollLeft()',30);
		timerRight= 0;
		}
	else{
		if(startDivMargin <= actualDivSize){
			}
		else{
			document.getElementById("button_left").src = "../img/arr_l_off.gif";
			}
		timerLeft = 0;
		}
	}

function loadPage(list) {
  location.href=list.options[list.selectedIndex].value;
}

function showOtherEvents(){
	document.getElementById("other_events").style.width  = "auto";
	document.getElementById("other_events").style.height  = "auto";
	document.getElementById("other_events").style.visibility  = "visible";
	}
function hideOtherEvents(){
	document.getElementById("other_events").style.width  = "0px";
	document.getElementById("other_events").style.height  = "0px";
	document.getElementById("other_events").style.visibility  = "hidden";
	}

function showExtraText(){
	document.getElementById("hp_text_block_2").style.height  = "auto";
	document.getElementById("hp_text_block_2").style.visibility  = "visible";
	document.getElementById("end_link").innerHTML = "";
	document.getElementById("end_link").style.visibility  = "hidden";
	}
function checkNewsRegForm1()
	{
	var objF = document.forms("fullNewsForm1");
	if((objF["news_prg"].checked != true)&&(objF["news_ny"].checked != true))
		{
		alert("Check at least one bar's location!");
		return false;
		}
	}
function checkNewsRegForm2()
	{
	var objF = document.forms("fullNewsForm2");
	if(objF["form_field[name]"].value == "")
		{
		alert("Please, fill your name.");
		objF['form_field[name]'].focus();
		return false;
		}
	if(objF["form_field[email]"].value == "")
		{
		alert("Your e-mail is required!");
		objF["form_field[email]"].focus();
		return false;
		}
	var str = objF["form_field[email]"].value;
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (!filter.test(str)){
		alert("You have to enter a valid e-mail address!");
		objF["form_field[email]"].focus();
		return false;		
		}
	
	if((objF["news_prg"].checked != true)&&(objF["news_ny"].checked != true))
		{
		alert("Check at least one bar's location!");
		return false;
		}		
	
	}
function checkNewsRegForm3()
	{
	var objF = document.forms("fullNewsForm3");
	if(objF["form_field[name]"].value == "")
		{
		alert("Please, fill your name.");
		objF['form_field[name]'].focus();
		return false;
		}
	if(objF["form_field[email]"].value == "")
		{
		alert("Your e-mail is required!");
		objF["form_field[email]"].focus();
		return false;
		}
	var str = objF["form_field[email]"].value;
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (!filter.test(str)){
		alert("You have to enter a valid e-mail address!");
		objF["form_field[email]"].focus();
		return false;		
		}	
	}
function checkShortNewsForm()
	{
	var objF = document.forms("shortNewsForm");
	if((objF["form_field[name]"].value == "Name")||(objF["form_field[name]"].value == ""))
		{
		alert("Please, fill your name.");
		objF['form_field[name]'].focus();
		return false;
		}
	if((objF["form_field[email]"].value == "E-mail")||(objF["form_field[email]"].value == ""))
		{
		alert("Your e-mail is required!");
		objF["form_field[email]"].focus();
		return false;
		}
	var str = objF["form_field[email]"].value;
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (!filter.test(str)){
		alert("You have to enter a valid e-mail address!");
		objF["form_field[email]"].focus();
		return false;		
		}
	}