window.flashhasloaded = false;
window.functionCall = '';
var cThemes = new Array();

function CTheme(name, alt, colors, alfa) {
    this.name = name;
    this.alt = alt;
    this.colors = new Array();
    this.colors['controllerButtonsNormal'] = colors[0];
    this.colors['controllerButtonsOver'] = colors[1];
    this.colors['progressBarElapse'] = colors[2];
    this.colors['progressBarDownload'] = colors[3];
    this.colors['progressBarBackground'] = colors[4];
    this.colors['backgroundVideo'] = colors[5];
    this.colors['playlistBackground'] = colors[6];
    this.colors['playlistThumbBck'] = colors[7];
    this.colors['controllerBackground'] = colors[8];
    this.alfa = alfa;
}

function buildCThemes() {
    var themes = new Array();
	
    themes.push(new CTheme(
        'Classic', 
        'buttonStyle1',
        Array('20ACF1', '2A87CF', '2A87CF', '02787E', '000000', '000000', '000000', '000000', '3E3E3E'),
        70
        ));
    themes.push(new CTheme(
        'Violin Wood', 
        'buttonStyle6',
        Array('2A1C01', '4A3208', '5A3B00', 'FFFFFF', 'EEA415', '000000', '000000', 'EEA415', 'EEA415'),
        90
        ));
    themes.push(new CTheme(
        'Scientifique', 
        'buttonStyle4',
        Array('1E1E1E', '6E6E6E', '1E1E1E', 'B3B3B3', '1E1E1E', '000000', '000000', 'EFEDED', 'EFEDED'),
        90
        ));
    themes.push(new CTheme(
        'Fresh', 
        'buttonStyle2',
        Array('28320F', 'EDFBC6', '28320F', '28320F', '43521D', '000000', '0A0E03', '9AB128', '9AB128'),
        90
        ));
    themes.push(new CTheme(
        'Dark', 
        'buttonStyle7',
        Array('505050', '6E6E6E', '505050', '2E2E2E', '464646', '000000', '101010', '505050', '000000'),
        100
        ));
    themes.push(new CTheme(
        'Candy', 
        'buttonStyle5',
        Array('FFDFFD', 'FF9BEF', 'FFDFFD', '40082A', '5E1F36', '000000', '262626', 'DD005D', 'DD005D'),
        95
        ));
    themes.push(new CTheme(
        'Milk', 
        'buttonStyle3',
        Array('6A5C43', 'AB8234', '74654B', 'FFEA7C', 'FFFED1', '000000', '1C1915', 'FFEF95', 'FFEF95'),
        90
        ));
    themes.push(new CTheme(
        'Corporate', 
        'buttonStyle8',
        Array('FFFFFF', 'DD2911', 'DD2911', 'FFFFFF', '808080', '000000', '000000', 'DDDDDD', '000000'),
        90
        ));	
    themes.push(new CTheme(
        'Mainstream', 
        'buttonStyle9',
        Array('CCCCCC', 'FFFFFF', '1098d2', 'AAAAAA', 'FFFFFF', '000000', '000000', '1098d2', '000000'),
        90
        ));	
    themes.push(new CTheme(
        'Xmas 1', 
        'buttonStyle10',
        Array('FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF'),
        70
        ));
    themes.push(new CTheme(
        'Xmas 2', 
        'buttonStyle11',
        Array('FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF'),
        70
        ));	
    themes.push(new CTheme(
        'Minimalist', 
        'buttonStyle12',
        Array('FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', 'FFFFFF', '000000', 'FFFFFF', 'FFFFFF'),
        70
        ));
    themes.push(new CTheme(
        'Mainstream 2', 
        'buttonStyle13',
        Array('E9F4E6', '45DEFF', '45DEFF', 'DBDBFF', 'CBCBCC', '000000', '262626', '45DEFF', '262626'),
        70
        ));
    cThemes = themes;
}

function getCTheme(altName) {
    if (cThemes.length > 0) {
        for (var i in cThemes) {
            if (typeof cThemes[i] == 'function')
                continue;
            if (altName == cThemes[i].alt)
                return cThemes[i];
        }
    }
    return false;
}

function loadTheme(theme) {
    if (theme) {
        xmasTheme = false;
        if (theme.alt == 'buttonStyle10' || theme.alt == 'buttonStyle11') {
            xmasTheme = true;
        }

        if (xmasTheme) {
            $('wrap_colors1').childElements()[0].style.display = 'none';
            $('wrap_colors2').childElements()[0].style.display = 'none';
            $('wrap_colors3').childElements()[0].style.display = 'none';
        }
        else {
            $('wrap_colors1').childElements()[0].style.display = '';
            $('wrap_colors2').childElements()[0].style.display = '';
            $('wrap_colors3').childElements()[0].style.display = '';
        }
		
        for (var k in theme.colors) {
            if (typeof theme.colors[k] == 'function')
                continue;
            //process HTML
            $(k + 'i').style.backgroundColor = '#' + theme.colors[k];
            //process JS object
            eval('skinDetails.details.' + k  + '= "0x' + theme.colors[k] + '"');
            //process Flash
            if (!xmasTheme) {
                $('vp_holder').setParameter(k, theme.colors[k]);
            }
        }
        //process HTML
        $('playlistBckAlpha').value = theme.alfa;
        //process JS object
        eval('skinDetails.details.playlistBckAlpha = theme.alfa');
        //process Flash
        if (!xmasTheme) {
            $('vp_holder').setParameter('playlistBckAlpha', theme.alfa);
        }
    }
    else {
        showRedNotification('The ' + theme.name + ' theme could not be processed.');
        return false;
    }
}

function restoreTheme() {
    customThemeColor = false;
    if (currTheme)
        loadTheme(currTheme);
    else
        loadTheme('buttonStyle1');
}

function loadThemeSwf(themeAlt) {
    if (themeAlt == "buttonStyle1")
	try {$('vp_holder').setParameter('buttonStyle', "1")}catch(e){}
	if (themeAlt == "buttonStyle2")
	try {$('vp_holder').setParameter('buttonStyle', "2")}catch(e){}
	if (themeAlt == "buttonStyle3")
	try {$('vp_holder').setParameter('buttonStyle', "3")}catch(e){}
	if (themeAlt == "buttonStyle4")
	try {$('vp_holder').setParameter('buttonStyle', "4")}catch(e){}
	if (themeAlt == "buttonStyle5")
	try {$('vp_holder').setParameter('buttonStyle', "5")}catch(e){}
	if (themeAlt == "buttonStyle6")
	try {$('vp_holder').setParameter('buttonStyle', "6")}catch(e){}
	if (themeAlt == "buttonStyle7")
	try {$('vp_holder').setParameter('buttonStyle', "7")}catch(e){}
	if (themeAlt == "buttonStyle8")
	try {$('vp_holder').setParameter('buttonStyle', "8")}catch(e){}			
	if (themeAlt == "buttonStyle9")
	try {$('vp_holder').setParameter('buttonStyle', "9")}catch(e){}			
	if (themeAlt == "buttonStyle10")
	try {$('vp_holder').setParameter('buttonStyle', "10")}catch(e){}		
	if (themeAlt == "buttonStyle11")
	try {$('vp_holder').setParameter('buttonStyle', "11")}catch(e){}
	if (themeAlt == "buttonStyle12")
	try {$('vp_holder').setParameter('buttonStyle', "12")}catch(e){}
	if (themeAlt == "buttonStyle13")
	try {$('vp_holder').setParameter('buttonStyle', "13")}catch(e){}
}

function setNewColor(c1, c2, c3) {
    if (c1 && c2 && c3) {
        //process HTML
        $S('controllerBackgroundi').backgroundColor = '#' + c1;
        $S('playlistThumbBcki').backgroundColor = '#' + c1;
		
        $S('controllerButtonsNormali').backgroundColor = '#' + c2;
        $S('progressBarBackgroundi').backgroundColor = '#' + c2;
		
        $S('controllerButtonsOveri').backgroundColor = '#' + c3;
        $S('progressBarElapsei').backgroundColor = '#' + c3;
        $S('progressBarDownloadi').backgroundColor = '#' + c3;
		
        //$S('backgroundVideoi').backgroundColor = '#000000';
        //$S('progressBarDownloadi').backgroundColor = '#FFFFFF';
        //$S('playlistBackgroundi').backgroundColor = '#000000';
		
        //process JS object
        skinDetails.details.controllerBackground = '0x' + c1;
        skinDetails.details.playlistThumbBck = '0x' + c1;

        skinDetails.details.controllerButtonsNormal = '0x' + c2;
        skinDetails.details.progressBarBackground = '0x' + c2;
		
        skinDetails.details.controllerButtonsOver = '0x' + c3;
        skinDetails.details.progressBarElapse = '0x' + c3;
        skinDetails.details.progressBarDownload = '0x' + c3;

        //skinDetails.details.backgroundVideo = '0x000000';
        //skinDetails.details.progressBarDownload = '0xFFFFFF';		
        //skinDetails.details.playlistBackground = '0x000000';

        document.modified = 1;
    }
}

function checkCustomColor() {
    if (typeof skinDetails.details != 'undefined') {
        var d = skinDetails.details;
        var skinname = 'buttonStyle' + d.buttonStyle;
        var currTheme = getCTheme(skinname);
		
        if (typeof currTheme != 'undefined') {
            for (var idx in currTheme.colors) {
                if (typeof currTheme.colors[idx] != 'string') {
                    continue;
                }
				
                var sColor = eval('d.'+idx);
                var tColor = '0x' + currTheme.colors[idx];

                if (sColor != tColor) {
                    return true;
                }
            }
        }
    }
    return false;
}

