if (top.location != location) 
	top.location.href = document.location.href;

function SetRating(rating_val)
{
	if(parseInt(rating_val) > 0 && parseInt(rating_val) <= 5 && parseInt(aid) > 0)
	{
		jx.load('/set_vote/'+aid+'/'+rating_val,function(data){},'text');
		document.getElementById('rateMe').innerHTML = '<img src="/images/stars/'+rating_val+'stars_big.gif" width="130" height="24" alt=""/>';
	}
}

function SetRatingiPhone(rating_val)
{
	if(parseInt(rating_val) > 0 && parseInt(rating_val) <= 5 && parseInt(aid) > 0)
	{
		jx.load('/set_vote_iphone/'+aid+'/'+rating_val,function(data){},'text');
		document.getElementById('rateMe').innerHTML = '<img src="/images/stars/'+rating_val+'stars_big.gif" width="130" height="24" alt=""/>';
	}
}

function SetUseful(c_id, useful)
{
	if(parseInt(c_id) > 0)
	{
		if(useful > 0)
			jx.load('/set_useful/'+c_id+'/1/',function(data){},'text');
		else
			jx.load('/set_useful/'+c_id+'/0/',function(data){},'text');
			
		document.getElementById('useful_'+c_id).innerHTML = 'Was this opinion useful?<div class="clear"></div><span class="yes">Yes</span><span class="no">No</span><div class="clear"></div><small>You have voted for this comment</small>';
	}
}

function SetFavorite(c_id)
{
	if(parseInt(c_id) > 0)
	{
		jx.load('/set_favorite/'+parseInt(c_id)+'/',function(data){},'text');
		document.getElementById('add_to_favorites').click = 'return false;';
		document.getElementById('add_to_favorites').className = 'add2list2';
		document.getElementById('add_to_favorites').innerHTML = 'I\'m a fan';
		//document.getElementById('add_to_favorites').style.display = 'none';
	}
}

function SetiPhoneFavorite(c_id, device)
{
	if(parseInt(c_id) > 0 && parseInt(device) > 0)
	{
		jx.load('/set_favorite_iphone/'+parseInt(c_id)+'/'+parseInt(device)+'/',function(data){},'text');
		document.getElementById('add_to_favorites').click = 'return false;';
		document.getElementById('add_to_favorites').className = 'add2list2';
		document.getElementById('add_to_favorites').innerHTML = 'I\'m a fan';
		//document.getElementById('add_to_favorites').style.display = 'none';
	}
}

function DelFavorite(c_id)
{
	if(parseInt(c_id) > 0)
	{
		jx.load('/unset_favorite/'+parseInt(c_id)+'/',function(data){},'text');
		document.getElementById('ufs_'+c_id).style.display = 'none';
		document.getElementById('ufs_'+c_id).innerHTML = '';
	}
}

function DelFavoriteiPhone(c_id, device)
{
	if(parseInt(c_id) > 0 &&  parseInt(device) > 0)
	{
		jx.load('/unset_favorite_iphone/'+parseInt(c_id)+'/'+parseInt(device)+'/',function(data){},'text');
		document.getElementById('ufs_iphone_'+c_id+'_'+parseInt(device)).style.display = 'none';
		document.getElementById('ufs_iphone_'+c_id+'_'+parseInt(device)).innerHTML = '';
	}
}

function SubscribeApp(c_id, mm)
{
	if(parseInt(mm)>0)
		jx.load('/favorite_mail/'+parseInt(c_id)+'/1/',function(data){},'text');
	else
		jx.load('/favorite_mail/'+parseInt(c_id)+'/0/',function(data){},'text');
}

function SubscribeAppiPhone(c_id, mm, device)
{
	if(parseInt(device) > 0)
	{
		if(parseInt(mm)>0)
			jx.load('/favorite_mail_iphone/'+parseInt(c_id)+'/'+parseInt(device)+'/1/',function(data){},'text');
		else
			jx.load('/favorite_mail_iphone/'+parseInt(c_id)+'/'+parseInt(device)+'/0/',function(data){},'text');
	}
}

function SetFriend(c_id)
{
	if(parseInt(c_id) > 0)
	{
		jx.load('/set_friend/'+parseInt(c_id)+'/',function(data){},'text');
		document.getElementById('add_to_friends').innerHTML = '';
		document.getElementById('add_to_friends').style.display = 'none';
	}
}


function rating(num)
{
	var links = document.getElementById('rateMe').getElementsByTagName('a');
	
	for(n=0; n<links.length; n++)
	{
		if(n <= num-1)
			links[n].className = 'on';
	}
}

// For when you roll out of the the whole thing //
function off()
{
	var links = document.getElementById('rateMe').getElementsByTagName('a');
	
	for(n=0; n<links.length; n++)
	{
			links[n].className = '';
	}
}

function limitText(limitField, limitNum) 
{
	if (limitField.value.length > limitNum) 
		limitField.value = limitField.value.substring(0, limitNum);
	//else
		//limitCount.value = limitNum - limitField.value.length;
}

function playVideo()
{
	var params = { allowScriptAccess: "always", allowFullScreen: "always" };
	var atts = { id: "ytPlayer" };
	swfobject.embedSWF("http://www.youtube.com/v/" + videoID + "&enablejsapi=1&playerapiid=player1&showinfo=0", "videoDiv", "748", "425", "8", null, null, params, atts);
}

