var NOSUPPORT ="noSupport";
var NOPLUGIN ="noPlugin";
var LOADED ="axLoaded";
var STOPED ="axStop";
var PLAYING ="axPlay";
var RECORDING ="axRec";
var SET_MIC="setMic";
var IS_NS6="gNS6";
var IE_INSTALLATION="installIE";
var FIREFOX_INSTALLATION="installFirefox";
// Flash Variables for use by callbacks

var IS_NETSCAPE="gNS";

var UPLOAD_PROG_VAR="gUploadProg";
var SAVE_RES_VAR="gSaveRes";

var MIC_VOLUME_VAR="gMicVolume";
var MIC_MUTE_VAR="gMicMute";

var host 		 = "";
var pickupUrlSTR = "";
var clientSideEditorExists	= 0;

var agt = navigator.userAgent.toLowerCase();
var is_mac = (agt.indexOf("mac")!=-1);
var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
       && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
       && (agt.indexOf('webtv')==-1));

var debug=0;
debugOut("UI debug on");
var vhssMovObj;

function debugOut(str){
    if (debug==1){
        alert(str);
    }
}

function initMovObj() {
    debugOut('initMovObj');

    if(is_nav) {
        vhssMovObj=eval('document.vhss_bhe');
    }else{
        vhssMovObj=eval('vhss_bhe');
    }

	hostUIDoc=window;
    if(hostUIDoc!='undefined')
    	hostUI=eval('hostUIDoc.document.vhss_bhe');
}

function uploadBG() {
	var bgWindow = window.open("newbgone.php?ss="+show_id,"bgWindow","width=455,height=450,scrollbars=yes");
	bgWindow.focus();
}


// New Audio functions *********************

var winAudioWidth  = 750;
var winAudioHeight = 500;

function uploadAudio() {
	var audioWindow = window.open("newaudio.php?ss="+show_id, "audioWindow", "width="+winAudioWidth+",height="+winAudioHeight+",scrollbars=yes");
	audioWindow.focus();
}

function ttsRecord(audioId) {
	var audioWindow = window.open("newaudio.php?ss="+show_id+"&mode=tts&replace="+audioId, "audioWindow", "width="+winAudioWidth+",height="+winAudioHeight+",scrollbars=yes");
	audioWindow.focus();
}

function phoneRecord() {
	var audioWindow = window.open("newaudio.php?ss="+show_id+"&mode=phone", "audioWindow", "width="+winAudioWidth+",height="+winAudioHeight+",scrollbars=yes");
	audioWindow.focus();
}



function setButton(){
	buttonWindow = window.open( "button.php?ss="+show_id+"&sl="+slide_id,"buttonWindow","width=575,height=450,toolbar=no,resizable=no");
	buttonWindow.focus();
}

function previewSlide(){
//	previewWindow = window.open( "previewslide.php?ss="+show_id+"&sl="+slide_id+"&editmode=1&bizplayer=1","previewWindow","width=410,height=300,toolbar=no,resizable=no");
	playerWindow = window.open( "playersettings.php?ss="+show_id+"&sl="+slide_id,"playerWindow","width=410,height=300,toolbar=no,resizable=no");
	playerWindow.focus();
}

function updateFlash(update,newID){
	if(update == 'bg'){
		mode = 'bg';
	}else if(update == 'au'){
		mode = 'sound';
	}else if(update == 'ph'){
		mode = 'phone';
	}

	useFlashLC('gotNewItem',mode+'~'+newID);
}


function useFlashLC(meth, args){

	var divcontainer = "lc";
	if(!document.getElementById(divcontainer)){
		var divholder = document.createElement("DIV");
		divholder.id = divcontainer;
		document.body.appendChild(divholder);
	}
	document.getElementById(divcontainer).innerHTML = "";
	var divinfo = "<embed src='vhss_lc.swf' FlashVars='lc_name=sitepal_lc&methodNm="+meth+"&args="+args+"' width='0' height='0' type='application/x-shockwave-flash'></embed>";
	document.getElementById(divcontainer).innerHTML = divinfo;
}

function updatePlayerSetting(title,vol,pause,color){
	useFlashLC('updatePlayerSettings',title+'~'+vol+'~'+pause+'~0x'+color);
}

function updateButtonSetting(label,visible){
	useFlashLC('updateLinkSettings',label+'~'+visible);
}
//-------------------------------------------------------------------------------------