function showSkinDetails(text)
{
    //	alert(text);
    eval(text);
	
    if (skinDetails.id != 0 && skinDetails.id != '')
    {
        window.location.href= '#'+skinDetails.id;
        document.title = videoPlayerFactoryText;
        window.scrollBy(-10000, -10000);
    }
	
    window.currentskin = skinDetails;
	
    if (checkCustomColor()) {
        window.customThemeColor = true;
    }
    else {
        window.customThemeColor = false;
    }
	
    document.selectedskin = skinDetails.id;
    if (skinDetails.title != '')
        showNotification(loadedSkinText+' "'+skinDetails.title+'".', 1);
    try {
        if (skinDetails.details)
        {
            var aaa = skinDetails.details;
            aaa.txtid = skinDetails.txtid;
            var bbb = aaa.toJSONString();
            bbb = str_replace('#', '0x', bbb);
        }
    } catch(e){
        var bbb = '';
    }
    $('vpparent').innerHTML = '<div id="vp_holder" class="vp_holder"> </div>';
    bbb = str_replace('#', '0x', bbb);
    var flashvars = {
        htmlPage: document.location,
        settingsFile: "/skins/feedxml?id="+aaa.txtid+"|||notpublished"
    };
    var params = {
        allowFullScreen: "true",
        wmode: "opaque",
        allowScriptAccess:"sameDomain"
    };
	
    window.flashhasloaded = false;
	
	
    swfobject.embedSWF("/videoPlayer_author.swf", "vp_holder", "473", "414", "9.0.115", "/swfobject/expressInstall.swf", flashvars, params);
		
	
    if (skinDetails.id != 0 && skinDetails.id != '')
    {
        selectSkin(skinDetails.id);
        post_params = {
            "sid":skinDetails.id, 
            'txtid':skinDetails.txtid
        }
    } else {
        var tsid = new Date().getTime();
        window.currentskin.tsid = tsid;
        window.skinDetails.tsid = window.currentskin.tsid;
        post_params = {
            "tsid":window.currentskin.tsid
        }
    }

    window.sid = window.currentskin.id;
    window.swfuploadinited = true;


    if (window.swfuploadinited)
    {
        //delete - recreate
        $('uploadParent').innerHTML = '<span id="uploadButton"><img src="/images'+langLink+'/plus.jpg" style=\'cursor:pointer;\' onclick="showRedNotification(\''+youNeedToUpgradeText+'\', 1)"/></span><input id="btnCancel1" type="hidden"/>';
    }

    if (uac > 1)
    {
        upload1 = new SWFUpload({
            upload_url: "/skins/uploadwatermark/",		
            post_params: post_params,
            file_size_limit : "1000240",		
            file_types : "*.gif;*.jpg;*.png;*.jpeg",
            file_types_description : "Image Files",		
            file_upload_limit : "10",
            file_queue_limit : "1",		
            file_dialog_start_handler : fileDialogStart,
            file_queued_handler : fileQueued,		
            file_queue_error_handler : fileQueueError,
            file_dialog_complete_handler : fileDialogComplete,		
            upload_start_handler : uploadStartSkins,
            upload_progress_handler : uploadProgress,		
            upload_error_handler : uploadError,
            upload_success_handler : uploadSuccessSkins,		
            upload_complete_handler : uploadComplete,
            button_image_url : "/images/upload.png",		
            button_placeholder_id : "uploadButton",
            button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, 
            button_cursor: SWFUpload.CURSOR.HAND,
            button_width: 69,		
            button_height: 26,
            flash_url : "/swfupload/swfupload.swf",		
            custom_settings : {
                progressTarget : "fsUploadProgress1",			
                cancelButtonId : "btnCancel1"
            },		
            debug: false
        });
    }
    $('skinname').value=skinDetails.title;
    if (skinDetails.title == '') {
        $('skinname').value = 'Name';
    }
    //$('skinname2').value=skinDetails.title;
    //$('skinname3').value=skinDetails.title;
    //$('skinname4').value=skinDetails.title;
    $('description').value=skinDetails.description;
    if (skinDetails.description == '') {
        $('description').value = 'Enter skin description';
    }

    /* 		try {
			$('skinid').value=skinDetails.id;
		} catch(e) {$('skinid').value = 0;} */


    window.currentskin.description = skinDetails.description;
    window.currentskin.id = skinDetails.id;
    window.currentskin.title = skinDetails.title;
    window.currentskin.txtid = skinDetails.txtid;
    window.currentskin.used = skinDetails.used;
    window.currentskin.details = skinDetails.details;

		
    /*$('authorcheck').className = "checkbox";*/
    var d = skinDetails.details;
    $('watermarkLink').value = d['watermarkLink'];
		
    if (d['shareViaEmbed'] == 1) {
        $('shareViaEmbed').className = 'checkbox on';
    }else {
        $('shareViaEmbed').className = 'checkbox';
    }
    //culors & alpha
    //$('backgroundPlayeri').style.backgroundColor = d['backgroundPlayer'].replace('0x', '#');
    $('controllerButtonsOveri').style.backgroundColor = d['controllerButtonsOver'].replace('0x', '#');
    $('controllerBackgroundi').style.backgroundColor = d['controllerBackground'].replace('0x', '#');
    //$('timesi').style.backgroundColor = d['times'].replace('0x', '#');
    $('progressBarElapsei').style.backgroundColor = d['progressBarElapse'].replace('0x', '#');
    //$('preloaderBackgroundi').style.backgroundColor = d['preloaderBackground'].replace('0x', '#');

    $('backgroundVideoi').style.backgroundColor = d['backgroundVideo'].replace('0x', '#');
    $('controllerButtonsNormali').style.backgroundColor = d['controllerButtonsNormal'].replace('0x', '#');
    //$('controllerButtonsDowni').style.backgroundColor = d['controllerButtonsDown'].replace('0x', '#');
    //$('volumebarBcki').style.backgroundColor = d['volumebarBck'].replace('0x', '#');
    $('progressBarBackgroundi').style.backgroundColor = d['progressBarBackground'].replace('0x', '#');
    $('progressBarDownloadi').style.backgroundColor = d['progressBarDownload'].replace('0x', '#');


    $('playlistBackgroundi').style.backgroundColor = d['playlistBackground'].replace('0x', '#');
    $('playlistThumbBcki').style.backgroundColor = d['playlistThumbBck'].replace('0x', '#');


    //$('playlistSelectorBcki').style.backgroundColor = d['playlistSelectorBck'].replace('0x', '#');
    //$('playlistSelectorTxtOveri').style.backgroundColor = d['playlistSelectorTxtOver'].replace('0x', '#');
    //$('playlistItemsBcki').style.backgroundColor = d['playlistItemsBck'].replace('0x', '#');
    //$('playlistItemsTxtOveri').style.backgroundColor = d['playlistItemsTxtOver'].replace('0x', '#');


    //$('playlistSelectorTxtNormali').style.backgroundColor = d['playlistSelectorTxtNormal'].replace('0x', '#');
    //$('playlistSelectorTxtDowni').style.backgroundColor = d['playlistSelectorTxtDown'].replace('0x', '#');
    //$('playlistItemsTxtNormali').style.backgroundColor = d['playlistItemsTxtNormal'].replace('0x', '#');
    //$('playlistItemsTxtDowni').style.backgroundColor = d['playlistItemsTxtDown'].replace('0x', '#');

    //window.currentskin.details.playlistThumbOverAlpha = $('playlistThumbOverAlpha').value = parseFloat(d['playlistThumbOverAlpha']) * 100;
    //		alert(d['playlistBckAlpha']);
    window.currentskin.details.playlistBckAlpha = parseInt(d['playlistBckAlpha'] * 100);
    $('playlistBckAlpha').value = window.currentskin.details.playlistBckAlpha;
    //		alert($('playlistBckAlpha').value);
    //alert(parseFloat(d['playlistBckAlpha']) * 100);
    var valX = window.currentskin.details.playlistBckAlpha;
    var newV = parseInt(valX);
    if (newV > 100) {
        newV = 100;
    }
    if (newV < 0) {
        newV = 0;
    }
    $('proc_bar_diff').style.height = 100 - newV + '%';
    $('proc_bar_bg').style.height = newV + '%';
    //window.currentskin.details.playlistThumbNormalAlpha = $('playlistThumbNormalAlpha').value =  parseFloat(d['playlistThumbNormalAlpha']) * 100;
    //window.currentskin.details.playlistThumbSelectedAlpha = $('playlistThumbSelectedAlpha').value =  parseFloat(d['playlistThumbSelectedAlpha']) * 100;


    //window.currentskin.details.middlePlayBtnBckNormal = $('middlePlayBtnBckNormali').style.backgroundColor = d['middlePlayBtnBckNormal'].replace('0x', '#');
    //window.currentskin.details.middlePlayBtnArrowNormal = $('middlePlayBtnArrowNormali').style.backgroundColor = d['middlePlayBtnArrowNormal'].replace('0x', '#');
    //window.currentskin.details.middlePlayBtnBckOver = $('middlePlayBtnBckOveri').style.backgroundColor = d['middlePlayBtnBckOver'].replace('0x', '#');
    //window.currentskin.details.middlePlayBtnArrowOver = $('middlePlayBtnArrowOveri').style.backgroundColor = d['middlePlayBtnArrowOver'].replace('0x', '#');
    //window.currentskin.details.middlePlayBtnBckDown = $('middlePlayBtnBckDowni').style.backgroundColor = d['middlePlayBtnBckDown'].replace('0x', '#');
    //window.currentskin.details.middlePlayBtnArrowDown = $('middlePlayBtnArrowDowni').style.backgroundColor = d['middlePlayBtnArrowDown'].replace('0x', '#');


    //window.currentskin.details.middlePlayBtnAlphaNormal = $('middlePlayBtnAlphaNormal').value = parseFloat(d['middlePlayBtnAlphaNormal']) * 100;
    //window.currentskin.details.middlePlayBtnAlphaOver = $('middlePlayBtnAlphaOver').value =  parseFloat(d['middlePlayBtnAlphaOver']) * 100;
    //window.currentskin.details.middlePlayBtnAlphaDown = $('middlePlayBtnAlphaDown').value =  parseFloat(d['middlePlayBtnAlphaDown']) * 100;
		
    window.currentskin.details.watermarkAlpha =  parseFloat(d['watermarkAlpha']) * 100;
    valX = window.currentskin.details.watermarkAlpha;
    var newV = parseInt(valX);
    if (newV > 100) {
        newV = 100;
    }
    if (newV < 0) {
        newV = 0;
    }
    $('proc_bar_diff2').style.height = 100 - newV + '%';
    $('proc_bar_bg2').style.height = newV + '%';
    if (document.getElementById('watermarkAlpha') )
    {
        $('watermarkAlpha').value = window.currentskin.details.watermarkAlpha;
    }
		
    if (window.currentskin.watermark != '')
    {
        //show the pic
        var currentTime = new Date();
        var t = currentTime.getTime();
        $('watermarkText').innerHTML = 'Current image: <img src="'+window.currentskin.watermark+'?'+t+'" style="height: 50px; max0width:190px; vertical-align:middle"/>';
    } else {
        $('watermarkText').innerHTML = "Please upload a picture.";
    }


    //styles
    /*if (d['buttonStyle'] != 2)
		{
			$('shape1').className = "radio checked";
			window.currentskin.buttonStyle1 = 1;

			$('shape2').className = "radio";
			window.currentskin.buttonStyle2 = 0;
		} else {
			$('shape1').className = "radio";
			window.currentskin.buttonStyle1 = 0;

			$('shape2').className = "radio checked";
			window.currentskin.buttonStyle2 = 1;
		}*/
		
    if (typeof d['buttonStyle'] != 'undefined') {
        currTheme = getCTheme('buttonStyle' + d['buttonStyle']);
		
    }
    else {
        currTheme = getCTheme('buttonStyle1');
    }
		
    if (d['buttonStyle'] == 1) {
        $('shape1').className = "radio checked";
        window.currentskin.buttonStyle1 = 1;
    }else {
			
    }
		
    if (d['buttonStyle'] == 1)
    {
        $('shape1').className = "radio checked";
        window.currentskin.buttonStyle1 = 1;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;

        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;	
			
        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;
			
        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;		
/*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;	        */
    }
		
    if (d['buttonStyle'] == 2)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio checked";
        window.currentskin.buttonStyle2 = 1;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;
			
        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;		
			
        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;	
			
        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;	
        /*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;        */
    }
		
    if (d['buttonStyle'] == 3)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio checked";
        window.currentskin.buttonStyle3 = 1;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;

        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;	

        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;	

        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;		
