<!DOCTYPE HTML SYSTEM "-//Macromedia//DWExtension layout-engine 5.0//dialog">
<HTML>
<HEAD>
<TITLE>Check Client Resolution</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html">
<SCRIPT language="JavaScript">
// Insert this into the HEAD of the user's document
function checkResolution(smallResURL,bigResURL) {
  var one = screen.height
  one = parseInt(one)
  if  (one >= 768 ){
    alert ("Resolution is 1024x768 or higher")
    window.location.href= bigResURL;
  }
  else{
  alert ("Small Resolution")
    window.location.href=smallResURL;
  }
}

//******************* API **********************
function canAcceptBehavior(){
  var theDOM = dreamweaver.getDocumentDOM();
  var allTags = theDOM.body;
  if (allTags != '') {
    return "onLoad";
  } else {
    return false;
  }
}

// Function(s) to be inserted into the HEAD of the user's document
function behaviorFunction(){
    return "checkResolution";
}

// Create the function call that will be inserted with the event handler
function applyBehavior() {
  var smallURL = escape(document.resForm.smallURL.value);
  var bigURL = escape(document.resForm.bigURL.value);
  if (smallURL && bigURL) {
    return "checkResolution (\'" + smallURL + "\',\'" + bigURL +
    "\')";
  }else{
    return "Please enter URLs in both fields."
  }
}

// Extract the arguments from the function call in the event handler and repopulate the parameters form
function inspectBehavior(fnCall){
  var argArray = getTokens(fnCall, "()',");
  var smallURL = unescape(argArray[1]);
  var bigURL = unescape(argArray[2]);
  document.resForm.smallURL.value = smallURL;
  document.resForm.bigURL.value = bigURL;
}

// Put the cursor in the first text field and select the contents, if any
function initializeUI(){
  document.resForm.smallURL.focus();
  document.resForm.smallURL.select();
}

// Let the user browse to the small and big URLs
function browseForURLs(getButton){
  var theURL = dreamweaver.browseForFileURL();
  if (getButton == "smallURL"){
    document.resForm.smallURL.value = theURL;
  }else{
    document.resForm.bigURL.value = theURL;
  }
}
//*************** END OF JAVASCRIPT *****************
</SCRIPT>
</HEAD>
<BODY>
<FORM METHOD="post" ACTION="" NAME="resForm">
<TABLE BORDER="0" CELLPADDING="8">
<TR>
<TD NOWRAP="nowrap">&nbsp;&nbsp;Small Resolution URL:<BR>
<INPUT TYPE="text" NAME="smallURL" SIZE="50" VALUE=""> &nbsp;
<INPUT TYPE="button" NAME="smallBrowse" VALUE="Browse..."
onClick="browseForURLs('smallURL')"></TD>
</TR>
<TR>
<TD NOWRAP="nowrap">&nbsp;&nbsp;Large Resolution URL:<BR>
<INPUT TYPE="text" NAME="bigURL" SIZE="50" VALUE=""> &nbsp; 
<INPUT TYPE="button" NAME="bigBrowse" VALUE="Browse..."
onClick="browseForURLs('bigURL')"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
