﻿// Copyright (C) 2005-2008 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Re-distribute this code or any part of it.
//     Instead, you may link to the homepage of this code:
//     http://www.php-development.ru/javascripts/dropdown.php
//
// YOU MAY
// (1) Use this code on your website.
// (2) Use this code as part of another product.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind.
// You expressly acknowledge and agree that use of this code is at your own risk.


// ***** Popup Control *********************************************************

// ***** at_show_aux *****

function socialText(word)
{
	$('.box_menu_footer_network_detail_R').html('<img src="images/bt/text_'+word+'.png" />');	
}

function socialTextClear()
{
	$('.box_menu_footer_network_detail_R').html('');
}

function suddenChangeLang(index,url)
{
	if(index == 0)
	{
		setTimeout(function()
		{
			document.location = 'change_lang?ln=&url='+url;
		}, 0);
	}else if(index == 1)
	{
		setTimeout(function()
		{
			document.location = 'change_lang?ln=th&url='+url;
		}, 0);
	}
}

function changeLan(index)
{
	
	if(index == 0)
	{
		url = baseurl() + "change_lang?ln=&url=" + escape(window.location);
	}else if(index == 1)
	{
		url = baseurl() +  "change_lang?ln=th&url=" + escape(window.location);
	}

	document.location = url;
}

function changeLang(url)
{
	window.location = url;
}

function setHilight(index)
{
	if(index == 0)
	{
		$('lang_Us').className = 'txt_event_morenews';
	}else if(index == 1)
	{
		$('lang_Th').className = 'txt_event_morenews';
	}
}



function setMenu(index,ln)
{
	var mainMenu = ["home","event","travel","venues","subscribe"];

	if(index == 7)
	{
		document.getElementById('mainMenu7').className = 'leftMenu7_active'+ln;
	}
	else
	{
		document.getElementById('mainMenu'+index).className = 'leftMenu'+index+'_active'+ln;
	}
}

/*
var active = 0;
function showFilter()
{
	if(active == 0)
	{
		document.getElementById('filter').style.visibility = 'visible';
		active = 1;
	}
	else if(active == 1)
	{
		document.getElementById('filter').style.visibility = 'hidden';
		active = 0;
	}
	return false;
}*/
var activeSearch = 0;
function showSearch()
{
	if(activeSearch == 0)
	{
		document.getElementById('search_box').style.visibility = 'visible';
		activeSearch = 1;
	}
	else if(activeSearch == 1)
	{
		document.getElementById('search_box').style.visibility = 'hidden';
		activeSearch = 0;
	}
	return false;
}
function dateTab(id)
{
	for(i=0;i<3;i++)
	{
		document.getElementById('dateTab'+i).src = 'images/+.png';
	}
		
		document.getElementById('dateTab'+id).src = 'images/image-.png';
}

function setFooterMenu(footer)
{
	/*if(ln == '_th')
	{
		var menuFooter = ["หน้าเเรก","ค้นหา","ลงทะเบียน","งานอีเว้นท์","งานนิทรรศการ","งานแสดงสินค้า","งานเทศกาล","งานประชุม","การเเสดงและละคร","คอนเสิร์ต","งานแสดงศิลปะ","งานกีฬา","ท่องเที่ยว","สถานที่เเนะนำ","โรงแรม","ร้านอาหารและผับ","สุขภาพและสปา","เส้นทางการท่องเที่ยว","เกี่ยวกับ WiKalenda","ร่วมแสดงความคิดเห็น","ติดต่่อเรา","สถานที่จัดเเสดง","บทความ","My BusinessKlalenda","ข่าวล่าสุด","ปฏิทินของฉัน","ปฏิทินธุรกิจของฉัน","มือถือ","การเดินทาง"];
	}
	else
	{
		var menuFooter = ["Home","Search","Subscribe","Events","Exhiibitions","Fairs","Festivals","Conventions","Shows","Concerts","Art Galleries","Sports","Travel","Attractions","Hotels","Eat & Drink","Medical & Spa","Travel Route","About WiKalenda","Feedback","Contact us","Venues","Reviews","My BusinessKlalenda","News & Update","My Kalenda","My Business Kalenda","Mobile","Transportation"];
	}
	
	for (i=0;i<29;i++)
	{
		document.getElementById('menuFooter'+(i+1)).innerHTML = menuFooter[i];
		if( i == (footer-1))
		{
			document.getElementById('menuFooter'+footer).innerHTML = '<strong>'+menuFooter[i]+'</strong>';
		}
	}*/
	
	document.getElementById('menuFooter'+footer).className = 'font_detail_menu_active';
	
}

