//function to pop up window

function pop_win_tools(url, h, w)
{
   mywin2 =
   window.open(url,"win2",'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width='+w+',height='+h+'');
   // Popup window was opened
   mywin2.focus();
}

function pop_win(url)
{
   mywin2 =
   window.open(url,"win2",'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width=550,height=460');
   // Popup window was opened
   mywin2.focus();
}

function pop_win_document(url, document)
{
   var styleSheetList = "";

   for ( i = 0; i < document.styleSheets.length; i++ )
   {
      if (i == 0){
         styleSheetList = document.styleSheets[i].href;
      }
      else{
         styleSheetList += "," + document.styleSheets[i].href;
      }
   }

   url += "&css=" + escape(styleSheetList);
   mywin2 =
   window.open(url,"win2",'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width=1000,height=460');
   // Popup window was opened
   mywin2.focus();
}


function pop_win_size(url, h, w)
{
   mywin2 =
   window.open(url,"win2",'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width='+w+',height='+h+'');
   // Popup window was opened
   mywin2.focus();
}

function pop_win_size_stripped(url, h, w)
{
   mywin2 =
   window.open(url,"win2",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width='+w+',height='+h+'');
   // Popup window was opened
   mywin2.focus();
}

function pop_scroll_win_size_stripped(url, h, w)
{
   mywin2 =
   window.open(url,"win2",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h+'');
   // Popup window was opened
   mywin2.focus();
}

function pop_scroll_win_size_stripped_auto_scroll(url, h, w)
{
   mywin2 =
   window.open(url,"win2",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,width='+w+',height='+h+'');
   // Popup window was opened
   mywin2.focus();
}


function pop_scroll_win_full_stripped(url)
{
   h = screen.height - 40;
   w = screen.width - 40;
   mywin2 = window.open(url,"win2",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,top=0, left=0, screenX=0,screenY=0,resizable=1,width='+w+',height='+h+'');
}

function pop_scroll_win_full_stripped_close(url)
{

   h = screen.height - 40;
   w = screen.width - 40;
   mywin2 = window.open(url,"win2",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,top=0, left=0, screenX=0,screenY=0,resizable=1,width='+w+',height='+h+'');

}

function showBlockSimple(id) {
   var el = document.getElementById(id).style;
   el.display = "inline";
}

function hideBlockSimple(id) {
   var el = document.getElementById(id).style;
   el.display = "none";
}

function hideBlock(id) {
   for (var i=0; i < arguments.length; i++)
   {
      var block = document.getElementById(arguments[i]).style;
      block.display = "none";
      block.position = "relative";
   }
   //  var el = document.getElementById(id).style;
   //  el.display = "none";
   //  el.position = "relative";
}

function showBlock(id) {
   for (var i=0; i < arguments.length; i++)
   {
      var block = document.getElementById(arguments[i]).style;
      block.display = "block";
      block.position = "relative";
   }
   //    var el = document.getElementById(id).style;
   //    el.display = "block";
   //    el.position = "relative";
}

function hideBlockNone(id) {
   var el = document.getElementById(id).style;
   el.display = "none";
}

function showBlockNone(id) {
   var el = document.getElementById(id).style;
   el.display = "block";
}

function hideBlocks(blocks) {
   var i = 0;
   for (i = 0; i < blocks.length; i++){
      var el = document.getElementById(blocks[i]).style;
      el.display = "none";
      el.position = "relative";
   }
}

function showBlocks(blocks) {
   var i = 0;
   for (i = 0; i < blocks.length; i++){
      var el = document.getElementById(blocks[i]).style;
      el.display = "block";
      el.position = "relative";
   }
}


function hideBlockCustom(id, position) {
   var el = document.getElementById(id).style;
   el.display = "none";
   el.position = position;
}


function showBlockCustom(id, display, position) {
   var el = document.getElementById(id).style;
   el.display = display;
   el.position = position;
}


function showBlockInline(id) {
   var el = document.getElementById(id).style;
   el.display = "inline";
   el.position = "relative";
}

function hideBlockAbs(id) {
   var el = document.getElementById(id).style;
   el.display = "none";
   el.position = "absolute";
}

function showBlockAbs(id) {
   var el = document.getElementById(id).style;
   el.display = "block";
   el.position = "absolute";
}


function toggleVisibility(id) {
   var el = document.getElementById(id).style;
   if(el.display == "none") {
      showBlock(id);
   }
   else if(el.display == "block") {
      hideBlock(id);
   }
   else{
      hideBlock(id);
   }
}

function toggleBlockOnCheck(check,block){
   if (check.checked){
      showBlock(block);
   }
   else{
      hideBlock(block);
   }
}

function toggleBlockOnCheckReverse(check,block){
   if (check.checked){
      hideBlock(block);
   }
   else{
      showBlock(block);

   }
}

function toggleBlocks(showLayer, hideLayer){
   showBlock(showLayer);
   hideBlock(hideLayer);
}

function waitMilli(gap){ /* gap is in millisecs */
   var then,now; then=new Date().getTime();
   now=then;
   while((now-then)<gap)
   {now=new Date().getTime();}
}



function submitAndReloadOpener(form) {
   form.submit();
   waitMilli(1000);
   var URL = window.opener.location.href;
   window.opener.location.href = URL;
   window.close();
}

function submitAndClose(href) {
   self.close();
   opener.location.href=href;
}

function srcSelect2TgtSelect(src, tgt) {
   srcLength = src.length ;
   for ( i=0; i<srcLength ; i++){
      if (src.options[i].selected ) {
         tgtLength = tgt.length;
         tgt.options[tgtLength]= new Option(src.options[i].text, src.options[i].value, "", "");
      }
   }

   for ( i = (srcLength -1); i>=0; i--){
      if (src.options[i].selected ) {
         src.options[i] = null;
      }
   }
}

function tgtSelect2SrcSelect(src, tgt) {
   tgtLength = tgt.length;
   for ( i=0; i<tgtLength ; i++){
      if (tgt.options[i].selected ) {
         srcLength = src.length;
         src.options[m1len]= new Option(tgt.options[i].text, tgt.options[i].value, "", "");
      }
   }
   for ( i=(tgtLengthn-1); i>=0; i--) {
      if (tgt.options[i].selected ) {
         tgt.options[i] = null;
      }
   }
}

function copySrcSelect2TgtSelect(src, tgt) {
   srcLength = src.length ;
   for ( i=0; i<srcLength ; i++){
      if (src.options[i].selected ) {
         tgtLength = tgt.length;
         tgt.options[tgtLength]= new Option(src.options[i].text, src.options[i].value, "", "");
      }
   }
}

function removeFromTgtSelect(tgt) {
   tgtLength = tgt.length ;
   for ( i=(tgtLength-1); i>=0; i--) {
      if (tgt.options[i].selected ) {
         tgt.options[i] = null;
      }
   }
}

function selectTgt(tgt, form, submit) {
   for (i=0; i<tgt.length; i++) {
      tgt.options[i].selected = true;
   }

   if (submit == 1) form.submit();
}

function selectTgtGoPricing(tgt, form, submit) {
   for (i=0; i<tgt.length; i++) {
      tgt.options[i].selected = true;
   }

   var pricing = form.pricing;

   pricing.value='1';

   if (submit == 1) form.submit();
}


function selectTgtUpload(tgt, form, submit) {
   for (i=0; i<tgt.length; i++) {
      tgt.options[i].selected = true;
   }

   alert('UPLOADING - ' + form);

   var upload = form.upload;

   alert('UPLOAD CONTROL - ' + upload);

   upload.value='1';

   if (submit == 1) form.submit();
}

function selectTgtScreenCapture(tgt, form, submit) {
   for (i=0; i<tgt.length; i++) {
      tgt.options[i].selected = true;
   }

   var screencapture = form.screencapture;

   screencapture.value='1';

   if (submit == 1) form.submit();
}



function detectFlash(noFlashRedir, flashRedir){
   // This script will test up to the following version.
   flash_versions = 20;

   // Initialize variables and arrays
   var flash = new Object();
   flash.installed=false;
   flash.version='0.0';

   // Dig through Netscape-compatible plug-ins first.
   if (navigator.plugins && navigator.plugins.length) {
      for (x=0; x < navigator.plugins.length; x++) {
         if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
            flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
            flash.installed = true;
            break;
         }
      }
   }

   // Then, dig through ActiveX-style plug-ins afterwords
   else if (window.ActiveXObject) {
      for (x = 2; x <= flash_versions; x++) {
         try {
            oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
            if(oFlash) {
               flash.installed = true;
               flash.version = x + '.0';
            }
         }
         catch(e) {}
      }
   }

   // Create sniffing variables in the following style: flash.ver[x]
   // Modified by mjac
   flash.ver = Array();
   for(i = 4; i <= flash_versions; i++) {
      eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true : false;");
   }

   if (flash.installed){
      window.location.replace(flashRedir);
   }
   else{
      window.location.replace(noFlashRedir);
   }
}

function callCenterBack(form){
   form.prev.value = "1";
   form.submit();
}

//end function to pop up window

function checkAll(field)
{
   for (i = 0; i < field.length; i++)
      field[i].checked = true ;
}

function uncheckAll(field)
{
   for (i = 0; i < field.length; i++){
      field[i].checked = false ;
   }
}

function checkAllElement(formId, fieldName) {
   var form = document.getElementById(formId);
   var field = form.elements[fieldName];
   for (i = 0; i < field.length; i++)
      field[i].checked = true ;
}

function uncheckAllElement(formId, fieldName) {
   var form = document.getElementById(formId);
   var field = form.elements[fieldName];

   for (i = 0; i < field.length; i++){
      field[i].checked = false ;
   }
}


function toggleCheckAll(field, check){

   for (i = 0; i < field.length; i++){
      field[i].checked = check.checked ;
   }
}



function previewMedia(type, mediaid){
   config="toolbar=no,location=no,directories=no,status=no,menubar=no,width=80,height=50";
   config += "scrollbars=yes,resizable=yes";
   pop = window.open ("","popThumb",config);
   body="<html>";
   body += "<head>";
   body += "<title>Content Preview</title>";
   body += "</head>";
   body += "<body>";
   body += "<img src=\"/admin/admindelivery.svlt?op=dl_media&mode=display&type="+type+"&mediaid="+mediaid+"\" border=1/>";
   body += "</body>";
   body +="</html>";
   pop.document.write(body);
   pop.document.close();
}

function previewMediaThumb(type, mediaid){
   config="toolbar=no,location=no,directories=no,status=no,menubar=no,width=250,height=200";
   config += "scrollbars=yes,resizable=yes";
   pop = window.open ("","popThumb",config);
   body="<html>";
   body += "<head>";
   body += "<title>Content Preview</title>";
   body += "</head>";
   body += "<body>";
   body += "<img src=\"/admin/admindelivery.svlt?op=dl_media&mode=display&type="+type+"&mediaid="+mediaid+"\" border=1/>";
   body += "</body>";
   body +="</html>";
   pop.document.write(body);
   pop.document.close();
}


function previewMediaFull(type, mediaid){
   config="toolbar=no,location=no,directories=no,status=no,menubar=no,width=600,height=450";
   config += "scrollbars=yes,resizable=yes";
   pop = window.open ("","popThumb",config);
   body="<html>";
   body += "<head>";
   body += "<title>Content Preview</title>";
   body += "</head>";
   body += "<body>";
   body += "<img src=\"/admin/admindelivery.svlt?op=dl_media&mode=display&type="+type+"&mediaid="+mediaid+"\" border=1/>";
   body += "</body>";
   body +="</html>";
   pop.document.write(body);
   pop.document.close();
}


function previewInventoryFull(websiteid){
   config="toolbar=no,location=no,directories=no,status=no,menubar=no,width=500,height=400";
   config += "scrollbars=yes,resizable=yes";
   pop = window.open ("","popThumb",config);
   body="<html>";
   body += "<head>";
   body += "<title>Content Preview</title>";
   body += "</head>";
   body += "<body>";
   body += "<img src=\"/image.svlt?mode=full&websiteId="+websiteid+"\" border=1/>";
   body += "</body>";
   body +="</html>";
   pop.document.write(body);
   pop.document.close();
}


function getElemRefs(id) {
   var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
   if (el) el.css = (el.style)? el.style: el;
   return el;
}


function toggleDisableCheckboxList(disable, className) {
   disable.checked ? disableCheckboxes(className) : enableCheckboxes(className);
}

function disableCheckboxes(className) {
   var list = document.getElementsByClassName(className);
   for (i = 0; i < list.length; i++) {
      list[i].checked = false;
      list[i].disabled = true;
   }
}

function enableCheckboxes(className) {
   var list = document.getElementsByClassName(className);
   for (i = 0; i < list.length; i++) { list[i].disabled = false; }
}


<!--

/**
 *
 * Function for generating a GUID of specific length
 *
 * @param length the desired string length of the GUID
 * @return a GUID string of desired length
 */
function getGUID(length){
   var number = 0;


   var guid = "";


   while (guid.length < length){
      if (number < (36 * 36)) {
         var seed = new Date().getTime();
         number = Math.round(Math.random() * seed);

      }

      var c = number % 36;

      number /= 36;

      if (c < 10) {
         guid += Math.round(c);
      } else {
         guid += String.fromCharCode(Math.round(c) + 87);
      }
   }

   return guid;
}


function RepairPasteFromWord(str){

   var sTemp=str;
   //we are going to replace the
   var sTemp2 = escape(sTemp);
   //replace front quote mark "
   sTemp2 = sTemp2.replace(/%u201C/gi, "%22");
   //replace end quote mark "
   sTemp2 = sTemp2.replace(/%u201D/gi, "%22");
   //replace opening single quote mark '
   sTemp2 = sTemp2.replace(/%u2018/gi, "%27");
   //replace closing single quote mark '
   sTemp2 = sTemp2.replace(/%u2019/gi, "%27");
   return sTemp2;
}


function setTextareaSize(formName, fieldName, sourceCols, sourceRows, sourceScreenWidth, sourceScreenHeight){

   var form = document.getElementById(formName);
   var field = form.elements[fieldName];

   field.cols = sourceCols * (screen.width/sourceScreenWidth);
   field.rows = sourceRows * (screen.height/sourceScreenHeight);

}


function setTextSize(formName, fieldName, sourceSize, sourceScreenWidth){

   var form = document.getElementById(formName);
   var field = form.elements[fieldName];

   field.size = sourceSize * (screen.width/sourceScreenWidth);

}

function newsletterSignup(formId, fieldName, requiredErrorId, formatErrorId){

   var form = window.document.getElementById(formId);


   hideBlock(requiredErrorId);
   hideBlock(formatErrorId);

   var submit = true;

   var ret = true;

   ret = validateRequired(formId, fieldName, requiredErrorId);

   if (!ret) submit = false;

   if (submit){
      ret = validateEmail(formId, fieldName, formatErrorId);

      if (!ret) submit = false;
   }

   if (submit){
      form.submit();
   }
}


function grayOut(vis, options) {
   // Pass true to gray out screen, false to ungray
   // options are optional.  This is a JSON object with the following (optional) properties
   // opacity:0-100         // Lower number = less grayout higher = more of a blackout
   // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
   // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
   // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
   // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
   // in any order.  Pass only the properties you need to set.
   var options = options || {};
   var zindex = options.zindex || 50;
   var opacity = options.opacity || 60;
   var opaque = (opacity / 100);
   var bgcolor = options.bgcolor || '#000000';
   var dark=document.getElementById('darkenScreenObject');

   if (!dark) {
      // The dark layer doesn't exist, it's never been created.  So we'll
      // create it here and apply some basic styles.
      // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
      var tbody = document.getElementsByTagName("body")[0];
      var tnode = document.createElement('div');           // Create the layer.
      tnode.style.position='absolute';                 // Position absolutely
      tnode.style.top='0px';                           // In the top
      tnode.style.left='0px';                          // Left corner of the page
      tnode.style.overflow='hidden';                   // Try to avoid making scroll bars
      tnode.style.display='none';                      // Start out Hidden
      tnode.id='darkenScreenObject';                   // Name it so we can find it later
      tbody.appendChild(tnode);                            // Add it to the web page
      dark=document.getElementById('darkenScreenObject');  // Get the object.

   }

   if (vis) {

      // Calculate the page width and height
      if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
         var pageWidth = document.body.scrollWidth+'px';
         var pageHeight = document.body.scrollHeight+'px';
      } else if( document.body.offsetWidth ) {
         var pageWidth = document.body.offsetWidth+'px';
         var pageHeight = document.body.offsetHeight+'px';
      } else {
         var pageWidth='100%';
         var pageHeight='100%';
      }

      //set the shader to cover the entire page and make it visible.
      dark.style.opacity=opaque;
      dark.style.MozOpacity=opaque;
      dark.style.filter='alpha(opacity='+opacity+')';
      dark.style.zIndex=zindex;
      dark.style.backgroundColor=bgcolor;
      dark.style.width= pageWidth;
      dark.style.height= '10000px';
      dark.style.display='block';
   } else {
      dark.style.display='none';
   }
}


function grayOutLayer(vis, layerId, options) {
   // Pass true to gray out screen, false to ungray
   // options are optional.  This is a JSON object with the following (optional) properties
   // opacity:0-100         // Lower number = less grayout higher = more of a blackout
   // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
   // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
   // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
   // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
   // in any order.  Pass only the properties you need to set.
   var options = options || {};
   var zindex = options.zindex || 50;
   var opacity = options.opacity || 70;
   var opaque = (opacity / 100);
   var bgcolor = options.bgcolor || '#000000';
   var dark = document.getElementById(layerId);
   if (vis) {
      //set the shader to cover the entire page and make it visible.
      dark.style.opacity=opaque;
      dark.style.MozOpacity=opaque;
      dark.style.filter='alpha(opacity='+opacity+')';
      dark.style.zIndex=zindex;
      dark.style.backgroundColor=bgcolor;
      dark.style.display='block';
   } else {
      dark.style.display='none';
   }
}

String.prototype.format = function() {

   var str = this;

   for (var i = 0; i < arguments.length; i++) {
      var re = new RegExp('\\{' + (i) + '\\}', 'gm');
      str = str.replace(re, arguments[i]);
   }

   return str;

};
// -->


function clearInput(field){
   var el = document.getElementById(field);
   el.value = '';
}

function disableInput(field){
   var el = document.getElementById(field);
   el.disabled = true;
}

function enableInput(field){
   var el = document.getElementById(field);
   el.disabled = false;
}

function opaqueThis(el, opacity, mozopacity){
   el.style.opacity=mozopacity;
   el.style.MozOpacity=mozopacity;
   el.style.filter='alpha(opacity='+opacity+')';

}

function unopaqueThis(el){
   el.style.opacity=1;
   el.style.MozOpacity=1;
   el.style.filter='alpha(opacity='+100+')';

}

// this function determines whether the event is the equivalent of the microsoft // mouseleave or mouseenter events. 

function isMouseLeaveOrEnter(e, handler) {
   if (e.type != 'mouseout' && e.type != 'mouseover') return false;
   var reltg = e.relatedTarget ? e.relatedTarget :
               e.type == 'mouseout' ? e.toElement : e.fromElement;
   while (reltg && reltg != handler) reltg = reltg.parentNode;
   return (reltg != handler);
}


var Client = {
   viewportWidth: function() {
      return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
   },

   viewportHeight: function() {
      return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
   },

   viewportSize: function() {
      return { width: this.viewportWidth(), height: this.viewportHeight() };
   }
};


function findPosY(obj)
{
   var curtop = 0;
   if(obj.offsetParent)
      while(1)
      {
         curtop += obj.offsetTop;
         if(!obj.offsetParent)
            break;
         obj = obj.offsetParent;
      }
   else if(obj.y)
      curtop += obj.y;
   return curtop;
}

function findPosX(obj)
{
   var curleft = 0;
   if(obj.offsetParent)
      while(1)
      {
         curleft += obj.offsetLeft;
         if(!obj.offsetParent)
            break;
         obj = obj.offsetParent;
      }
   else if(obj.x)
      curleft += obj.x;
   return curleft;
}


function pop_win_return(url)
{
   mywin2 =
   window.open(url, "win2", 'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width=550,height=460');
   // Popup window was opened
   mywin2.focus();
   return mywin2;
}


function getWindowHeight() {
   var windowHeight = 0;
   if (typeof(window.innerHeight) == 'number') {
      windowHeight = window.innerHeight;
   }
   else {
      if (document.documentElement && document.documentElement.clientHeight) {
         windowHeight = document.documentElement.clientHeight;
      }
      else {
         if (document.body && document.body.clientHeight) {
            windowHeight = document.body.clientHeight;
         }
      }
   }
   return windowHeight;
}

  function setBackground(el, color, forecolor){
      
      el.style.color = forecolor;
      el.style.background = color;
  }


String.prototype.startsWith = function(str) 
{return (this.match("^"+str)==str)}

function getStyle(el,styleProp)
{
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}