function Open(url) {
	win = window.open(url);
	win.focus();
}
function OpenSmall(url) {
	win = window.open(url, 'OP','toolbar = no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=640, height=480,copyhistory=no');
	win.focus();
}
function BlogProject(url) {
	win = window.open(url, 'ProjectImage','toolbar = no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=720, height=680,copyhistory=no');
	win.focus();
}

function OpenGP(garmentID) {
	win = window.open("GarmentPreview.aspx?GarmentID=" + garmentID, 'IM','toolbar = no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=675, height=540,copyhistory=yes');
	win.focus();
}
function OpenProof(projectID) {
	win = window.open("ProofPreview.aspx?ProjectID=" + projectID, 'IM','toolbar = no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=776, height=575,copyhistory=no');
	win.focus();
}
function OpenZoom(page) {
	win = window.open(page, 'F','toolbar = no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=yes, width=380, height=380,copyhistory=no');
	win.focus();
}
function OpenPricing(page) {
	win = window.open(page, 'F','toolbar = no, directories=no, status=yes, menubar=no, scrollbars=no, resizable=yes, width=380, height=240,copyhistory=no');
	win.focus();
}
function OpenEmail(page) {
	win = window.open(page, 'F','toolbar = no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=640, height=480,copyhistory=no');
	win.focus();
}
function OpenSheet(page) {
	win = window.open(page, 'IM','toolbar = no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=720, height=575,copyhistory=no');
	win.focus();
}
function RenderWait() { 
	ns4 = document.layers;
	ie4 = document.all;
	nn6 = document.getElementById && !document.all;
	if (ns4) {
		document.zrp.visibility = "show";
	}
	else if (ie4) {
		document.all['zrp'].style.visibility = "visible";
	}
	else if (nn6) {
		document.getElementById('zrp').style.visibility = "visible";
	}
}
function DefaultEnter(e, button, command) {
	var key;
	if(window.event) {
		key = window.event.keyCode;
	}
	else {
		key = e.which;
	}
	if(key == 13)	{
		if(typeof(Page_ClientValidate)=='function'){
			if(Page_ClientValidate()==false) {
				return false;
			}
		}
		button = button.replace(/_/g, "$");
		
		this.disabled=true;
		__doPostBack(button, '');
		this.value = command;
		return false;
	} else {
		return true;
	}
}


//http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3066658&SiteID=1
function FireButtonOnReturnOrEnter(ev, buttonIdToFire) {
  // return and enter key codes
  var charCode = ev ? ev.which : event.keyCode;
  if (charCode == 10 || charCode == 13) {
    document.getElementById(buttonIdToFire).click();
    return false;
  }
}

function ConsumeReturnOrEnter(ev) {
  // return and enter key codes
  var charCode = ev ? ev.which : event.keyCode;
  if (charCode == 10 || charCode == 13) {
    return false;
  }
}


var mascotTextBoxId, mascotImageId, mascotDefaultText;
function ShowMascotWindow(mascotTextBoxIdParam, mascotImageIdParam) {
    obj = document.getElementById('mascotWindow');
	obj.style.visibility = 'visible';
	mascotTextBoxId = mascotTextBoxIdParam;
	mascotImageId = mascotImageIdParam;
}

function HideMascotWindow() {
    obj = document.getElementById('mascotWindow');
	obj.style.visibility = 'hidden';
}

function SelectMascot(mascotName) {
    SelectMascotWithParams(mascotTextBoxId, mascotImageId, mascotName);
}

function SelectMascotWithParams(mascotTextBoxIdParam, mascotImageIdParam, mascotName) {
    if (mascotName.toLowerCase() == mascotDefaultText.toLowerCase()) {
        mascotName = "none";
    }
    document.getElementById(mascotTextBoxIdParam).value = mascotName;
    var imgStr = 'App_Themes/ImageMarket/images/IndividualMascots/' + mascotName + '.jpg';
    document.getElementById(mascotImageIdParam).src = imgStr;
    HideMascotWindow();
}



var noTextValue = '(no text)';
function OnEnterDesignTextBox(txtObject) {
    if (txtObject.value == noTextValue) {
        txtObject.value = '';
        txtObject.style.color = 'black';
    }
}

function OnExitDesignTextBox(txtObject) {
    if (txtObject.value == '') {
        txtObject.value = noTextValue;
        txtObject.style.color = 'gray';
    }
}


function CheckRequireJQuery(methodName) {
    if(typeof jQuery != 'function'){
        alert("The method (" + methodName + ") requires jquery to be included. It appears it is not.");
        return;
    }
}

function OnClientSelectedIndexChangedEventHandlerForColorSelector(sender, clientIdOfObject) {
    CheckRequireJQuery("OnClientSelectedIndexChangedEventHandlerForColorSelector");
    
    //alert(sender.Value);
    var splits = sender.SelectedItem.Value.split(':');
    var hexValue = splits[1];
    $("#" + clientIdOfObject).css("background-color", hexValue);
}