function autoClick(index,url)
{
	if(index == 1)
	{
		document.getElementById('loginButton').href = 'signin?height=428&width=667&modal=true&err=1';
		$('#loginButton').click();
	}
	else if(index == 2)
	{
		document.getElementById('loginButton').href = 'signin?height=428&width=667&modal=true&r='+url;
		$('#loginButton').click();	
	}
	else if(index == 3)
	{
		document.getElementById('loginButton').href = 'signin?height=428&width=667&modal=true';
		$('#loginButton').click();
	}
	else if(index == 4)
	{
		document.getElementById('loginButton').href = 'signinMyBusiness?height=445&width=709';
		$('#loginButton').click();
	}
	else if(index == 5)
	{
		document.getElementById('loginButton').href = 'signinMyBusiness?height=445&width=709&err=1';
		$('#loginButton').click();
	}
	else if(index == 6)
	{
		document.getElementById('loginButton').href = 'signin?height=428&width=667&modal=true&err=6';
		$('#loginButton').click();
	}
	
}

function checkSearchDate()
{
	
	if(document.getElementById('end_date').value >= document.getElementById('from_date').value)
	{
		document.getElementById('searchBox').submit();
	}
	else
	{
		alert('End dat < From Date');
	}
	
	return false;

	
}

function submitFB()
{
	if(document.getElementById('email').value.length > 0 && document.getElementById('subject').value.length > 0 && document.getElementById('detail').value.length > 0)
	{
		if($('#security_code').val() != $('#secur_code').val())
			document.getElementById('error').innerHTML = 'Captcha is not match';
		else
			document.getElementById('FBForm').submit();
	}
	else
	{
		document.getElementById('error').innerHTML = 'Please fill all information.';
	}
}

function share(type,uri,desc)
{	
	var uri = encodeURIComponent(uri);
	
	var desc = encodeURIComponent(desc);
	
	if(type =='digg')
		window.open('http://digg.com/submit?phase=2&url=' + uri +'&title=' + desc);
	else if(type == 'twitter')
		window.open('http://twitter.com/home?status=' + uri);
		
	else if(type == 'stumbleupon')
		window.open('http://www.stumbleupon.com/submit?url=' + uri);
		
	else if(type == 'delicious')
		window.open('http://del.icio.us/post?url=' + uri +'&title=' + desc);
		
	else if(type == 'facebook')
		window.open('http://www.facebook.com/share.php?u=' + uri,'','width=720,height=320');
		
	else if(type == 'myspace')
		window.open('http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=' + uri);
		
	else if(type == 'google')
		window.open('http://www.google.com/bookmarks/mark?op=edit&bkmk=' + uri);
		
	else if(type == 'technorati')
		window.open('http://technorati.com/cosmos/search.html?url=' + uri);
		
	return false;
}

function checkValidForm()
{
	if(($('#what').val()).length == 0)
	{
		alert('Please Fill Form');
		return false;
	}
	else
	{
		return true;
	}
}

function searchSubmit()
{
	if(checkValidForm())
		$('#search').submit();
}

function chaneMyfavType(type,ln,page)
{
	$.ajax({
	  url: 'iframeMyfavorite?type='+type+'&page='+page,
	  success: function(data) {
		$('#myFav').html(data);
		}
	});
	
	/*if(type == 'travel')
	{
		document.getElementById('myFavTravelTab').className = 'event_right_myfavorite1_travel_active'+ln;
		document.getElementById('myFavEventTab').className = 'event_right_myfavorite1_event'+ln;
	}
	else
	{
		document.getElementById('myFavEventTab').className = 'event_right_myfavorite1_event_active'+ln;
		document.getElementById('myFavTravelTab').className = 'event_right_myfavorite1_travel'+ln;
	}*/
}

function weatherFrame(type)
{
	$('#weather_box').html('<div style="float:left;padding-left:100px;padding-top:250px;"><img src="images/loading_small.gif"></div>');
	$.ajax({
	  url: 'iframeWeather?type='+type,
	  success: function(data) {
		$('#weather_box').html(data);
		if(type == 'f'){
			document.getElementById('fahrenheit').className = 'travel_boxbottomR_weather_btF_active';
			document.getElementById('celsius').className = 'travel_boxbottomR_weather_btC';
		}
		else{
			document.getElementById('celsius').className = 'travel_boxbottomR_weather_btC_active';
			document.getElementById('fahrenheit').className = 'travel_boxbottomR_weather_btF';
		}
		}
	});
}

function openWindow(imgFile) 
{
	var img = new Image();
	img.src = imgFile;
	
	open(imgFile, '', 'height=' + img.height + ', width=' + img.width);
}

/********************* V 4.0 ****************************/
function htmlSize()
{
	try{
		var height = document.getElementById('footer').offsetTop;
		var left = document.getElementById('footer').getBoundingClientRect().left;
		
		if(navigator.appName == "Microsoft Internet Explorer")
		{
			left = left - 22;
		}
		else
		{
			left = left - 20;
		}
		
		height = height + 43;
	
		
		document.getElementById('footer_network').style.top = height+'px';
		document.getElementById('footer_network').style.left = left+'px';
		
		document.getElementById('box_location').style.top = document.getElementById('wrap_detail_top').offsetTop+'px';
		document.getElementById('box_location').style.left = document.getElementById('wrap_detail_top').getBoundingClientRect().left+702+'px';
		
	}catch(err){}
	
	setTimeout("htmlSize()",1000);
	
}