function vhss_bhe_FSCProcess(com, arg){
	clientSideEditorExists	= 1;

    if (com == "load")
        load();

	else if (com == "record")
        parent.frames.hostClientFrame.record();
    else if (com == "play")
        parent.frames.hostClientFrame.play();
    else if (com == "stop")
        parent.frames.hostClientFrame.stop();
    else if (com == "save")
        parent.frames.hostClientFrame.save();
    else if (com == "cancelSave")
        parent.frames.hostClientFrame.cancelSave();
    else if (com == "installXPI")
        parent.frames.hostClientFrame.InstallXPI2();

    // properties setting

    else if (com == "user")
        parent.frames.hostClientFrame.setUserid(arg);
    else if (com == "did")
        parent.frames.hostClientFrame.setDoorid(arg);
    else if (com == "track")
        parent.frames.hostClientFrame.setTrackid(arg);
    else if (com == "client")
        parent.frames.hostClientFrame.setClientid(arg);
    else if (com == "cid")
        parent.frames.hostClientFrame.setClientid(arg);
    else if (com == "contest")
        //parent.frames.hostClientFrame.setContest(arg);
        parent.frames.hostClientFrame.setStrVar(arg);
    else if (com == "micVolume")
        parent.frames.hostClientFrame.setMicVolume(arg);
    else if (com == "micMute")
        parent.frames.hostClientFrame.setMicMute(arg);
    else if (com == "createThumbChar"){
        parent.frames.hostClientFrame.createThumbEx(92,296, 230, 435, 100,100);
	}else if (com == "createThumbScene"){
		parent.frames.hostClientFrame.createThumbEx(90,270, 290, 470, 100, 100);
	}else if (com == "close")
		parent.frames.close();

}

function load(){

	var uA = navigator.userAgent.toLowerCase();
	var bNS6 = (uA.indexOf("netscape6/6") !=-1 || uA.indexOf("netscape/7") !=-1);

    if (is_mac || bNS6 /*|| is_nav*/){
        vhssMovObj.TCallLabel("/", NOSUPPORT);
        return;
    }
    newLoc=pickupUrlSTR+"/hostClient.php";
    parent.hostClientFrame.location=newLoc;
}

function vhss_bhe_DoFSCommand(com, arg){
    vhss_bhe_FSCProcess(com, arg);
}


function setSoundCheck()
{
    var now = new Date();
    now.setFullYear(now.getFullYear() + 1);
    document.cookie = "soundCheck=notshow; expires="+ now.toGMTString() + "; path=/; domain="+host;
}

function goBack(mode){

	if(mode==1){
		parent.window.close();
	}else if(mode==0){
		theFrame = parent.window.opener;
		pageNumber = 0;
		if(theFrame.document.adminshows && theFrame.document.adminshows.page){
			pageNumber = theFrame.document.adminshows.page.value;
		}
		theFrame.document.location = 'slideshowsTM.php'+(pageNumber>1?'?page='+pageNumber:'');

		setTimeout("parent.window.close();",1000);
	}else if(mode>1){
		theFrame = parent.window.opener;
		theFrame.reloadLeftframe(accountId,mode);

		theFrame.focus();
	}

}

function createThumb() {
    parent.frames.hostClientFrame.setTrackid(show_id);
    parent.frames.hostClientFrame.setClientid(accountId);
    parent.frames.hostClientFrame.createThumbEx(80,230, 290, 510, 80, 70);
    alert("Thumbnail created");
}

function buyIt()
{
	if (top.window.opener) 
		top.window.opener.location.href = "http://www.sitepal.com/detailedpricing";
	else
		window.open('http://www.sitepal.com/detailedpricing', 'dp');

	window.setTimeout('top.window.close();', 500);
}

function gotoStore(option){
	buyIt();
}

function setAlert(alertFlag){

	now = new Date();
	now.setYear(now.getYear()+1);

	document.cookie = "alertFlag=" + alertFlag +
    "; expires=" + now.toGMTString() +
    "; path=/" +
    "; domain=oddcast.com";
}

function openTutorial(url,w,h){
	h = h==undefined?475:h;
	w = w==undefined?735:w;
	tutorialWindow = window.open( url,"tutorialWindow","width="+w+",height="+h+",toolbar=no,resizable=no");
	tutorialWindow.focus();
}


function goToTutorial(){
	tutWindow = window.open("http://www.sitepal.com/TutorialMovie","tutWindow","width=930,height=570,resizable=yes");
	tutWindow.focus();	
}

function skinEditorHelp(){
	helpWindow = window.open( "whatsThis.php?whatsThis=skinEditor","helpWindow","width=600,height=500,toolbar=no,resizable=yes,scrollbars=yes");
	helpWindow.focus();	
}

function openSkinEditor(){
	top.document.location = 'skinEditor.php?ss='+show_id;
}