/*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;        */
    }
		
    if (d['buttonStyle'] == 4)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio checked";
        window.currentskin.buttonStyle4 = 1;
			
        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;				
			
        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;	

        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;	
/*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;        */
    }
		
    if (d['buttonStyle'] == 5)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;
			
        $('shape5').className = "radio checked";
        window.currentskin.buttonStyle5 = 1;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;		
			
        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;	

        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;	
/*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;        */
    }		
		
    if (d['buttonStyle'] == 6)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;
			
        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio checked";
        window.currentskin.buttonStyle6 = 1;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;		
			
        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;		

        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;	
/*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;        */
    }		
		
    if (d['buttonStyle'] == 7)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;
			
        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio checked";
        window.currentskin.buttonStyle7 = 1;		
			
        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;	

        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;	
/*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;        */
    }
    if (d['buttonStyle'] == 8)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;
			
        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;		
			
        $('shape8').className = "radio checked";
        window.currentskin.buttonStyle8 = 1;		

        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;	
/*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;        */
    }
		
    if (d['buttonStyle'] == 9)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;
			
        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;		
			
        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;		

        $('shape9').className = "radio checked";
        window.currentskin.buttonStyle9 = 1;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;	
/*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;        */
    }
		
    if (d['buttonStyle'] == 10)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;
			
        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;		
			
        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;		

        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio checked";
        window.currentskin.buttonStyle10 = 1;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;	
/*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;        */
    }

    if (d['buttonStyle'] == 11)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;
			
        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;		
			
        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;		

        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio checked";
        window.currentskin.buttonStyle11 = 1;
/*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;        */
    }		
    
    if (d['buttonStyle'] == 12)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;
			
        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;		
			
        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;		

        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;
