// JavaScript Document
//alert(document.location.href);
//<![CDATA[
var viosyncUrl = "http://www.tubelinx.com";
function openFeedback(){
window.open(viosyncUrl+"/jsp/user/feedback.jsp","","width=800, height=600");
ClosingVar = true
}

function openYoutubePlayer(str)
{
	var screenWidth = window.screen.width;
	var screenHeight = window.screen.height;
	var windowWidth = 450;
	var windowHeight = 360;
	if(screenWidth >= windowWidth && screenHeight >= windowHeight){
		leftPosition = (screenWidth/2)-(windowWidth/2);
		topPosition = (screenHeight/2)-(windowHeight/2);
	}

	window.open(viosyncUrl+"/jsp/media/youtube_player.jsp?videoId=" +str, "youtubeplayer",
				"left="+leftPosition+", top="+topPosition+", width="+windowWidth+", " +
				"height="+windowHeight+", location=no, menubar=no, resizable=no, " +
				"scrollbars=no, status=no, titlebar=no, toolbar=no");
}
// Open Blog
function openBlog()
{
	//alert("Open Blog");
	var screenWidth = window.screen.width;
	var screenHeight = window.screen.height;
	var windowWidth = 800;
	var windowHeight = 600;
	if(screenWidth >= windowWidth && screenHeight >= windowHeight){
		leftPosition = (screenWidth/2)-(windowWidth/2);
		topPosition = (screenHeight/2)-(windowHeight/2);
	}
	window.open(viosyncUrl+"/blog/tubelinx","","width=800, height=600, scrollbars=yes, left="+leftPosition+", top="+topPosition);
}
//open image
function openImage(str)
{
	//alert("Open Image");
	window.open(str,"","width=800, height=600, scrollbars=yes, left=0");
}

// open quick guide
function callRoboAPI(hParent, a_pszHelpFile, uCommand, dwData)
{
	//	alert();
	if(uCommand == "HH_HELP_CONTEXT"){
		RH_ShowHelp(hParent, a_pszHelpFile, HH_HELP_CONTEXT, dwData);
	}
	if(uCommand == "HH_DISPLAY_TOC"){
		RH_ShowHelp(hParent, a_pszHelpFile, HH_DISPLAY_TOC, dwData);
	}
	if(uCommand == "HH_DISPLAY_SEARCH"){
		RH_ShowHelp(hParent, a_pszHelpFile, HH_DISPLAY_SEARCH, dwData);
	}
	if(uCommand == "HH_DISPLAY_INDEX"){
		RH_ShowHelp(hParent, a_pszHelpFile, HH_DISPLAY_INDEX, dwData);
	}
}

// -----------------------------------------------------------------------------
// spell check
var strToCheck = "";
var commentType = "";
function openSpellChecker(str, type){
	commentType = type;
	var screenWidth = window.screen.width;
	var screenHeight = window.screen.height;
	var windowWidth = 500;
	var windowHeight = 550;
	if(screenWidth >= windowWidth && screenHeight >= windowHeight){
		leftPosition = (screenWidth/2)-(windowWidth/2);
		topPosition = (screenHeight/2)-(windowHeight/2);
	}
	strToCheck = str;
	winSpell = window.open('SpellChecker.html', 'SpellWin', 'width='+windowWidth+', height='+windowHeight+', left='+leftPosition+', top='+topPosition+', resizable=no, titlebar=no, status=yes, scrollbars=yes, menubar=no, fullscreen=no');
}
function updateCheckedContent(str, flag)
{
	var obj = document.getElementById("viosyncMovie");
	//if (obj && typeof obj.JStoASviaExternalInterface != "undefined") {
	if(obj){
		obj.updateCheckedContent(str, commentType, flag);
	}
}
//Spell check function ends--------------------
function openFooterLinks(base, str){
	var screenWidth = window.screen.width;
	var screenHeight = window.screen.height;
	var windowWidth = 800;
	var windowHeight = 600;
	if(screenWidth >= windowWidth && screenHeight >= windowHeight){
		leftPosition = (screenWidth/2)-(windowWidth/2);
		topPosition = (screenHeight/2)-(windowHeight/2);
	}
	winSpell = window.open(base + str +'.html', str+'Win', 'width='+windowWidth+', height='+windowHeight+', left='+leftPosition+', top='+topPosition+', resizable=no, titlebar=no, status=yes, scrollbars=yes, menubar=no, fullscreen=no');
}
// embed swf file ++++++++++++++++++++++++++++++++++++
function getViewportSize() { 
	var size = [0, 0]; 
	if (typeof window.innerWidth != "undefined") { 
		size = [window.innerWidth, window.innerHeight];
	} 
	else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth != 0) {
		size = [document.documentElement.clientWidth, document.documentElement.clientHeight]; 
	}
	else {
		size = [document.getElementsByTagName("body")[0].clientWidth, document.getElementsByTagName("body")[0].clientHeight]; 
	}
	return size; 
}

