/*
	Main Mobimii Js :: custom functions
	make sure that jquery is loaded before this js page 
*/

$jq(document).ready(function(){
	// alert('page fully loaded now');
	$jq('a[rel*=facebox]').facebox();
});

//function to load mobimii chat
function start_chat(auth){ 
	if(auth==true){
		//window.open('/mobimii_chat/mobimii_chat_param.php?ver=1.01', 'mobimii', 'width=285, height=470,left=100, resizable=1, top=100');
		document.location = 'index.php?action=chat';
	} else {
		alert('Please login to use Mobimii Chat');
	}
}

//jump menu for select fields
function jump_menu(targ,selObj,restore){ 
	document.location=''+targ+''+selObj.options[selObj.selectedIndex].value;
	if (restore) selObj.selectedIndex=0;
}

//confirm before redirect
function confirmation(msg,url) {
	var answer = confirm(msg)
	if (answer){
		//alert("Bye bye!");
		if(url) window.location = url;
		return true;
	}else{
		//alert("no action needed");
		return false;
	}
}

//form inputs :: onclick / onblur
function highlight(){ }
function normalise(){ }

//alert msg to user
function alert_user(msg){
	alert(msg);
}

//rate content
function rate_content(id,url,rcount){
	//alert(id);
	$jq(id).load(url);
}

//rate content
function send_to_phone(id,url){
	$jq.ajax({
		//data: 'cid='+id,
		data: '',
		url: url,
		timeout: 2000,
		error: function() {
			console.log("Failed to send request");
		},
		success: function(r) { 
			alert(r);
		}
	}) 
	return false;
}

// country selector funcs
function showCountries(){
	var countrydiv	=	document.getElementById('countryselect');
	countrydiv.style.display	=	'block';

	var countrydiv2	=	document.getElementById('currentcountry');
	countrydiv2.style.display	=	'none';
}
function goBack(){
	var countrydiv	=	document.getElementById('countryselect');
	countrydiv.style.display	=	'none';

	var countrydiv2	=	document.getElementById('currentcountry');
	countrydiv2.style.display	=	'block';
}