// JavaScript Document

$(document).ready(function () {
	if($('#messagedisplay')){
		$('#messagedisplay').animate({opacity: 1.0}, 6000)
		$('#messagedisplay').fadeOut('slow');
	}
	if($('#error_messagedisplay')){
		$('#error_messagedisplay').animate({opacity: 1.0}, 6000)
		$('#error_messagedisplay').fadeOut('slow');
	}
});
function closeerr(t)
{
	if(t=="err"){
		$("#error_messagedisplay").hide();
	}
	else{
		$("#messagedisplay").hide();
	}
}
function emailsubscribe()
{
	var email = document.getElementById('emailaddress').value;
	if(email == "Enter your e-mail Address"){
		return false;
	}
	else{
		document.forms["emailsubscrib"].submit();
	}
}

function storessearch()
{
	var q = document.getElementById('searchq').value;
	if(q == "Search Stores here..."){
		return false;
	}
	else{
		document.location.href = "/search-stores.html?q="+q;
	}
}

var win2;
function fbconnect(s)
{
  win2 = window.open('http://livebillion.com/facebook-connect.php',null,'width=668,location=0,status=0,height=400');
  checkChild();    
}

function checkChild() {
	  if (win2.closed) {
		window.location.reload(true);
		//
	  } else setTimeout("checkChild()",1);
}

function postcomments(check)
{
	var com = document.getElementById('cDesc').value;
	if(check == 1 && com){
		document.forms["CommDesc"].submit();
		return;
	}
	else if(check == 0){
		var err = "Login To Post comment";
	}
	else if(!com){
		var err = "Comment Required";
	}
	document.getElementById('commerr').innerHTML = err;
	return;
}


var win3;
function clogin()
{
  win3 = window.open('http://livebillion.com/customer-login.html',null,'width=668,location=0,status=0,height=250');
  checkChild1();    
}

function checkChild1() {
	  if (win3.closed) {
		window.location.reload(true);
	  } else setTimeout("checkChild1()",1);
}

$(document).ready(function(){	
	$('#ratelinks li a').click(function(){
		var i = document.getElementById('ratingi').value;
		var t = document.getElementById('itemt').value;
		var url = '/rating.html?rating='+$(this).text()+'&i='+i+'&t='+t+'&curl='+document.URL;
		$.post(url,function(check){ 
			var rmessage = document.getElementById('rating_err');
			if(check && check > 1){
				$("#ratelinks").remove();
				$("#current-rating").css({ width: "" + check + "%" });
				rmessage.innerHTML = "Successfully Voted !";
			}
			else if(check == 1){
				rmessage.innerHTML = "You Already Voted...";		
			}
			else if(check == 0){
				rmessage.innerHTML = "Login To Vote This";
			}
			else{
				rmessage.innerHTML = "Error...";
			}
			displayrateerr();	
		});
	});
});

function checklogin(){
	document.getElementById('rating_err').innerHTML = "Login To Vote This";
	displayrateerr()
}
function votexist()
{
	document.getElementById('rating_err').innerHTML = "You Already Voted...";
	displayrateerr()
}

function displayrateerr()
{
	$("#cloudrate").css({ display: "block" });
	if($('#cloudrate')){
		$('#cloudrate').animate({opacity: 1.0}, 2000)
		$('#cloudrate').fadeOut('slow');
	}
	return;
}
	
$(document).ready(function(){
	$(".menu_tab > li").click(function(e){
		for(var i=1;i<=5; i++){
			if(e.target.id == 'tab'+i){
				$("#"+e.target.id).addClass("tab"+i+"_active");
				$("#ctab"+i).fadeIn();
			}
			else{
				$("#tab"+i).removeClass("tab"+i+"_active");
				$("#ctab"+i).css("display", "none");
			}
		}
		return false;
	});
});