/*
        $('shape12').className = "radio checked";
        window.currentskin.buttonStyle12 = 1;	
        
        $('shape13').className = "radio";
        window.currentskin.buttonStyle13 = 0;        */
    }    
    
    if (d['buttonStyle'] == 13)
    {
        $('shape1').className = "radio";
        window.currentskin.buttonStyle1 = 0;

        $('shape2').className = "radio";
        window.currentskin.buttonStyle2 = 0;
			
        $('shape3').className = "radio";
        window.currentskin.buttonStyle3 = 0;
			
        $('shape4').className = "radio";
        window.currentskin.buttonStyle4 = 0;
			
        $('shape5').className = "radio";
        window.currentskin.buttonStyle5 = 0;

        $('shape6').className = "radio";
        window.currentskin.buttonStyle6 = 0;

        $('shape7').className = "radio";
        window.currentskin.buttonStyle7 = 0;		
			
        $('shape8').className = "radio";
        window.currentskin.buttonStyle8 = 0;		

        $('shape9').className = "radio";
        window.currentskin.buttonStyle9 = 0;	
			
        $('shape10').className = "radio";
        window.currentskin.buttonStyle10 = 0;	
			
        $('shape11').className = "radio";
        window.currentskin.buttonStyle11 = 0;
	/*
        $('shape12').className = "radio";
        window.currentskin.buttonStyle12 = 0;	
        
        $('shape13').className = "radio checked";
        window.currentskin.buttonStyle13 = 1;        */
    }    
		
    //general
    //		checkSD();
    if (d['autoResize'] == 1)
    {
        //			$('autoResizecheck').className = "checkbox on";
        $('wh').style.visibility = 'hidden';
        var childs = $('wh').childNodes;
        try {
            for (i in childs) {
                if (typeof childs[i] == "object") {
                    childs[i].style.visibility = 'hidden';
                }
            }
        } catch(e){}
        //$('bd').style.visibility = 'hidden';
        var childs = $('bd').childNodes;
        try {
            for (i in childs) {
                if (typeof childs[i] == "object") {
                    childs[i].style.visibility = 'hidden';
                }
            }
        } catch(e){}
        //$('pd').style.visibility = 'hidden';
        var childs = $('pd').childNodes;
        try {
            for (i in childs) {
                if (typeof childs[i] == "object") {
                    childs[i].style.visibility = 'hidden';
                }
            }
        } catch(e){}
        window.currentskin.details.autoResize = 1;

        window.currentskin.details.playerHeight = 0;
        window.currentskin.details.playerWidth = 0;


        var sel = document.getElementById('auto_rezolution');
			
			
			
        document.getElementById('skin2ddi').value = sel.innerHTML;
        document.getElementById('skin2ddt').innerHTML = sel.innerHTML;
        $('skin2ddi').onblur();

    } else {
        //$('autoResizecheck').className = "checkbox";
        var set_resize_select = 0;
			
        switch (d['playerWidth'])
        {
            case '240':
                if (d['playerHeight']== '180')	{
                    set_resize_select = 1;	
                    var sel = document.getElementById('very_small_rezolution_sd');
                    document.getElementById('skin2ddi').value = sel.innerHTML;
                    document.getElementById('skin2ddt').innerHTML = 'SD (4:3)';
                    $('skin2ddi').onblur();
                //						checkSD();
                }
                if (d['playerHeight']== '135')	{
                    set_resize_select = 1;	
                    var sel = document.getElementById('very_small_rezolution_hd');
                    document.getElementById('skin2ddi').value = sel.innerHTML;
                    document.getElementById('skin2ddt').innerHTML = 'HD (16:9)';
                    $('skin2ddi').onblur();
                //						checkHD();
                }
					
                break;
            case '360':
                if (d['playerHeight']== '270')	{
                    set_resize_select = 1;
                    var sel = document.getElementById('small_rezolution_sd');
                    document.getElementById('skin2ddi').value = sel.innerHTML;
                    document.getElementById('skin2ddt').innerHTML = 'SD (4:3)';
                    $('skin2ddi').onblur();
                //						checkSD();
                }
                if (d['playerHeight']== '203')	{
                    set_resize_select = 1;
                    var sel = document.getElementById('small_rezolution_hd');
                    document.getElementById('skin2ddi').value = sel.innerHTML;
                    document.getElementById('skin2ddt').innerHTML = 'HD (16:9)';
                    $('skin2ddi').onblur();
                //						checkHD();
                }
                break;
            case '480':
                if (d['playerHeight']== '360')	{
                    set_resize_select = 1;
                    var sel = document.getElementById('medium_rezolution_sd');
                    document.getElementById('skin2ddi').value = sel.innerHTML;
                    document.getElementById('skin2ddt').innerHTML = 'SD (4:3)';
                    $('skin2ddi').onblur();
                //						checkSD();
                }
                if (d['playerHeight']== '270')	{
                    set_resize_select = 1;
                    var sel = document.getElementById('medium_rezolution_hd');
                    document.getElementById('skin2ddi').value = sel.innerHTML;
                    document.getElementById('skin2ddt').innerHTML = 'HD (16:9)';
                    $('skin2ddi').onblur();
                //						checkHD();
                }
                break;
            case '640':
                if (d['playerHeight']== '480')	{
                    set_resize_select = 1;
                    var sel = document.getElementById('large_rezolution_sd');
                    document.getElementById('skin2ddi').value = sel.innerHTML;
                    document.getElementById('skin2ddt').innerHTML = 'SD (4:3)';
                    $('skin2ddi').onblur();
                //						checkSD();
                }
                if (d['playerHeight']== '360')	{
                    set_resize_select = 1;
                    var sel = document.getElementById('large_rezolution_hd');
                    document.getElementById('skin2ddi').value = sel.innerHTML;
                    document.getElementById('skin2ddt').innerHTML = 'HD (16:9)';
                    $('skin2ddi').onblur();
                //						checkHD();
                }
                break;
            case '800':
                if (d['playerHeight']== '600')	{
                    set_resize_select = 1;
                    var sel = document.getElementById('very_large_rezolution_sd');
                    document.getElementById('skin2ddi').value = sel.innerHTML;
                    document.getElementById('skin2ddt').innerHTML = 'SD (4:3)';
                    $('skin2ddi').onblur();
                //						checkSD();
                }
                if (d['playerHeight']== '450')	{
                    set_resize_select = 1;
                    var sel = document.getElementById('very_large_rezolution_hd');
                    document.getElementById('skin2ddi').value = sel.innerHTML;
                    document.getElementById('skin2ddt').innerHTML = 'HD (16:9)';
                    $('skin2ddi').onblur();
                //						checkHD();
                }
                break;
        }
        if (!set_resize_select)
        {
            document.getElementById('skin2ddi').value = 'custom';
            document.getElementById('skin2ddt').innerHTML = 'custom';
            $('skin2ddi').onblur();
        }
        $('wh').style.visibility = 'visible';
        var childs = $('wh').childNodes;
        try {
            for (i in childs) {
                if (typeof childs[i] == "object") {
                    childs[i].style.visibility = 'visible';
                }
            }
        } catch(e){}
        $('bd').style.visibility = 'visible';
        var childs = $('bd').childNodes;
        try {
            for (i in childs) {
                if (typeof childs[i] == "object") {
                    childs[i].style.visibility = 'visible';
                }
            }
        } catch(e){}
        $('pd').style.visibility = 'visible';
        var childs = $('pd').childNodes;
        try {
            for (i in childs) {
                if (typeof childs[i] == "object") {
                    childs[i].style.visibility = 'visible';
                }
            }
        } catch(e){}
        window.currentskin.details.autoResize = 0;
        $('playerHeight').value = d['playerHeight'];
        $('playerWidth').value = d['playerWidth'];

        window.currentskin.details.playerHeight = d['playerHeight'];
        window.currentskin.details.playerWidth = d['playerWidth'];
    }
 		
    if (d['autoLoad'] == 1)
    {
        $('autoLoadcheck').className = "checkbox on";
        window.currentskin.details.autoLoad = 1;
    }
    else {
        $('autoLoadcheck').className = "checkbox";
        window.currentskin.details.autoLoad = 0;
    }
		
    if (d['autoPlay'] == 1)
    {
        $('autoPlaycheck').className = "checkbox on";
        window.currentskin.details.autoPlay = 1;
    }
    else {
        $('autoPlaycheck').className = "checkbox";
        window.currentskin.details.autoPlay = 0;
    }

    if (d['playContinuously'] == 1)
    {
        $('playContinuouslycheck').className = "checkbox on";
        window.currentskin.details.playContinuously = 1;
    }
    else {
        $('playContinuouslycheck').className = "checkbox";
        window.currentskin.details.playContinuously = 0;
    }

    if (d['random'] == 1)
    {
        $('randomcheck').className = "checkbox on";
        window.currentskin.details.random = 1;
    }
    else {
        $('randomcheck').className = "checkbox";
        window.currentskin.details.random = 0;
    }

    if (d['showMiddlePlayBtn'] == 1)
    {
        //$('showMiddlePlayBtncheck').className = "checkbox on";
        window.currentskin.details.showMiddlePlayBtn = 1;
    }
    else {
        //$('showMiddlePlayBtncheck').className = "checkbox";
        window.currentskin.details.showMiddlePlayBtn = 0;
    }



    if (d['showPreviewImage'] == 1)
    {
        //$('showPreviewImagecheck').className = "checkbox on";
        window.currentskin.details.showPreviewImage = 1;
    }
    else {
        //$('showPreviewImagecheck').className = "checkbox";
        window.currentskin.details.showPreviewImage = 0;
    }

    if (d['showWatermark'] == 1)
    {
        //uncomment later
        //$('vp_holder').setParameter('showWatermark', true);
        $('showWatermarkcheck').className = "checkbox on";
        window.currentskin.details.showWatermark = 1;
    }
    else {
        //uncomment later
        //$('vp_holder').setParameter('showWatermark', false);
        $('showWatermarkcheck').className = "checkbox";
        window.currentskin.details.showWatermark = 0;
    }
		
    //		alert(d['watermarkLinkEnabled']);
		
    if (d['watermarkLinkEnabled'] == 1)
    {
        $('watermarkLinkEnabled').className = "checkbox on";
    //window.currentskin.details.showWatermark = 1;
    }
    else {
        $('watermarkLinkEnabled').className = "checkbox";
    //window.currentskin.details.showWatermark = 0;
    }


    if (d['cBarAutoHide'] == 1) {
        $('buttonsAutoHidecheck').className = "checkbox on";
        window.currentskin.details.cBarAutoHide = 1;
        window.currentskin.details.cBarHideDelay = d['cBarHideDelay'];
        $('cBarHideDelay').value = d['cBarHideDelay'];
			
        $('cBarHideDelay').disabled = false;
    }
    else {
        $('buttonsAutoHidecheck').className = "checkbox";
        window.currentskin.details.cBarAutoHide = 0;
        window.currentskin.details.cBarHideDelay = d['cBarHideDelay'];
        $('cBarHideDelay').value = d['cBarHideDelay'];
        $('cBarHideDelay').disabled = true;
    }

    if (d['playlistAutoHide'] == 1)
    {
        $('playlistAutoHidecheck').className = "checkbox on";
        window.currentskin.details.playlistAutoHide = 1;
        window.currentskin.details.playlistHideDelay = d['playlistHideDelay'];
        $('playlistHideDelay').value = d['playlistHideDelay'];
        $('playlistHideDelay').disabled = false;
    }
    else {
        $('playlistAutoHidecheck').className = "checkbox";
        window.currentskin.details.playlistAutoHide = 0;
        window.currentskin.details.playlistHideDelay = d['playlistHideDelay'];
        $('playlistHideDelay').value = d['playlistHideDelay'];
        $('playlistHideDelay').disabled = true;
    }

    if (d['hideTitle'] == 1)
    {
        $('hideTitlecheck').className = "checkbox on";
        window.currentskin.details.hideTitle = 1;
    }
    else {
        $('hideTitlecheck').className = "checkbox";
        window.currentskin.details.hideTitle = 0;
    }		
		
    if (d['hideToolbar'] == 1)
    {
        $('hideToolbarcheck').className = "checkbox on";
        window.currentskin.details.hideToolbar = 1;
    }
    else {
        $('hideToolbarcheck').className = "checkbox";
        window.currentskin.details.hideToolbar = 0;
    }				
		
    //dropdown
    /*if (d['playlistHideType'] == 1)
		$('skin1ddt').innerHTML = "Fade";

		if (d['playlistHideType'] == 2)
		$('skin1ddt').innerHTML = "Slide";*/

    $('skin1ddt').innerHTML = d['playlistHideType'];
    window.currentskin.details.playlistHideType = d['playlistHideType'];
		
    $('skin3ddt').innerHTML = d['playlistPos'];
    window.currentskin.details.playlistPos = d['playlistPos'];		
		
    //watermark position
    if (d['watermarkPos'])
    {
        var v = d['watermarkPos'].substring(0, 1);
        var h = d['watermarkPos'].substring(1);

        currentskin.verticalplacement = v;
        currentskin.horizontalplacement = h;

        /* 			$('leftradio').className = "radio";
			$('centerradio').className = "radio";
			$('rightradio').className = "radio";

			$('topradio').className = "radio";
			$('middleradio').className = "radio";
			$('bottomradio').className = "radio";

			$('rightradio').className = "radio"; */
			
        $('pos1').className = 'radio';
        $('pos2').className = 'radio';
        $('pos3').className = 'radio';
        $('pos4').className = 'radio';
        $('pos5').className = 'radio';

        if (v == "T") {
            if (h == "L")
                $('pos3').className = "radio checked";
            if (h == "R")
                $('pos2').className = "radio checked";
        }
        if (v == "M" && h == "C") {
            $('pos5').className = "radio checked";
        }
        if (v == "B"){
            if (h == "L")
                $('pos4').className = "radio checked";
            if (h == "R")
                $('pos1').className = "radio checked";
        }
    }
		
    if (window.makethumb)
    {
        window.makethumb = false;
        generateSkin();
    }
    $('toolbarButton').innerHTML = editToolbarText;
		
    if ($('csCur')) {
        $S('csCur').top = '106px';
        $S('csCur').left = '106px';
    }
}

/* function selectSkin(id)
{
	var t = $('skinstable').lastChild;
	var j = 1;
	var ok = true;
	for (i in t.childNodes)
	{
		try {
			if (t.childNodes[i].tagName != "TR")
			t.removeChild(t.childNodes[i]);
		} catch(e){}
	}
	for (i=0;i < t.childNodes.length; i++)
	{

		try {
			t.childNodes[i].className = '';

			var a = parseInt(t.childNodes[i].getAttribute('rel'));
			if (a == id)
			{
				var object = t.childNodes[i];
			}
			if (j == t.childNodes.length)
			{
				if (t.childNodes[i].getAttribute('rel') == id)
				{
					t.childNodes[i].className = 'selected last_tr';
					ok = false;
				} else {
					t.childNodes[i].className = 'last_tr';
				}
			}

			j ++;
		} catch(e) {}
	}
	try {
	if (ok )
		if (object)
		object.className='selected';
		
	} catch(e) {}
} */



