// Author: Andrew Green / Copyright DR Solutions International Ltd.

function URLEncode(surl){surl=encodeURI(surl);surl=surl.replace(/,/g,"%2C");/*surl=surl.replace(/?/g,"%3F");*/surl=surl.replace(/:/g,"%3A");surl=surl.replace(/&/g,"%26");surl=surl.replace(/=/g,"%3D");surl=surl.replace(/$/g,"%24");surl=surl.replace(/#/g,"%23");return surl;}
function URLEncode(surl){surl=decodeURI(surl);surl=surl.replace(/%2C/g,",");/*surl=surl.replace(/%3F/g,"?");*/surl=surl.replace(/%3A/g,":");surl=surl.replace(/%26/g,"&");surl=surl.replace(/%3D/g,"=");surl=surl.replace(/%24/g,"$");surl=surl.replace(/%23/g,"#");return surl;}

/*
function fncexternallink(){
  if (document.getElementsByTagName){
    var i,a; a=document.getElementsByTagName('a');
    for(var i=0; i<a.length; i++){if(a[i].getAttribute('href') && a[i].getAttribute('rel')=='externallink'){a[i].target='_blank';}}
  }
}
*/

function fncsubmit(oform){document.getElementById(oform).submit();}

function fncformfieldfileUpload(oform){
  oform = document.getElementById(oform);
  var surl = "";
  for (var i=0;i<oform.length;i++){
    if(oform.elements[i].type=='text'){
      if(i>1){surl=surl+"&"}
      surl=surl+oform.elements[i].name+"%3D"+oform.elements[i].value;
    }
  }
  oform.action = oform.action+"&addurl="+surl;
}

function fncconfirm(stext,surltrue,surlfalse){var oconfirm=confirm(stext);if(oconfirm==true){window.location=surltrue;}else{window.location=surlfalse;}}

function fncstylechange(oitem,stype,svalue){
  switch(stype){
    case "bg": if(svalue.indexOf("#")>-1){oitem.style.backgroundColor=svalue;}else{oitem.style.backgroundImage="url(img/"+svalue+")";};break;
    case "brd": if(svalue.indexOf("#")>-1){oitem.style.borderColor=svalue;};break;
    case "txt": if(svalue.indexOf("#")>-1){oitem.style.color=svalue;};break;
    case "img": oitem.src=svalue;break;
    default: return false;
  }
}

function fncviewimage(oitem, svalue) {
  oitem = document.getElementById(oitem);
  svalue = encodeURI(svalue);
  oitem.src = svalue;
}

function fncwmpwrite(strid,strurl){
  document.write("<object classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' type='application/x-oleobject' id='" + strid + "'>\n");
  document.write("<param name='filename' value='" + strurl + "'>\n");
  document.write("<param name='autostart' value='true'>\n");
  document.write("<param name='showcontrols' value='true'>\n");
  document.write("<param name='showstatusbar' value='false'>\n");
  document.write("<param name='showdisplay' value='false'>\n");
  document.write("<param name='volume' value='0'>\n");
  document.write("<embed type='application/x-mplayer2' src='" + strurl + "' showcontrols='true' showstatusbar='false' showdisplay='true' autostart='true' volume='0' id='" + strid + "'></embed>\n");
  document.write("</object>\n");
}

function fnccleartextbox(ofield,stext){
//  ofield = document.getElementById(ofield);
  if(ofield.value==stext){
    ofield.value = "";
  }
}

