function popUp(URL)
{
    day = new Date();
    id = day.getTime();
    eval("spiffyplayer = window.open(URL, 'spiffyplayer', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=275,height=275,left = 10,top = 10');");
}
function ConfirmDelete()
{
	var i=confirm("Are you sure you want to DELETE this item?");
	if(i)
	{
		return true;
	}else{
		return false;
	}
}
function ConfirmPending(type)
{
    if(type == 'approve')
	   var i=confirm("Are you sure you want to APPROVE this theme?");
	else if(type == 'disable')
	   var i=confirm("Are you sure you want to DISABLE this theme?");
	if(i)
	{
		return true;
	}else{
		return false;
	}
}
function LinkKey(passedKey, KeyNumber)
{
    if(passedKey == undefined || passedKey == '')
    {
        showKey('key5', 'BM', KeyNumber, 'linkkey');
    }
}
window.addEvent('domready', function(){
    SqueezeBox.initialize({});
    SqueezeBox.assign($$('a[rel=boxed]'));
    SqueezeBox.assign($$('a.boxed'), {
        parse: 'rel'
    });
   //store titles and text
	$$('a.tipz').each(function(element,index) {
		var content = element.get('title').split('::');
		element.store('tip:title', content[0]);
		element.store('tip:text', content[1]);
	});
    var tipz = new Tips($$('.tipz'), {
    	timeOut		: 700,
    	maxTitleChars	: 50,
    	hideDelay		: 200,
    	className		: 'tipztop', //for you yo use in the css classes being then .tip .tip-title and .tip-text
    	initialize: function() { this.tip.fade('hide'); },
        onShow		: function(tip){
    	   tip.fade('in');
    	},
		onHide: function(tip) {
			tip.fade('out');
		}
    });
    //BLightBox = new SLightBox({color:'black', find:'BLightBox', Skin:{ 'black' : { 'hexcolor': '#000000', 'captionColor': '#FFFFFF', 'background-color': '#000', 'opacity': 0.7 }}});
    //myTips.tip.set('tween',{duration: 200});
    
    Sexy = new SexyAlertBox();
    
    soundManager.url = '/incme/';
    soundManager.useFlashBlock = false;
    soundManager.defaultOptions.volume = 50;
});