function editSkin(id)
{
    if (checkForChanges())
    {
        GET(''+langLink+'/skins/getskin/?id='+id, 'showSkinDetails');
        showNotification("Loading...");
    } else {
        document.perform = "GET('"+langLink+"/skins/getskin/?id="+id+"', 'showSkinDetails');";
        var name = $('skinname').value;
        createModal(youHaveMadeChanges+' "'+name+'" '+skinText+' <br />'+ifYouContinueText+' <br />'+areYouSureYouWant, 'document.modified = 0; eval(document.perform); createModal();', 'createModal()', 'Abort changes');
    }
}

function getSkinDetails(id) {
    GET(''+langLink+'/skins/getskin/?id='+id, 'loadSkinDetails');
}

function loadSkinDetails(text) {
    currentskin = eval(text);
}

function deleteSkin(id, confirm)
{
    if (!confirm)
    {
        var t = $('skinstable').lastChild;

        for (var i in t.childNodes)
        {
            try {
                if (t.childNodes[i].getAttribute('rel') == id)
                {
                    var name = t.childNodes[i].getAttribute('search');
                }
            } catch(e){}
        }
        createModal(areYouSureYouWantToDeleteText+' <br />"'+name+'"?', 'deleteSkin('+id+', 1);createModal()', 'createModal()', deleteSkinText);
    }

    if (confirm)
    {
        var t = $('skinstable').lastChild;

        for (var i in t.childNodes)
        {
            try {
                if (t.childNodes[i].getAttribute('rel') == id)
                {
                    var skin = getskin(id);
                    if (skin.defaultskin == 1)
                    {
                        showRedNotification(youCannotDelete, 1);
                        return;
                    } 
                    else 
                    {
                        t.removeChild(t.childNodes[i]);
                        GET('/skins/delete/?id='+id, "showNotification('"+skinDeletedText+"', 1);GET('/skins/list', 'displaySkins');");
                        if (currentskin.id == id)
                        {
                            //reset
                            window.setTimeout('newSkin()', 1000);
                        }
                    }
                }
            }catch(e){}
        }
        document.selectedskin = 0;
    }
}


function getskin(id)
{
    for (i in window.allskins)
    {
		
        if (allskins[i].id == id)
        {
            return allskins[i];
        }
    }
}

function selectSkin(id)
{
    var skins = window.allskins;
    var a = '';
    for (i in skins)
    {
        var p = skins[i];
        if (typeof p == "object")
        {
            classn = "";
            if (id == p.id)
                classn = "selected";
            if (i == skins.length -1 && id == p.id)
                classn = "last_tr selected";
            else if (i == skins.length -1)
                classn = "last_tr";

            if (p.title.length > 25) var skinname = p.title.substring(0,25)+"..."; else var skinname = p.title;

            classn = "";
            if (id == p.id)
                classn = "selected";
            if (i == skins.length -1 && id == p.id)
                classn = "last_tr selected";
            else if (i == skins.length -1)
                classn = "last_tr";

            var img = "skin_not_used";
            if (p['used'] == 1) img = "skin_used_in_1";
            if (p['used'] > 1) img = "skin_shared";

            p.description = p.description.replace("\r\n", "");
            p.description = p.description.replace("\n", "");
            if (p.description.length > 50) p.description = p.description.substring(0, 50)+"...";

			
			
            var w = p.playerWidth;
            var h = p.playerHeight;
			
            var onclick1 = '';
            if (p['defaultskin'] == 1) {
                onclick1 = 'onclick="showRedNotification(\'You cannot modify a default skin.\', 1);"';
            }else {
                onclick1 = 'onclick="editName('+p['id']+');"';
            }
			
            if (p.description.length > 0) var description = p.description; else var description = "&nbsp;";
            a += '<tr rel="'+p.id+'" search="'+p.title+'" class="'+classn+'">\
                    	<td width="44" align="center"><img src="/images/'+img+'.png" alt="" /></td>\
                        <td width="216" class="text_blue"><div class="pad3">\
                        	<a href="javascript: editSkin('+p['id']+');" id="inputName-'+p['id']+'">'+skinname+'</a>\
                        	<input type="text" class="inputChangeName" id="inputNameSelect-'+p['id']+'" value="'+skinname+'" onkeyup="checkEnter(event,\''+p['id']+'\',\'skins\');"/>\
                        </div></td>\
                        <td width="134">\
                            <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                                <tr>\
                                    <td width="33%"><a href="javascript: void(0)" '+onclick1+'><img src="/images/edit.png" width="13" height="16" alt="'+editText+'" title="'+editText+'" /></a></td>\
                                    <td width="33%"><a href="javascript: deleteSkin('+p['id']+');"><img src="/images/delete.png" width="16" height="17" alt="'+deleteText+'" title="'+deleteText+'" /></a></td>\
                                    <td width="33%"><a href="javascript: validateSkinDuplication('+p['id']+');"><img src="/images/duplicate.png" width="15" height="17" alt="'+duplicateText+'" title="'+duplicateText+'" /></a></td>\
                                </tr>\
                            </table>\
                        </td>\
                        <td width="500" class="text3">\
                            <div class="pad3">'+description+'</div>\
                        </td>\
                        <td align="center" class="no_border" colspan="2">\
                            <a href="javascript: previewSkin(\''+p['txtid']+'\', '+w+', '+h+');"><img src="/images/preview.png" width="24" height="14" alt="'+previewText+'" title="'+previewText+'" /></a>\
                        </td>\
                    </tr>\
		        ';
        }
    }
    $('scroll1').innerHTML = '<table cellpadding="0" cellspacing="0" border="0" class="players line_h1 resizable" id="skinstable">\
	<tr class="title">\
	                             <td width="44" style="border-left:#bdbdbd solid 1px;">&nbsp;</td>\
                                <td style="width: 216px;">Name</td>\
                                <td width="134">Actions</td>\
                                <td style="width:475px;">Skin Info</td>\
                                <td style="border-right:#bdbdbd solid 1px;" class="no_border">Preview</td>\
                              </tr>\
	'+a+'</tbody></table>';
	
    TableKit.Resizable.init($('skinstable'), {});
}
function displaySkins(text)
{
    skins = null;
    eval(text);
    allskins = skins;

    var t = $('skinstable');
    var d = $('scrollholder1');
    while (t.hasChildNodes())
    {
        t.removeChild(t.firstChild)
    }
    var tb = document.createElement('tbody');
    t.appendChild(tb);

    try {
        $('track1').parentNode.removeChild($('track1'));
    } catch(e) {}

    var a = "";
    for (i in skins)
    {
        var p = skins[i];
        if (typeof p == "object")
        {
            classn = "";
            if (document.selectedskin == p.id)
                classn = "selected";
            if (i == skins.length -1 && document.selectedskin == p.id)
                classn = "last_tr selected";
            else if (i == skins.length -1)
                classn = "last_tr";
			
            if (p.title.length > 25) var skinname = p.title.substring(0,25)+"..."; else var skinname = p.title;

            classn = "";
            if (document.selectedskin == p.id)
                classn = "selected";
            if (i == skins.length -1 && document.selectedskin == p.id)
                classn = "last_tr selected";
            else if (i == skins.length -1)
                classn = "last_tr";

            var img = "skin_not_used";
            if (p['used'] == 1) img = "skin_used_in_1";
            if (p['used'] > 1) img = "skin_shared";

            p.description = p.description.replace("\r\n", "");
            p.description = p.description.replace("\n", "");
            if (p.description.length > 50) p.description = p.description.substring(0, 50)+"...";

			
            if (parseInt(p.autoResize) == 0)
            {
                var w = p.playerWidth;
                var h = p.playerHeight;
            } else {
                w = 473;
                h = 340;
            }
            var onclick1 = '';
            if (p['defaultskin'] == 1) {
                onclick1 = 'onclick="showRedNotification(\'You cannot modify a default skin.\', 1);"';
            }else {
                onclick1 = 'onclick="editName('+p['id']+');"';
            }
			
            if (p.description.length > 0) var description = p.description; else var description = "&nbsp;";
            a += '<tr rel="'+p.id+'" search="'+p.title+'" class="'+classn+'">\
                    	<td width="44" align="center"><img src="/images/'+img+'.png" alt="" /></td>\
                        <td width="216" class="text_blue"><div class="pad3">\
                        	<a href="javascript: editSkin('+p['id']+');" id="inputName-'+p['id']+'">'+skinname+'</a>\
                        	<input type="text" class="inputChangeName" id="inputNameSelect-'+p['id']+'" value="'+skinname+'" onkeyup="checkEnter(event,\''+p['id']+'\',\'skins\');"/>\
                        </div></td>\
                        <td width="134">\
                            <table cellpadding="0" cellspacing="0" border="0" width="100%">\
                                <tr>\
                                    <td width="33%"><a href="javascript: void(0);" '+onclick1+'><img src="/images/edit.png" width="13" height="16" alt="Edit" title="Edit" /></a></td>\
                                    <td width="33%"><a href="javascript: deleteSkin('+p['id']+');"><img src="/images/delete.png" width="16" height="17" alt="Delete" title="Delete" /></a></td>\
                                    <td width="33%"><a href="javascript: duplicateSkin('+p['id']+');"><img src="/images/duplicate.png" width="15" height="17" alt="Duplicate" title="Duplicate" /></a></td>\
                                </tr>\
                            </table>\
                        </td>\
                        <td width="500" class="text3">\
                            <div class="pad3">'+description+'</div>\
                        </td>\
                        <td align="center" class="no_border" colspam="2">\
                            <a href="javascript: previewSkin(\''+p['txtid']+'\', '+w+', '+h+');"><img src="/images/preview.png" width="24" height="14" alt="Preview" title="Preview" /></a>\
                        </td>\
                    </tr>\
		        ';
        }
    }
    $('scroll1').innerHTML = '<table id="skinstable" class="players line_h1 resizable" cellspacing="0" cellpadding="0" border="0"><tbody>\
	<tr class="title">\
		<td width="44" style="border-left:#bdbdbd solid 1px;">&nbsp;</td>\
        <td style="width: 216px;">Name</td>\
        <td width="134">Actions</td>\
        <td style="width:475px;">Skin Info</td>\
        <td style="border-right:#bdbdbd solid 1px;" class="no_border">Preview</td>\
	</tr>\
	'+a+'</tbody></table>';
    //tb.innerHTML = a;
    /*if (skins.length > 13)
	{
		d.style.height = "517px";
		document.No = 1;
		ScrollLoad("scrollholder1", "scroll1", true);
	}
	else {
		dw_scrollObj.initScroll('scrollholder1', "up");*/
    d.style.height = (47*skins.length + 47) +"px";
    /*	removeMouseWheeleScrolling('scrollholder1');
	}*/

    if (document.godown)
        moveDown($('scrollholder1'), 1);

    document.godown = false;
    if (document.selectedskin)
        selectSkin(document.selectedskin);
	
    TableKit.Resizable.init($('skinstable'), {});
    if (window.functionCall != '') {
        eval(window.functionCall);
        window.functionCall = '';
    }
}


