// JavaScript Document
if (top.location != self.location)
top.location = self.location;

var newStar = new Array(10)

function showMoreLocation(){
	if($("moreLocation").style.display=="none"){$("moreLocation").show();$("labelLocation").innerHTML="<a href='javascript:showMoreLocation()' class='close'>Hide locations</a>";}else{$("moreLocation").hide();$("labelLocation").innerHTML="<a href='javascript:showMoreLocation()' class='open'>More locations</a>";}}

function getRating(intRatingType,intSort,starID){ 
	var starID = starID;
	newStar[intSort-1] = starID;
	$("rating_"+intRatingType).value = starID;

	for(i=1;i<=5;i++) {
		if (i <= starID){
			document.getElementById("rating_"+intRatingType+"_"+i).style.backgroundImage = "url(/images/stars/star-index-m.gif)"
		}
		else
		{
			document.getElementById("rating_"+intRatingType+"_"+i).style.backgroundImage = "url(/images/stars/star-gray-m.gif)"
		}
	} 
}

function setRating(origialRating,intPoint,intRatingType,intSort){
	for (var i = 1; i<=5 ; i ++){
		if (i<=intPoint){
			document.getElementById("rating_"+intRatingType+"_"+i).style.backgroundImage= "url(/images/stars/star-index-m.gif)";
		}
		else{
			document.getElementById("rating_"+intRatingType+"_"+i).style.backgroundImage= "url(/images/stars/star-gray-m.gif)";
		}
	}
}

function cleanRating(origialRating,intPoint,intRatingType,intSort){
	if (newStar[intSort-1] == ""||newStar[intSort-1] == undefined) {
		starPoint = origialRating;
		starImg = "url(/images/stars/star-index-m.gif)"
	}
	else {
		starPoint = newStar[intSort-1]
		starImg = "url(/images/stars/star-index-m.gif)"
	}
	for (var i = 1; i<=5 ; i ++){
		if (i<=starPoint){
			document.getElementById("rating_"+intRatingType+"_"+i).style.backgroundImage= starImg;
		}
		else{
			document.getElementById("rating_"+intRatingType+"_"+i).style.backgroundImage= "url(/images/stars/star-gray-m.gif)";
		}
	}
}

function ratingFunction(intClient,intTotal,intMem){
	var strLink;
	strLink = '';
	for(j=1;j<=intTotal;j++)
	{
		intRatingType = $F("intRatingTyp_"+j);
		strLink = strLink + '&intRatingType_'+j+'='+intRatingType+'&rating_'+j+'='+ $F("rating_"+intRatingType);;
	}
	
	var myAjax = new Ajax.Request(
		'/include/venues/updateRating.asp?clientid=' + intClient + '&intTotal=' + intTotal + strLink + '&memid='+intMem,
		{
			method: 'get', 
			onSuccess: function(transport4){
				$("rating").hide();
				$("reviewForm").show();
			}
		}
	);
}

function reviewFunction(intClient,intMem){
	avgPrice = $F("avgPrice");
	$$('input[type="radio"][name="payment"]').select(function(i){return i.checked}).each(function(i){payment=i.value}); 
	if (payment != 'neither') 
	{
		ratingValue = 3;
		for(i=5;i>=1;i--) { 
			if (document.getElementById("rating_0_"+i).style.backgroundImage == "url(/images/stars/star-index-m.gif)"){
				var ratingValue = i;
				break;
			}
		}
	}
	else
	{
		ratingValue = '';
	}
	review = $F("review");
	locationid = $F("locationid");
	var myAjax = new Ajax.Request(
								  
		'/include/venues/updateReview.asp?clientid='+intClient+'&memid='+intMem+'&avgPrice='+avgPrice+'&payment='+payment+'&review='+review+'&locationid='+locationid+'&ratingValue='+ratingValue,
		{
			method: 'get', 
			onSuccess: function(transport4){
				$("reviewForm").hide();
				$("rating").hide();
				$("thks").show();
			}
		}
	);
}

