<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2005-2006 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts EasyCreate 1.1                 |
// +----------------------------------------------------------------------+
// | Authors: jimmy<jimmy.jos@armia.com>        		              	  |
// +----------------------------------------------------------------------+

exit;
include "../includes/session.php";
include "../includes/config.php";
$currentloc="../";	  
include "../includes/applicationheader.php";
?>

<script>
var used_space = 0; var quota = 10; var sUploadsList = new Array(); 
 var hyper_mode = 1;

 onload = function(){
  modifyStyle.checked = true;
  linkcolor.style.backgroundColor = dialogArguments.defLinkColor;
  hovercolor.style.backgroundColor = '#ff0000';

  if(dialogArguments.linkcolor){
   modifyStyle.checked = false;
   linkcolor.style.backgroundColor = dialogArguments.linkcolor;
   if(dialogArguments.linkDec == 'underline')
     hypSelDecLink.options[1].selected = true;
  }
  if(dialogArguments.hovercolor){
   modifyStyle.checked = false;
   sUseHover.checked = true;
   hovercolor.style.backgroundColor = dialogArguments.hovercolor;
   if(dialogArguments.hoverDec == 'underline')
    hypSelDecHover.options[1].selected = true;
  }

  newWinCBox.checked = dialogArguments.popup;

  if(dialogArguments.res || dialogArguments.status || dialogArguments.tool || dialogArguments.width || dialogArguments.height){
   pPop[1].checked = true;
   pRes.checked = dialogArguments.res == 1 ? true : false;
   pStatus.checked = dialogArguments.status == 1 ? true : false;
   pTool.checked = dialogArguments.tool == 1 ? true : false;
   pWidth.value = dialogArguments.width;
   pHeight.value = dialogArguments.height;
  }

  switch(dialogArguments.type){
   case 2:
    sExt.value = dialogArguments.url;
    sSelExt.checked = true;
    break
   case 3:
    sMail.value = dialogArguments.url;
    sSelMail.checked = true;
    break;
   case 4:
    sSelFile.checked = true;
    break
   default:
    sSelLoc.checked = true;
  }

  for(i=0; i<dialogArguments.pages.length; i++){
   if(dialogArguments.pages[i].text.match(/^search.html$/i))
    continue;
   dialogArguments.pages[i].text = dialogArguments.pages[i].text.replace(/^guestbook\.html$/, '- Guestbook -');
   dialogArguments.pages[i].value = dialogArguments.pages[i].value.replace(/^guestbook\.html$/, 'guestbook.php');
   sLoc.options[sLoc.length] = new Option(dialogArguments.pages[i].text, dialogArguments.pages[i].value);
   if(dialogArguments.pages[i].value == dialogArguments.url)
    sLoc.options[sLoc.length-1].selected = true;
  }
  for(key in sUploadsList){
   sFile.options[sFile.length] = new Option(sUploadsList[key], sUploadsList[key]);
   if(sSelFile.checked && sUploadsList[key] == dialogArguments.url)
    sFile.options[sFile.length-1].selected = true;
  }

  sPopChange();
  sPopDisplay()
  sHyperButtons();
  sSelChange();
  sDefault();
  sChangeHoverState();
 }

 function sPopDisplay(){
  if(hyper_mode == 3){
   hyper_mode = 1;
   sHyperButtons();
  }
  hPop.style.display = newWinCBox.checked ? 'inline' : 'none';
 }

 function sHyperButtons(){
  if(event && event.srcElement){
   hyper_mode = event.srcElement.id == 'hGen' ? 1 : hyper_mode;
   hyper_mode = event.srcElement.id == 'hCss' ? 2 : hyper_mode;
   hyper_mode = event.srcElement.id == 'hPop' ? 3 : hyper_mode;
  }
  switch(hyper_mode){
   case 1:
    hGen.src = '../img/hyper_general_up.gif';
    hCss.src = '../img/hyper_styles.gif';
    hPop.src = '../img/hyper_advanced.gif';
    hGenTab.style.display = 'block';
    hCssTab.style.display = 'none';
    hPopTab.style.display = 'none';
    break;
   case 2:
    hGen.src = '../img/hyper_general.gif';
    hCss.src = '../img/hyper_styles_up.gif';
    hPop.src = '../img/hyper_advanced.gif';
    hGenTab.style.display = 'none';
    hCssTab.style.display = 'block';
    hPopTab.style.display = 'none';
    break;
   case 3:
    hGen.src = '../img/hyper_general.gif';
    hCss.src = '../img/hyper_styles.gif';
    hPop.src = '../img/hyper_advanced_up.gif';
    hGenTab.style.display = 'none';
    hCssTab.style.display = 'none';
    hPopTab.style.display = 'block';
    break;
  }
 }

 function sSelChange(){
  if(sSelLoc.checked){
   newWinLabel.disabled = newWinCBox.disabled = sLoc.disabled = false;
   sTextLoc.disabled = false;
   sExt.disabled = sTextExt.disabled = true;
   sMail.disabled = sTextMail.disabled = true;
   sFile.disabled = sTextFile.disabled = true;
  }else if(sSelExt.checked){
   newWinLabel.disabled = newWinCBox.disabled = false;
   sLoc.disabled = sTextLoc.disabled = true;
   sExt.disabled = sTextExt.disabled = false;
   sMail.disabled = sTextMail.disabled = true;
   sFile.disabled = sTextFile.disabled = true;
  }else if(sSelMail.checked){
   newWinLabel.disabled = newWinCBox.disabled = true;
   sLoc.disabled = sTextLoc.disabled = true;
   sExt.disabled = sTextExt.disabled = true;
   sMail.disabled = sTextMail.disabled = false;
   sFile.disabled = sTextFile.disabled = true;
  }else if(sSelFile.checked){
   newWinLabel.disabled = newWinCBox.disabled = true;
   sLoc.disabled = sTextLoc.disabled = true;
   sExt.disabled = sTextExt.disabled = true;
   sMail.disabled = sTextMail.disabled = true;
   sFile.disabled = sTextFile.disabled = false;
  }
 }

 function sPopChange(){
  if(pSelStandart.checked){
   pDivStandart.disabled = false;
   pDivPop.disabled = true;
  }else if(pSelPop.checked){
   pDivStandart.disabled = true;
   pDivPop.disabled = false;
  }
 }

 function callColorDlg(src){
  sInitColor = document.all[src].style.backgroundColor ? document.all[src].style.backgroundColor : null;
  if(sInitColor == null)
   var sColor = dlgHelper.ChooseColorDlg();
  else
   var sColor = dlgHelper.ChooseColorDlg(sInitColor);

  sColor = sColor.toString(16);
  if (sColor.length < 6) {
   var sTempString = "000000".substring(0,6-sColor.length);
   sColor = sTempString.concat(sColor);
  }

  document.all[src].style.backgroundColor = '#' + sColor;
 }

 function sInsertLink(){
  linkSource = sSelLoc.checked ? sLoc.options[sLoc.selectedIndex].value : 'http://' + sExt.value.replace(/http:\/\//ig, '');
  linkSource = sSelFile.checked ? 'uploads/' + sFile.options[sFile.selectedIndex].value : linkSource;
  if(sSelMail.checked)
   linkSource = 'mailto:' + sMail.value.replace(/^mailto:( )*/ig, '');

  if(linkSource){
   if(dialogArguments.self == linkSource && !confirm('You are attampting to create the link to itself.\n Continue?'))
    return true;

   returnValue = new Object();
   returnValue.url = linkSource;
   returnValue.popup = newWinCBox.checked;
   if(!modifyStyle.checked){
    returnValue.linkcolor = linkcolor.style.backgroundColor;
    returnValue.linkDec = hypSelDecLink.options[hypSelDecLink.selectedIndex].value;
    if(sUseHover.checked){
     returnValue.hovercolor = hovercolor.style.backgroundColor;
     returnValue.hoverDec = hypSelDecHover.options[hypSelDecHover.selectedIndex].value;
    }
   }

   if(newWinCBox.checked && pPop[1].checked){
    returnValue.params = (pWidth.value ? 'width=' + pWidth.value + '; ' : '') + (pHeight.value ? 'height=' + pHeight.value + '; ' : '') + 'resizable=' + (pRes.checked ? 1 : 0) + '; toolbar=' + (pTool.checked ? 1 : 0) + '; status=' + (pStatus.checked ? 1 : 0) + ';';
   }

   close();
  }else{
   alert("Link address cannot be left blank");
   focus();
  }
 }

 function sDefault(){
  lsField.disabled = rsField.disabled = linkcolor.disabled = hovercolor.disabled = hypSelDecLink.disabled = hypSelDecHover.disabled = modifyStyle.checked;
  sChangeHoverState();
 }

 function sChangeHoverState(){
  rsField.disabled = hovercolor.disabled = hypSelDecHover.disabled = !sUseHover.checked;
 }

</script>
<body>
<table width=260 cellspacing=0 cellpadding=0>
<tr><td height=15></td></tr>
<tr><td><img src=../images/spacer.gif width=10 height=20><img src=../images/spacer.gif id=hGen onclick="sHyperButtons();"><img src=../images/spacer.gif id=hCss onclick="sHyperButtons();"><img src=../images/spacer.gif id=hPop onclick="sHyperButtons();"></td></tr>
<tr><td height=410></td></tr>
<tr><td height=30>&nbsp;&nbsp;&nbsp;<input type=checkbox id=newWinCBox onclick="sPopDisplay();"><label for=newWinCBox id=newWinLabel>Open link in pop-up window</label></td></tr>
<tr><td align=right><input type=button id=hypOK value="&nbsp;&nbsp;&nbsp; OK &nbsp;&nbsp;&nbsp;" onclick="sInsertLink();"> <input type=button value=Cancel onclick="javascript: window.close();"></td></tr>
</table>
<div id=hGenTab style="position: absolute; display: none; top: 40px; left: 20px; width: 230;">
 <fieldset><legend><input type=radio name=sSel onclick="sSelChange();" id=sSelLoc checked> Local Page</legend><div id=sTextLoc>Select one of the pages you have already created.</div><img src=../images/spacer.gif width=1 height=20><select id=sLoc><option> - Select a page - </option><option value=the_s2u_new_page.html> - Add new page - </option></select></fieldset>
 <fieldset><legend><input type=radio name=sSel onclick="sSelChange();" id=sSelExt> External Link</legend><div id=sTextExt>Enter link to external resource <br>(e.g. http://www.iscripts.com).</div><img src=../images/spacer.gif width=1 height=20><input type=text size=20 id=sExt></fieldset>
 <fieldset><legend><input type=radio name=sSel onclick="sSelChange();" id=sSelMail> E - Mail Address</legend><div id=sTextMail>Enter email address <br>(e.g. support@yoursite.com)</div><img src=../images/spacer.gif width=1 height=20><input type=text size=20 id=sMail></fieldset>
 <fieldset><legend><input type=radio name=sSel onclick="sSelChange();" id=sSelFile> Uploaded file</legend><div id=sTextFile>Choose already uploaded file to link <br>(ie. mymelody.mp3)<br><img src=../images/spacer.gif width=1 height=20><select id=sFile><option> - Select a file - </option></select></div></fieldset>
</div>
<div id=hCssTab style="position: absolute; display: none; top: 40px; left: 20px; width: 230;">
 <input type=checkbox id=modifyStyle onClick="sDefault();"><label for=modifyStyle>Use default link apearence</label>
 <fieldset id=lsField><legend>Link Appearance</legend><br><table cellspacing=2 cellpadding=0><tr><td>Color:</td><td><img src=../images/spacer.gif width=30 height=17 border=1 id=linkcolor onclick="callColorDlg('linkcolor');"></td></tr><tr><td>Underline:</td><td><select id=hypSelDecLink><option value=none>no</option><option value=underline>yes</option></select></td></tr></table></fieldset><br>
 <input type=checkbox id=sUseHover onclick="sChangeHoverState();"><label for=sUseHover>Change on mouse over</label>
 <fieldset id=rsField><legend>Rollover Appearance</legend><br><table cellspacing=2 cellpadding=0><tr><td>Color:</td><td><img src=../images/spacer.gif width=30 height=17 border=1 id=hovercolor onclick="callColorDlg('hovercolor');"></td></tr><tr><td>Underline:</td><td><select id=hypSelDecHover><option value=none>no</option><option value=underline>yes</option></select></td></tr></table></fieldset>
</div>
<div id=hPopTab style="position: absolute; display: none; top: 40px; left: 20px; width: 230;">
 <fieldset><legend><input type=radio name=pPop onclick="sPopChange();" id=pSelStandart checked> <label for=pSelStandart>Standart Window</label></legend><div id=pDivStandart>The link will be launched in the standart window including toolbar, statusbar etc. The parent window will remain open.</div></fieldset>
 <fieldset><legend><input type=radio name=pPop onclick="sPopChange();" id=pSelPop> <label for=pSelPop>Pop Up Window</label></legend><div id=pDivPop>This option specified for the pages created from the 'blank pop up page' source.<br><br style="font-size: 3px;">
           <input type=checkbox id=pRes> <label for=pRes>resizable</label><br><input type=checkbox id=pTool> <label for=pTool>toolbar</label><br><input type=checkbox id=pStatus> <label for=pStatus>statusbar</label><br><br style="font-size: 3px;">
           Pop up size:<br><br style="font-size: 3px;">
           Width: <input type=text id=pWidth size=4 maxlength=4 value=480> &nbsp; &nbsp; Height: <input type=text id=pHeight size=4 maxlength=4 value=360>
           </div></fieldset>
</div>
<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>
<?php
  include "./includes/editorfooter.php";
?> 