function newSkin()
{
    if (checkForChanges())
    {
        showNotification(loadedDefaultText,1);
        getSkinDefaults();
        $('playerWidth').value = 473;
        $('playerHeight').value = 340;		
        selectSkin(0);
        window.location.href="#";
    }
    else {
        //document.peform = 'resetPlayerForm()';
        var name = $('skinname').value;
        createModal(youHaveMadeChanges+' "'+name+'" '+skinText+' <br />'+ifYouContinueText+' <br />'+areYouSureYouWant, 'document.modified = 0; newSkin(); createModal();', 'createModal()', 'Abort changes');
    }

}

function getSkinDefaults()
{
    GET(''+langLink+'/skins/getdefaults/', 'showSkinDetails');
}

function validateSkinDuplication(id) {
    if (checkForChanges()) {
        window.setTimeout("duplicateSkin("+id+")", 1000);
    } else {
        document.perform = 'window.setTimeout("duplicateSkin('+id+')", 1000)';
        createModal(youHaveMadeChangesToThe+' <br />'+ifYouContinueText+' <br />'+areYouSureYouWant, 'document.modified = 0; eval(document.perform); createModal();', 'createModal()', 'Abort changes');
    }	
}

function duplicateSkin(id, confirm)
{
    var name = "";
	
    if (!confirm)
    {
        for (i in allskins)
        {
            if (typeof allskins[i] == "object")
            {
                if (allskins[i]['id'] == id)
                    var name = allskins[i]['title'];
            }
        }

        var search = "Copy of "+name;
        createModal(pleaseEnterANewNameText+'<br /><input type="text" onfocus="autoSelect(this)" name="newskinname" id="newskinname" value="'+search+'" />' , 'duplicateSkin("'+id+'", 1);', 'createModal()', duplicateText);
        document.getElementById('newskinname').focus();
    } else {
        window.duplicatedSkin = true;
        var newname = document.getElementById('newskinname').value;
        if ($('warning').style.display == "block") {
            createModal();
        }		
        if (checkDuplicateSkinName(newname)) {
            createModal('You already have a skin named "'+newname+'"<br/>'+pleaseEnterANewNameText+'<br /><input type="text" onfocus="autoSelect(this)" name="newskinname" id="newskinname" value="" />' , 'duplicateSkin("'+id+'", 1);', 'createModal()', duplicateText);
            document.getElementById('newskinname').focus();
        }
        else {
            GET('/skins/newskin/?name='+newname+'&id='+id, 'insertSkin');
            showNotification(savingSkinText, 1);
        }
    }
}

function getSkinNames() {
    var names = new Array;
	
    if (typeof allskins != 'undefined') {
        for (var i in allskins) {
            if (typeof allskins[i].title != 'string') {
                continue;
            }
            names.push(allskins[i].title);
        }
    }
	
    return names;
}

function checkDuplicateSkinName(sName) {
    var names = getSkinNames();
	
    for (var i in names) {
        if (typeof names[i] != 'string') {
            continue;
        }
        if (sName == names[i]) {
            return true;
        }
    }
    return false;
}

function saveSkin(confirm)
{
    //if (($('skinname').value.trim().length == 0 || $('skinname').value.trim() == 'Name' || checkDuplicateSkinName($('skinname').value.trim())) && !confirm)
    if (($('skinname').value.trim().length == 0 || $('skinname').value.trim() == 'Name') && !confirm)
    {
        document.perform = "saveSkin(1);";
        if ($('warning').style.display == "block") {
            createModal();
        }
        createModal(pleaseEnterNewName+'<br /><input type="text" id="newskinname" />', 'eval(document.perform);', 'createModal()', 'Skin name');
        $('newskinname').focus();
        return 0;
    } 
    else {
        if ($('newskinname') && $('newskinname').value.trim().length > 0)
        {
            //checking for duplicate names
            if (checkDuplicateSkinName($('newskinname').value.trim())) {
                document.perform = "saveSkin(1);";
                if ($('warning').style.display == "block") {
                    createModal();
                }
                createModal(pleaseEnterNewName+'<br /><input type="text" id="newskinname" />', 'eval(document.perform);', 'createModal()', 'Skin name');
                $('newskinname').focus();
                return 0;
            } 		
			
            $('newskinname').value = $('newskinname').value.trim();
            currentskin.title = $('newskinname').value.trim();
            if ($('warning').style.display == "block")
            {
                createModal();
            }
        }
        else
        if ($('skinname').value.length > 0)
        {
            $('skinname').value = $('skinname').value.trim();
            currentskin.title = $('skinname').value.trim();
            if ($('warning').style.display == "block")
            {
                createModal();
            }
        }
        else
		
        {
            document.perform = "saveSkin(1)";
            if ($('warning').style.display == "block")
            {
                createModal();
            }
            createModal(pleaseEnterNewName+'<br /><input type="text" id="newskinname" />', 'eval(document.perform); ', 'createModal()', 'Skin name');
            return 0;
        }
    }
	
    try {
        if (currentskin.id != '' && currentskin.id != '0')
        {
            var ptype = "old";
        } else {
            var ptype = "new";
        }
    }catch(e){
        ptype = "new";
    }

    document.modified = 0;
	
	
    $('skinname').value = currentskin.title;
    /* 	$('skinname2').value = currentskin.title;
	$('skinname3').value = currentskin.title;
	$('skinname4').value = currentskin.title; */
    //currentskin.details = false;
    currentskin.description = $('description').value;
	
    currentskin.details.playlistHideDelay = $('playlistHideDelay').value;
    currentskin.details.cBarHideDelay = $('cBarHideDelay').value;
    currentskin.details.playerWidth = $('playerWidth').value;
    currentskin.details.playerHeight = $('playerHeight').value;
    currentskin.details.watermarkLink = $('watermarkLink').value;
    if ($('shareViaEmbed').className == 'checkbox on') {
        currentskin.details.shareViaEmbed = 1;
    }else {
        currentskin.details.shareViaEmbed = 0;
    }
	
    currentskin.details.playlistBckAlpha = currentskin.details.playlistBckAlpha ;
    /* 	currentskin.details.playlistThumbNormalAlpha = currentskin.details.playlistThumbNormalAlpha;
	currentskin.details.playlistThumbSelectedAlpha = currentskin.details.playlistThumbSelectedAlpha;
	currentskin.details.playlistThumbOverAlpha = currentskin.details.playlistThumbOverAlpha;
	currentskin.details.middlePlayBtnAlphaNormal = currentskin.details.middlePlayBtnAlphaNormal;
	currentskin.details.middlePlayBtnAlphaOver = currentskin.details.middlePlayBtnAlphaOver;
	currentskin.details.middlePlayBtnAlphaDown = currentskin.details.middlePlayBtnAlphaDown; */
    currentskin.details.watermarkAlpha = currentskin.details.watermarkAlpha;

    var details = currentskin.details;
	
    var cskin = currentskin;
    delete cskin.watermark;
	
    var myString = cskin.toJSONString();
    myString  = str_replace("#slide", 'slide', myString );
    myString  = str_replace("#fade", "fade", myString );
    params = "string="+str_replace("#", "0x", myString );
    params = str_replace('&', 'and', params);

    if (ptype == "old")
    {
        var aaa = getskin(currentskin.id);
        try {
            if (aaa.defaultskin == 1) {
                currentskin.id = 0;
                currentskin.details.defaultskin = 0;
                //saveSkin(1);
                saveSkinFromDefault(aaa.id, 1);

                //showRedNotification('You cannot save a system skin.', 1);
				
                return;
            }
        } catch(e) {}
        POST('/skins/saveskin/', 'document.selectedskin="'+currentskin.id+'"; GET("/skins/list", "displaySkins")',params, 1);
        showNotification(savingSkinText1+' "'+currentskin.title+'".', 1);
        $('vp_holder').generateThumbnail(94,30,currentskin.txtid);
		
    /*if (currentskin.details.autoResize == 1)
			window.setTimeout("$('vp_holder').generateThumbnail(475,342,'"+currentskin.txtid+"')", 100);
		else
			window.setTimeout("$('vp_holder').generateThumbnail("+currentskin.details.playerWidth+","+currentskin.details.playerHeight+",'"+currentskin.txtid+"')", 100);*/
    //createThumbnail
    }
    else {
        showNotification(savingSkinText1+' "'+currentskin.title+'".', 1);
        POST('/skins/saveskin/', 'insertSkin', params);
    }
}

