// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function doConversion() {
	$.get("/conversion/",
	  function(data){
	    $("#conversion_frame").append(data);
	  });
}

function openWindow ( url, windowname, options ) {
     if ( window.open ( url, windowname, options ) ) {
          return true;
     }
     return false;
}

function conversationsPopup() {
	if ( $(this).height() < 570) {
		$("#html_frame").css('height','455px');
	}
	$('#html_frame').css('width', '732px');
	$('#html_frame').css('height', '580px');
	$('#html_frame').attr('src', '/conversations/');
	$("#html_frame").show();
	$('#html_frame').center();	
}

function newConversationPopup(client_id, video_id) {
	if ( $(this).height() < 570) {
		$("#html_frame").css('height','455px');
	}
	$('#html_frame').css('width', '732px');
	$('#html_frame').css('height', '580px');
	$('#html_frame').attr('src', '/clients/' + client_id + '/conversations/new?video_id=' + video_id);
	$("#html_frame").show();
	$('#html_frame').center();	
}

function regionPopup() {
	$('#html_frame').css('width', '350px');
	$('#html_frame').css('height', '340px');
	$('#html_frame').attr('src', '/regions');
	$("#html_frame").show();
	$('#html_frame').center();	
}

function loginPopup() {
	/*if ( $(this).height() < 570) {
		$("#html_frame").css('height','455px');
	}*/
	$('#html_frame').css('width', '732px');
	$('#html_frame').css('height', '455px');
	$('#html_frame').attr('src', '/session/new');
	$("#html_frame").show();
	$('#html_frame').center();	
}

function logoutPopup() {
	/*if ( $(this).height() < 570) {
		$("#html_frame").css('height','455px');
	}*/
	this.parent.$('#odin')[0].callHideCurtain();	
	$("#html_frame").show();
	$('#html_frame').attr('src', '/logout');
}


function completeSignupPopup() {
	/*if ( $(this).height() < 570) {
		$("#html_frame").css('height','455px');
	}*/
	$('#html_frame').css('width', '732px');
	$('#html_frame').css('height', '455px');
	$('#html_frame').attr('src', '/complete_signup');
	$("#html_frame").show();
	$('#html_frame').center();	
}

function showCurtain() {
	this.parent.$('#odin')[0].callShowCurtain();	
}

function htmlPopupClose() {
	this.parent.$('#odin')[0].callHideCurtain();
	this.parent.$("#html_frame").hide();
	this.parent.$('#html_frame').attr('src', '');
	//reset the iframe height in case user resizes window
	//this.parent.$("#html_frame").css('height','570px');		
}