function loginForm(){
	var strMessage;
	strMessage = '';
	card_no = $F("card_no");
	//alert(card_no);
	if (card_no == '') strMessage = '<li>Card Number cannot be empty</li>';
	pin_no = $F("pin_no");
	//alert(pin_no);
	if (pin_no == '') strMessage = strMessage + '<li>Password cannot be empty</li>';
	if (strMessage != '') $('strMessage').innerHTML = '<ul>' + strMessage + '</ul>';
	else {
		//alert("hehehe")
		var myAjax = new Ajax.Request(
									  
			'/function/login.asp?card_no='+card_no+'&pin_no='+pin_no,
			{
				method: 'get', 
				onSuccess: function(transport){
					var response = transport.responseText;
					if (response.substring(0,2) == '1-' ){
						$("strMessage").innerHTML = response.substring(2,response.length);
					}
					else if (response.substring(0,2) == '2-' ) {
						 parent.location.href='/register.asp?cn='+card_no+'&pn='+pin_no;
					}
					else {
						window.location.reload();
						//$("loginTitle").innerHTML= "<span>Logged In</span>";
						//$("loinResult").show();
						//$("loinResult").innerHTML = response;
						//$("frmLogin").hide();
					}
				}
			}
		);
	}
}

function loginOut(){
	//$("frmLogin").show();
	//$("loinResult").hide();
	var myAjax = new Ajax.Request(
		'/function/login.asp?item=logout',
		{
			method: 'get', 
			onSuccess: function(transport){
				window.location.reload();
				//$("loginTitle").innerHTML= "<span>Members</span>";
			}
		}
	);
}

function showVenue(intSection,intCity) {
	if (intSection != 0) {
		var myAjax = new Ajax.Request(
									  
			'/include/findVenuFunction.asp?intSection='+intSection+'&intCity='+intCity,
			{
				method: 'get', 
				onSuccess: function(transport){
					var response = transport.responseText;
					$("findList").innerHTML = response;
				}
			}
		);
	}
}

function checkClient()
{
	if($F("intClient")== null)
	{
		return false;
	}
	
	return true;
}


function showReviewDetail(intReview){
	if ($("reviewDetail_"+intReview).style.display=="none"){
		$("reviewDetail_"+intReview).show();
		$("openStatus_"+intReview).innerHTML = "[close]";
		$("reviewList_"+intReview).addClassName("on");
	}
	else {
		$("reviewDetail_"+intReview).hide();
		$("openStatus_"+intReview).innerHTML = "[view]";
		$("reviewList_"+intReview).removeClassName("on");
	}
}

function cancelReview(intReview,intMem) {
	var myAjax = new Ajax.Request(
								  
		'/include/myenjoy/cancelReview.asp?reviewid='+intReview+'&memid='+intMem,
		{
			method: 'get', 
			onSuccess: function(transport){
				var response = transport.responseText;
				$("reviewList_"+intReview).innerHTML = response;
				$("reviewDetail_"+intReview).hide();
			}
		}
	);
}


function givePoint(intMem,intReview) {
	//alert("heheheh")
	var myAjax = new Ajax.Request(
		'/include/venues/giveReviewPoint.asp?reviewid='+intReview+'&memid='+intMem+'&bitType=1',
		{
			method: 'get', 
			onSuccess: function(transport){
				var response = transport.responseText;
				$("givePointDatail_"+intReview).innerHTML = response;
			}
		}
	);
}

function cancelPoint(intReviewPoint,intReview,intMem) {
	var myAjax = new Ajax.Request(
								  
		'/include/venues/giveReviewPoint.asp?reviewPointID='+intReviewPoint+'&bitType=0'+'&reviewid='+intReview+'&memid='+intMem,
		{
			method: 'get', 
			onSuccess: function(transport){
				var response = transport.responseText;
				$("givePointDatail_"+intReview).innerHTML = response;
			}
		}
	);
}

function showDetail(tURL)
{
	wnd = open(tURL,"DetailWin",'toolbar=no,location=no,status=no,menubar=yes,scrollbars=yes,width=800,height=560,left=10,top=10,screenX=20,screenY=30');
	if (wnd)
		wnd.focus();
}

function showOther(intAdvsrc)
{
	if (intAdvsrc == 4)
	{
		$("otherAdvsrc").show();
	}
	else{$("otherAdvsrc").hide();}
}

function showBuyFrom(strBuyFrom)
{
	if (strBuyFrom == "venue")
	{
		$("details").show();
		$("detailsMore").show();
		$("venue").show();
		$("giveaway").hide();
		$("othervenue").hide();
	}
	else if (strBuyFrom == "giveaway")
	{
		$("details").show();
		$("detailsMore").show();
		$("venue").hide();
		$("giveaway").show();
		$("othervenue").hide();
	}
	else if (strBuyFrom == "other")
	{
		$("details").show();
		$("detailsMore").show();
		$("venue").hide();
		$("giveaway").hide();
		$("othervenue").show();
	}
	else{
		$("details").hide();
		$("detailsMore").hide();
		$("venue").hide();
		$("giveaway").hide();
		$("othervenue").hide();
	}
}