function createFullBrowserFlash() {
	swfobject.createCSS("html", "height:100%;");
	swfobject.createCSS("body", "height:100%;");
	swfobject.createCSS("#container", "margin:0; width:100%; height:100%; min-width:996px; min-height:500px;");
	window.onresize = function() {
		var el = document.getElementById("container");
		var size = getViewportSize(); 
		el.style.width = size[0] < 996 ? "996px" : "100%";
		//el.style.height = size[1] < 500 ? "500px" : "100%";
	};
	window.onresize();
}

// change swf height
function movHeight(hg) 
{
	//alert("this is test height "+hg);
	var el = document.getElementById("container");
	var size = getViewportSize(); 
	//el.style.width = size[0] < 996 ? "996px" : "100%";
	el.style.height = hg + "px";
	scroll(0,0);
}

function scrollMovieTo(ys)
{
	scroll(0,ys);
}

function closeDemo(){
	var obj = document.getElementById("viosyncMovie");
	obj.closeDemo();
}

function closeDemoOpenQuickGuide(){
	var obj = document.getElementById("viosyncMovie");
	obj.closeDemo();
	
	callRoboAPI("0","quickguide/VioSync_Beta.htm>WithNavPane","HH_HELP_CONTEXT","23");

}

function scrollContent()
{
	scroll(0, 123);
}

// open Login page
function gotoLogin(param)
{
	//alert("gotoLogin " + param);
	signIn();
}

// create MultiSync
function createMultiSync(srcId, destId, multisyncType)
{
	//alert("createMultiSync " + srcId + ", " + destId);
	document.multiSyncForm.srcMediaId.value = srcId;
	document.multiSyncForm.destMediaId.value = destId;
	document.multiSyncForm.multisyncType.value = multisyncType;
	document.multiSyncForm.action="createMultiSync.do";
	document.multiSyncForm.submit();
}

// edit MultiSync
function editMultiSync(multisyncId)
{
	//alert("editMultiSync " + multisyncId);
	document.multiSyncForm.multiSyncId.value=multisyncId;
	document.multiSyncForm.action="editMultiSync.do";
	document.multiSyncForm.submit();
}

function opemDemo(){
window.open("http://www.tubelinx.com/html/demo.html","","width=970, height=610");
}

//]]>	

// FACEBOOK Connector

function addToFaceBook(AddURL, AddTitle)
{
	//alert("AddURL-> "  +  AddURL + "\n AddTitle -> "  + AddTitle);
	//var AddTitle ="Comment from VioSync"
	var AddSite = "http://www.facebook.com/sharer.php?";
	var AddUrlVar = "u";
	var AddTitleVar = "t";
	//Build the URL
	var addtoFullURL = AddSite + AddUrlVar + "=" + AddURL + "&" + AddTitleVar + "=" + AddTitle ;
	//Checking AddToMethod, to see if it opens in new window or not
	//alert(addtoFullURL );
   	addtoWin(addtoFullURL); 	
}


var popupWin = '';

function addtoWin(addtoFullURL)
{
	if (!popupWin.closed && popupWin.location){
		popupWin.location.href = addtoFullURL;
		//intervalMgr();
	}
	else{
		popupWin = window.open(addtoFullURL);
		if (!popupWin.opener) popupWin.opener = self;
		//intervalMgr();
	}
	if (window.focus) {popupWin.focus()}
	return false;
}
/*
function intervalMgr()
{
	if(/Safari/i.test(navigator.userAgent)){ //Test for Safari
		var addtoInterval=setInterval(function(){
  		if(/loaded|complete/.test(document.readyState)){
			clearInterval(addtoInterval)
			closeAddTo() 
  		}}, 1000)
	}
	else{var addtoInterval = setInterval("closeAddTo();",1000);}
}
*/

function ShowHelp(CONTEXT_SENSITIVE_HELP_ID) {

    var fileName = "";
          fileName="quickguide/!SSL!/WebHelp/cut2it.htm#"+CONTEXT_SENSITIVE_HELP_ID;
    
    var windowHandle = window.open(fileName,'helpwindow','width=800,height=530,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes, left=150, top=140');
    if(windowHandle!= null)
          windowHandle.focus();
    else
          alert('Popup blocker has prevented the application from opening the Help window.');

}


function uploadError() 
{
     alert("There was an error while uploading the media. Please try again.");
}