window.size = function(){
	var w = 0;
	var h = 0;
	if(!window.innerWidth){
		if(!(document.documentElement.clientWidth == 0)){
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		} else {
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	} else {
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}

function loadKey(keyid){
	var keyNumber = Math.ceil(Math.random() * 5);
	var posNumber = Math.ceil(Math.random() * 8);
	var div = 'key' + keyNumber;
	switch(posNumber){
		case 1:
			position = 'TL';
			break;
		case 2:
			position = 'TM';
			break;
		case 3:
			position = 'TR';
			break;
		case 4:
			position = 'CL';
			break;
		case 5:
			position = 'CR';
			break;
		case 6:
			position = 'BL';
			break;
		case 7:
			position = 'BM';
			break;
		case 8:
			position = 'BR';
			break;
	}
	showKey(div, position, keyid);
}
function showKey(div, position, keyid, sesskey){
	filename = Math.ceil(Math.random() * 40);
    soundManager.onready(function() {
    if (soundManager.supported()) {
        UnlockSound = soundManager.createSound({
            id: 'aSound',
            url: '/incme/keysounds/'+filename+'.mp3'
        });
        UnlockSound.play();
    }
    var keyNumber = Math.ceil(Math.random() * 5);
    div = 'key' + keyNumber;
	// Send Ajax Request
	var req = new Request({
		method: 'get',
		url: 'http://spiffy360.com/keys.php',
		data: { 'keyid' : keyid, 'sesskey' : sesskey },
		onComplete: function(response)
        {
            $(div+'text').innerHTML = response;
        	var topStart = (document.all)?document.body.scrollTop:window.pageYOffset;
			var topEnd = (document.all)?document.body.scrollTop:window.pageYOffset;
			var leftStart = 0;
			var leftEnd = 0;
			switch(position){
				case 'TL':
					topStart = topStart - 80;
					topEnd = topStart + 90;
					leftStart = leftEnd = 10;
					break;
				case 'TM':
					topStart = topStart - 80;
					topEnd = topStart + 90;
					leftStart = leftEnd = (window.size().width / 2) - 213;
					break;
				case 'TR':
					topStart = topStart - 80;
					topEnd = topStart + 90;
					leftStart = leftEnd = window.size().width - 450;
					break;
				case 'CL':
					topStart = topEnd = ((window.size().height / 2) + topStart) - 34;
					leftStart = -436;
					leftEnd = 10;
					break;
				case 'CR':
					topStart = topEnd = ((window.size().height / 2) + topStart) - 34;
					leftStart = window.size().width + 10;
					leftEnd = window.size().width - 450;
					break;
				case 'BL':
					topStart = topStart + window.size().height;
					topEnd = topStart - 80;
					leftStart = leftEnd = 10;
					break;
				case 'BM':
					topStart = topStart + window.size().height;
					topEnd = topStart - 80;
					leftStart = leftEnd = (window.size().width / 2) - 213;
					break;
				case 'BR':
					topStart = topStart + window.size().height;
					topEnd = topStart - 80;
					leftStart = leftEnd = window.size().width - 450;
					break;
			}
        	//$(div).setStyle('display','block');
        	$(div).fade('in');
        	var showEffect = new Fx.Morph(div, {duration:'short'});
        	showEffect.start({
        		'top' : [topStart, topEnd],
        		'left' : [leftStart, leftEnd]
        	});
        	setTimeout('hideKey(\''+div+'\')', 6000);
		}
	}).send();
    });
}
function showKey2(div, position, keyid, sesskey){
	filename = Math.ceil(Math.random() * 40);
    soundManager.onready(function() {
    if (soundManager.supported()) {
        UnlockSound = soundManager.createSound({
            id: 'aSound',
            url: '/incme/keysounds/'+filename+'.mp3'
        });
        UnlockSound.play();
    }
    var keyNumber = Math.ceil(Math.random() * 5);
    div = 'key' + keyNumber;
	// Send Ajax Request
	var req = new Request({
		method: 'get',
		url: 'http://spiffy360.com/keys.php',
		data: { 'test' : 'testing', 'keyid' : keyid, 'sesskey' : sesskey },
		onComplete: function(response)
        {
            $(div+'text').innerHTML = response;
        	var topStart = (document.all)?document.body.scrollTop:window.pageYOffset;
			var topEnd = (document.all)?document.body.scrollTop:window.pageYOffset;
			var leftStart = 0;
			var leftEnd = 0;
			switch(position){
				case 'TL':
					topStart = topStart - 80;
					topEnd = topStart + 90;
					leftStart = leftEnd = 10;
					break;
				case 'TM':
					topStart = topStart - 80;
					topEnd = topStart + 90;
					leftStart = leftEnd = (window.size().width / 2) - 213;
					break;
				case 'TR':
					topStart = topStart - 80;
					topEnd = topStart + 90;
					leftStart = leftEnd = window.size().width - 450;
					break;
				case 'CL':
					topStart = topEnd = ((window.size().height / 2) + topStart) - 34;
					leftStart = -436;
					leftEnd = 10;
					break;
				case 'CR':
					topStart = topEnd = ((window.size().height / 2) + topStart) - 34;
					leftStart = window.size().width + 10;
					leftEnd = window.size().width - 450;
					break;
				case 'BL':
					topStart = topStart + window.size().height;
					topEnd = topStart - 80;
					leftStart = leftEnd = 10;
					break;
				case 'BM':
					topStart = topStart + window.size().height;
					topEnd = topStart - 80;
					leftStart = leftEnd = (window.size().width / 2) - 213;
					break;
				case 'BR':
					topStart = topStart + window.size().height;
					topEnd = topStart - 80;
					leftStart = leftEnd = window.size().width - 450;
					break;
			}
        	//$(div).setStyle('display','block');
        	$(div).fade('in');
        	var showEffect = new Fx.Morph(div, {duration:'short'});
        	showEffect.start({
        		'top' : [topStart, topEnd],
        		'left' : [leftStart, leftEnd]
        	});
        	setTimeout('hideKey(\''+div+'\')', 6000);
		}
	}).send();
    });
}
function hideKey(div){
	$(div).fade('out');
}

function CheckAll(chk)
{
    for (i = 0; i < document.checkform.elements.length; i++)
    {
        if(document.checkform.elements[i].type == "checkbox")
        {
            document.checkform.elements[i].checked = chk.checked;
        }
    }
}
