﻿function MyImagePopUp(url) {
	preview = window.open(url, "Preview", "scrollbars,resizable=yes,width=350,height=300");
	window.preview.focus();
}

function doPopUp(url, width, height) {
	preview = window.open(url, "Preview", "scrollbars,resizable=yes,width="+width+",height="+height);
	window.preview.focus();
}

function errorMsg()
{
  alert("Netscape 6 or Mozilla is needed to install a sherlock plugin");
}
function addEngine(name,ext,cat,type)
{
  if ((typeof window.sidebar == "object") && (typeof
  window.sidebar.addSearchEngine == "function"))
  {
    //cat="Web";
    //cat=prompt('In what category should this engine be installed?','Web')
    window.sidebar.addSearchEngine(
      "http://www.camospecs.com/files/firefox/"+name+".src",
      "http://www.camospecs.com/files/firefox/"+name+"."+ext,
      name,
      cat );
  }
  else
  {
    errorMsg();
  }
}

function changeImage(ele, newSrc)
{
	Get_Object(ele).src = newSrc;
}

function preLoad(newSrc)
{
	var loadImage = new Image();
	loadImage.src = newSrc;
}

var curImage = '';

function changeClass(id)
{
	closeCur();
	updateClass(id);
}

function updateClass(id)
{
	var e = Get_Object(id);
	if (e.className == 'ShowIt')
	{
		e.className = 'HideIt';
	} else {
		e.className = 'ShowIt';
	}
	curImage = id;
}
function closeCur()
{
	if (curImage != '')
	{
		updateClass(curImage);
	}
}

function copyMiniatureName(e)
{
	var miniName = e[e.selectedIndex].text;
	if (miniName.indexOf("(") > 0)
	{
		miniName = miniName.substr(0, miniName.lastIndexOf("("));
	}
	document.forms["Mini"].Name.value = miniName;
}

function validateFileExt(f, Mask)
{
	var bReturn = true;
	var fields = 0;
	for (var i = 0; i < f.length; i++) {
		var e = f.elements[i]
		if ((e.type == 'file') && (e.value.length > 0))
		{
			fields += 1;
			var ext = e.value.substring(e.value.lastIndexOf('.')+1, e.value.length);
			ext = ext.toUpperCase();
			
			if (Mask.indexOf(ext) < 0) {
				showError (e, ' must be one of the following file types:\n'+Mask);
				bReturn = false;
			}
		}
	}
	if (fields == 0) {
		alert('You must select a file to upload!');
		bReturn = false;
	}
	
	return bReturn;
}

function myFile(webPath, name, width, height)
{
	if (confirm('Would you like to View (ok) or Delete (cancel) this file?'))
	{
		doPopUp(webPath, width, height);
		
	} else {
		window.location.href = '/Artist/MyFiles.asp?Action=DeleteFile&FileName='+name;
	}
}

function reSize(leftItem, rightItem, extraSpace, minWidth)
{
	//alert(rightItem + ' ' + $(rightItem).css("width"));
	//alert($(window).width() - $(leftItem).width() - extraSpace + "px");
	$(rightItem).css("width", $(window).width() - $(leftItem).width() - extraSpace + "px");
	//alert(parseInt($(rightItem).css("width")) + ' = ' + minWidth);
	if (parseInt($(rightItem).css("width")) < minWidth) { $(rightItem).css("width", $(window).width() - extraSpace + "px"); }
}

$(document).ready(function() {
	//Corners don't look good in IE so only add if FF/Mozilla
	if ($.browser.mozilla) {
		$(".Round").corner();
		$(".RoundTop").corner("round top");
	}

	//Only appears if on an admin page
	$("#Date").datepicker();

	$("#loader").ajaxStart(function() {
		$(this).show();
	}).ajaxStop(function() {
		$(this).hide();
	});
});