function saveSkinFromDefault(id_default, confirm) {
    var defaultSkin = getskin(id_default);
    document.perform = 'saveSkinFromDefault("' + defaultSkin.id + '", 0);';
    document.cancel = 'currentskin.id = ' + defaultSkin.id + '; currentskin.details.defaultskin = 1;';
	
    var skinName = $('skinname').value.trim();
    $('skinname').value = skinName;
    var newSkinName = skinName;
    if ($('newskinname')) {
        newSkinName = $('newskinname').value.trim();
        $('newskinname').value = newSkinName;
    }
	
    if ($('warning').style.display == "block") {
        createModal();
    }
	
    if (confirm) {
        if (skinName.length == 0)
            createModal(pleaseEnterANewNameText+'<br /><input type="text" onfocus="autoSelect(this)" name="newskinname" id="newskinname"/>' , 'eval(document.perform)', 'eval(document.cancel); createModal()', saveSkinText);			
        else if (skinName == defaultSkin.title)
            createModal(youCannotSaveThisSkin+' <br/>'+usingTheDefaultNameText+' "' + defaultSkin.title +'".<br/> '+pleaseEnterANewNameText+'<br /><input type="text" onfocus="autoSelect(this)" name="newskinname" id="newskinname"/>' , 'eval(document.perform)', 'eval(document.cancel); createModal()', saveSkinText);			
        else
            saveSkin(1);
    }
    else {
        if (newSkinName.length == 0)
            createModal(pleaseEnterANewNameText+'<br /><input type="text" onfocus="autoSelect(this)" name="newskinname" id="newskinname"/>' , 'eval(document.perform)', 'createModal()', saveSkinText);
        else if (newSkinName == defaultSkin.title)
            createModal(youCannotSaveThisSkin+' <br/>'+usingTheDefaultNameText+' "' + defaultSkin.title +'".<br/> '+pleaseEnterANewNameText+'<br /><input type="text" onfocus="autoSelect(this)" name="newskinname" id="newskinname"/>' , 'eval(document.perform)', 'eval(document.cancel); createModal()', saveSkinText);			
        else {
            $('skinname').value = newSkinName;
            saveSkin(1);
        }			
    }
}

function insertSkin(text)
{
    if (text.indexOf("ERROR") != -1)
    {
        showRedNotification(str_replace('ERROR:', '', text), 1);
        return;
    }
    //if (parseInt(currentskin.id) == 0)
    document.selectedskin = text;
    document.godown = true;
    window.makethumb = true;
    GET('/skins/list', 'displaySkins');
    if (duplicatedSkin || parseInt(currentskin.id) == 0) {
        window.functionCall = "GET('"+langLink+"/skins/getskin/?id="+text+"', 'showSkinDetails')";
    }
}

function generateSkin()
{
    if (window.flashhasloaded)
    {
        $('vp_holder').generateThumbnail(94,30,currentskin.txtid);
    } else {
        window.setTimeout('generateSkin()', 500);	
    }
/*if (currentskin.details.autoResize == 1)
			window.setTimeout("$('vp_holder').generateThumbnail(475,342,'"+currentskin.txtid+"')", 1200);
		else
			window.setTimeout("$('vp_holder').generateThumbnail("+currentskin.details.playerWidth+","+currentskin.details.playerHeight+",'"+currentskin.txtid+"')", 1200);*/
}

function selectskin()
{
    var divs = document.getElementsByTagName('div');
    var a = new Array();
	
    /*if (vnp.videos)
	{
		for (i in vnp.videos)
		{
			if (vnp.videos[i]['id'])
			a[a.length] = vnp.videos[i]['id'];
		}
	}*/
	
    for (i in divs)
    {
        try {
            if (divs[i].getAttribute('rel') == "browseskin")
            {
        /*if ($('skinid').value == divs[i].getAttribute('itemid'))
				{
					divs[i].className = "radio mfive checked";
				}
				else
					divs[i].className = "radio mfive";*/
        }
			
        }catch(e){}
    }
}

function updateinput(object, property, bypass)
{
    eval('window.currentskin.details.'+property+' = "'+object.value+'"');
    try {
        if (property == 'playlistBckAlpha') {
            var val = $('playlistBckAlpha').value;
            if (val > 100) {
                val = 100;
            }
            if (val < 0) {
                val = 0;
            }
            $('playlistBckAlpha').value = val;
			
        }
        if (property == 'playerWidth' || property == 'playerHeight') {
            document.getElementById('skin2ddi').value = 'custom';
            document.getElementById('skin2ddt').innerHTML = 'custom';
            $('skin2ddi').onblur();
			
        }
        if (!bypass)
            $('vp_holder').setParameter(property, object.value)
    }catch(e){}
}

function restoreDefaults()
{
    if (document.selectedskin != "0" && document.selectedskin != "")
    {
        showNotification(loadingCurrentSkinDefaultText, 1);
        editSkin(document.selectedskin);
    } else {
        showNotification(loadingDefaultSkinDetailsText, 1);
        getSkinDefaults();
    }
}

function skindiss(id, v) {
    try {
        if (v == 1) {
            var dd = document.getElementById(id);
            if (dd.style.display == "block") {
                //window.clearTimeout(window.mo);
                dd.style.display="none";
                $(dd).style.zIndex = 100;
				
                if (id == 'player-size-menu') {
                    document.getElementById('skin2ddl').className='skindropdownleft';
                    document.getElementById('skin2ddt').className='skindropdowncontent';
                    document.getElementById('skin2ddr').className='skindropdownright';
                    $('wh').style.zIndex = 0;
                    $('buttonsAutoHidecheck').style.zIndex = 0;
                    $('playlistAutoHidecheck').style.zIndex = 0;
                    $('bd').style.zIndex = 0;
                    $('pd').style.zIndex = 0;
                    $('skin1').style.zIndex = 0;
					
                    if (getIEVersionNumber() >= 8) {
                        $('autohideTT').style.zIndex = 0;
                    }else {
                        $('autohideTTT').style.zIndex = 0;
                    }
                }else {
                    document.getElementById('skin1ddl').className='skindropdownleft';
                    document.getElementById('skin1ddt').className='skindropdowncontent';
                    document.getElementById('skin1ddr').className='skindropdownright';
                }
            }
        }else {
            window.window.mo = window.setTimeout("skindiss('"+id+"',1)",100);
        }
    } catch (e) {}
}

function skinddshow(id)
{
	
    var dd = document.getElementById(id+'dd');
    if (document.getElementById(id).className.indexOf('disabled') == -1)
    {
        dd.style.display="block";
        //document.getElementById(id+'ddi').src='./images/input_select_down.jpg';
        document.getElementById(id+'ddl').className='skindropdownleftpressed';
        document.getElementById(id+'ddt').className='skindropdowncontentpressed';
        document.getElementById(id+'ddr').className='skindropdownrightpressed';
        document.getElementById(id).focus();
        if (id == 'skin2') {
            try {
                $('wh').style.zIndex = -1;
                $('buttonsAutoHidecheck').style.zIndex = -1;
                $('buttonsAutoHideDelay').style.zIndex = -1;
                $('bd').style.zIndex = -1;
                $('pd').style.zIndex = -1;
            } catch (e) {}
        }
    }
}

/* function previewSkin(id, w, h)
{
	flashTogglePlay(false);
	if (!w) w = 473;
	if (!h) h = 340;
	
	w = parseInt(w);
	h = parseInt(h);
	
	$('previewmodalcontent').innerHTML = '<div id="preview"></div>';
	
	var flashvars = {
	  htmlPage: document.location,
	  settingsFile: "/skins/feedxml?id="+id+"|||notpublished"
	};
	var params = {
	  allowFullScreen: "true",
	  allowScriptAccess:"sameDomain"
	};
	
	swfobject.embedSWF("/player.swf", "preview", w, h, "9.0.115", "/swfobject/expressInstall.swf", flashvars, params);
	
	$('previewmodalcontent').style.textAlign = "left";
	//$('preview').style.textAlign = "left";
	//$('previewmodalcontent').style.paddingLeft = "6px";
	
	var thediv=document.getElementById('displayboxwarning');
	thediv.style.height = getDocHeight()+"px";
	thediv.style.position = "absolute";
	thediv.style.marginLeft = "0px";
	thediv.style.marginTop = "0px";
	thediv.style.zIndex = "1";
	thediv.style.left = "0px";
	thediv.style.top = "0px";
	thediv.style.display = "block";
	
	$('previewmodal').style.display="block";
	
	
	$('previewtopmiddle').style.width = w+'px';
	$('previewmodalcontent').style.width = w+20+'px';
	$('previewbottommiddle').style.width = w+'px';
	
	var sizes = getSize();
	if (sizes[1] > h)
		document.getElementById('previewmodal').style.top = pos() + (sizes[1] - h) / 2 + "px";
	else
		document.getElementById('previewmodal').style.top = pos() + (h - sizes[1]) / 2 + "px";

		
	
	if (sizes[0] > w)
	{
		document.getElementById('previewmodal').style.left = (sizes[0] - w) / 2 + "px";
	}
	else {
		document.getElementById('previewmodal').style.left = (w - sizes[0]) / 2 + "px";
	}
		
}
 */
/*function closeSkinPreview()
{
	$('previewparent').style.display = "none";
}*/

function abortpicker()
{
    $S('mini').display='none';
    $(window.colortarget+'i').style.background=window.lastcolor;
    document.modified = 1;
    try {
        eval('window.currentskin.details.'+window.colortarget+' = "'+str_replace('#', '', window.lastcolor)+'"')
    }catch(e){}
    $('vp_holder').setParameter(window.colortarget, str_replace('#', '', window.lastcolor))
    window.lastcolor = '';
    window.colortarget = '';
	
/*flashTogglePlay(true);
	var thediv=document.getElementById('displayboxwarning');
	thediv.style.height = "0px";
	thediv.style.display = "none";*/
}

function toolbarMode()
{
    if ($('toolbarButton').innerHTML == editToolbarText)
    {
        $('vp_holder').setParameter('authoring', 'true');
        $('toolbarButton').innerHTML = saveToolbarText;
    } else {
        $('vp_holder').setParameter('authoring', 'false');
        var buttons = $('vp_holder').getButtons();
        currentskin.details.buttons = buttons;
        $('toolbarButton').innerHTML = editToolbarText;
    }
}

function enableEditingMode(obj)
{
    if (obj.className == "checkbox on")
    {
        var buttons = $('vp_holder').getButtons();
        currentskin.details.buttons = buttons;
    //window.setTimeout("setFlashParam('buttons', '"+buttons+"')", 480);
    }
	
    document.modified = 1;
    $('vpparent').innerHTML = '<div id="vp_holder" class="vp_holder"> </div>';
    var aaa = currentskin.details;
    aaa.txtid = currentskin.txtid;
    var bbb = aaa.toJSONString();
    bbb = str_replace('#', '0x', bbb);
			
    bbb = str_replace('#', '0x', bbb);
    var flashvars = {
        htmlPage: document.location,
        settingsFile: "/skins/feedxml?id="+aaa.txtid+"|||notpublished"
    };
	
    var params = {
        allowFullScreen: "true",
        wmode: "opaque",
        allowScriptAccess:"sameDomain"
    };
	
    if (obj.className == "checkbox") {
        obj.className = "checkbox on";
        window.flashhasloaded = false;
        swfobject.embedSWF("/videoPlayer_author.swf", "vp_holder", "473", "414", "9.0.115", "/swfobject/expressInstall.swf", flashvars, params);
    } else {
        window.flashhasloaded = false;
        obj.className = "checkbox";
        swfobject.embedSWF("/videoPlayer_author.swf", "vp_holder", "473", "414", "9.0.115", "/swfobject/expressInstall.swf", flashvars, params);
    }
	
/* 	var j = 200;
	for (i in currentskin.details)
	{
		if (typeof currentskin.details[i] == "string" && i != "buttonStyle")
		{
			j = j +30;
			window.setTimeout("setFlashParam('"+i+"', '"+str_replace('0x', '', str_replace('#', '', currentskin.details[i]))+"');", j);
		}
	} */

/* 	if (currentskin.buttonStyle1 == "1")
		window.setTimeout("setFlashParam('buttonStyle', '1')", 500);
	if (currentskin.buttonStyle2 == "1")
		window.setTimeout("setFlashParam('buttonStyle', '2')", 500);
	if (currentskin.buttonStyle3 == "1")
		window.setTimeout("setFlashParam('buttonStyle', '3')", 500);
	if (currentskin.buttonStyle4 == "1")
		window.setTimeout("setFlashParam('buttonStyle', '4')", 500);
	if (currentskin.buttonStyle5 == "1")
		window.setTimeout("setFlashParam('buttonStyle', '5')", 500);
	if (currentskin.buttonStyle6 == "1")
		window.setTimeout("setFlashParam('buttonStyle', '6')", 500);
	if (currentskin.buttonStyle7 == "1")
		window.setTimeout("setFlashParam('buttonStyle', '7')", 500);		 */
}

function flashHasLoaded()
{
    window.flashhasloaded = true;
}

function setFlashParam(param, value)
{
    if (window.flashhasloaded)
    {
        $('vp_holder').setParameter(param, value);
    } else {
        window.setTimeout("setFlashParam('"+param+"', '"+value+"');", 100);
    }
}

function dealWithURL()
{
    var hash = str_replace('#', '', window.location.hash);
    var id = parseInt(hash);
	
    if (id && getskin(id))
    {
        editSkin(id);
    }
}

function setrezolution2custom (flashTarget){
    var tmpTarget = false;
    if (flashTarget)
        tmpTarget = flashTarget;
    skinddselect(document.getElementById('custom_rezolution'), 'skin2', tmpTarget);
}

function updaterezolution(object)
{
    var w = 0;
    var h = 0;
    var change =1;
    var autoenable = 0;
    //	alert(object.value.trim());
	
    if (object)
    {
        switch(object.value.trim()){ 
            case 'auto':
                autoenable = 1;
                change =0;
                break;
            case 'very small':
                w = 240;
                h = 180;
                break;
            //			case 'very small hd':
            //				w = 240;
            //				h = 135;
            //				break;
            case 'small':
                w = 360;
                h = 270;
                break;
            case 'small hd':
                w = 320;
                h = 180;
                break;
            case 'medium':
                w = 480;
                h = 360;
                break;
            case 'medium hd':
                w = 480;
                h = 270;
                break;
            case 'large':
                w = 640;
                h = 480;
                break;
            case 'large hd':
                w = 640;
                h = 360;
                break;
            case 'very large':
                w = 800;
                h = 600;
                break;
            case 'very large hd':
                w = 800;
                h = 450;
                break;
            case 'Facebook':
                w = 420;
                h = 334;
                break;
            case 'custom':
                change = 0;
                break;
            default :
                autoenable = 1;
                change =0;
                break;
			
        }

        window.currentskin.details.autoResize = autoenable;
		
		

        if (autoenable)
        {
            //try {$('vp_holder').setParameter('autoResize', 'true'); }catch(e){}
            document.getElementById('wh').style.visibility = "hidden";
            var childs = $('wh').childNodes;
            try {
                for (i in childs) {
                    if (typeof childs[i] == "object") {
                        childs[i].style.visibility = 'hidden';
                    }
                }
            } catch(e){}
        }else{
            //try {$('vp_holder').setParameter('autoResize', 'false'); }catch(e){}
            document.getElementById('wh').style.visibility = "visible";
            var childs = $('wh').childNodes;
            try {
                for (i in childs) {
                    if (typeof childs[i] == "object") {
                        childs[i].style.visibility = 'visible';
                    }
                }
            } catch(e){}
        }

        if(change)
        {
            document.getElementById('playerWidth').value = w;
            document.getElementById('playerHeight').value = h;
        }
    //document.modified = 1;
    }

}

function startFlashDrag(param)
{
    window.flashDrag = param;
}


function previewSkin(id, w, h)
{
    flashTogglePlay(false);
    if (!w) w = 473;
    if (!h) h = 340;
	
    w = parseInt(w);
    h = parseInt(h);
	
    $('previewmodalcontent').innerHTML = '<div id="preview"></div>';
	
    var flashvars = {
        htmlPage: document.location,
        settingsFile: "/skins/feedxml?id="+id+"|||notpublished"
    };
    var params = {
        allowFullScreen: "true",
        allowScriptAccess:"sameDomain"
    };
	
    swfobject.embedSWF("/player.swf", "preview", w, h, "9.0.115", "/swfobject/expressInstall.swf", flashvars, params);
	
    $('previewmodalcontent').style.textAlign = "left";
    //$('preview').style.textAlign = "left";
    //$('previewmodalcontent').style.paddingLeft = "6px";
	
    var thediv=document.getElementById('displayboxwarning2');
    thediv.style.height = getDocHeight()+"px";
    thediv.style.position = "absolute";
    thediv.style.marginLeft = "0px";
    thediv.style.marginTop = "0px";
    thediv.style.zIndex = "102";
    thediv.style.left = "0px";
    thediv.style.top = "0px";
    thediv.style.display = "block";
	
    $('previewmodal').style.display="block";
    $('previewmodal').style.zIndex="103";
	
	
    $('previewtopmiddle').style.width = w+'px';
    $('previewmodalcontent').style.width = w+20+'px';
    $('previewbottommiddle').style.width = w+'px';
	
    var sizes = getSize();
    if (sizes[1] > h)
        document.getElementById('previewmodal').style.top = pos() + (sizes[1] - h) / 2 + "px";
    else
        document.getElementById('previewmodal').style.top = pos() + (h - sizes[1]) / 2 + "px";

		
	
    if (sizes[0] > w)
    {
        document.getElementById('previewmodal').style.left = (sizes[0] - w) / 2 + "px";
    }
    else {
        document.getElementById('previewmodal').style.left = (w - sizes[0]) / 2 + "px";
    }
		
}

function enableRename(id)
{
    var inp = $(id);
    if (inp.className == "input_rename_disabled")
    {
        inp.disabled = false;
        inp.focus();
        inp.className = "input_rename_enabled";
    } 
    else {
        inp.disabled = true;
        inp.blur();
        inp.className = "input_rename_disabled";
    }
}

function openColors()
{
    if ($('csphere').style.display == 'none')
    {
        $('csphere').style.display = 'block';
        $('adv_basic').innerHTML = 'Advanced options&nbsp;<img style="border: 0; vertical-align: middle;" src="/images/skins-arrow-up.png"/>';
        $('colors').style.display = 'none';
        $('col_gradient').innerHTML = '<div class="left skin_col_arr"></div><div class="right skin_col_arr"></div>';
    }
    else
    {
        $('csphere').style.display = 'none';
        $('adv_basic').innerHTML = 'Basic options&nbsp;<img style="border: 0; vertical-align: middle;" src="/images/skins-arrow-down.png"/>';
        $('colors').style.display = 'block';
        $('col_gradient').innerHTML = '';
    }
}

/*
function checkSD() {
	if ($('sd').className != 'radio checked') {
		$('sd').className = 'radio checked';
		$('hd').className = 'radio';
		updaterezolution($('skin2ddi'));
	}
}

function checkHD() {
	if ($('sd').className != 'radio') {
		$('sd').className = 'radio';
		$('hd').className = 'radio checked';
		updaterezolution($('skin2ddi'));
	}
}*/

