/**
 *
 * SaviCMS
 * Copyright 2009, Eric R Falkner.
 *
 * Redistributions of files not permitted without expressed permission from Eric R Falkner 
 * Scripts used under creative commons can be redistriubuted per the original owner's rules
 *
 * @file 		    util.js
 * @filepurpose     Contains generic site javascript functions
 * @copyright		Copyright 2009, Eric R Falkner
 * @link			http://www.savicms.com
 * @package			savicms
 *
 **/


/** 
 * @function  loadSWF()  Generic SWF loader using swfObject 
 * @function  loadSWFwParams()  Generic SWF loader using swfObject 
 * @required  swfobject.js
 *
 * @param  div  Div to be replaced with SWF content
 * @param  swf  SWF to be loaded
 * @param  w    Width parameter for swfobject call
 * @param  h    Height parameter for swfobject call
 *
 * @param  fvs   Flashvars hash
 * @param  pars  Flashvars hash
 * @param  atts  Flashvars hash
 *               Hashes should be:  fv = { param1:value1,
 *                                         param2:value2,
 *                                         paramN:valueN }
 *               See swfojbect manual for propery params and values
 **/

    function loadSWF(div, swf, w, h) {
        var flashvars = {};
        var params = {};
        var attributes = {};
        swfobject.embedSWF(swf, div, w, h, "9.0.0", false, flashvars, params, attributes);
    }

    function loadSWFwParams(div, swf, w, h, fvs, pars, atts) {
        var flashvars = fv;
        var params = par;
        var attributes = atts;
        swfobject.embedSWF(swf, div, w, h, "9.0.0", false, flashvars, params, attributes);
    }

/** 
 * @function  popWin()  Generic helper for creating Strict valued popup windows 
 *
 * @param  url     The Url to feed the new window
 * @param  target  The window target (window name or '_parent', etc) - default is '_blank'
 */
 
    function popWin(url, target) {
    	if(!target) { target = '_blank'; }
		blankWin = window.open(url,target);
	}
	
/*
Disable right click script II (on images)- By Dynamicdrive.com
For full source, Terms of service, and 100s DTHML scripts
Visit http://www.dynamicdrive.com
*/

var clickmessage="Images are copyrighted so downloading is disabled";

function disableclick(e) {
   if (document.all) {
      if (event.button==2||event.button==3) {
         if (event.srcElement.tagName=="IMG"){
            alert(clickmessage);
            return false;
         }
      }
   } else if (document.layers) {
      if (e.which == 3) {
         alert(clickmessage);
         return false;
      }
   } else if (document.getElementById) {
      if (e.which==3&&e.target.tagName=="IMG"){
         alert(clickmessage);
         return false;
      }
   }
}

function associateimages() {
   for(i=0;i<document.images.length;i++) {
      document.images[i].onmousedown=disableclick;
   }
}

function noImgDownload() {
   if (document.all) {
      document.onmousedown=disableclick;
   } else if (document.getElementById) {
      document.onmouseup=disableclick;
   } else if (document.layers) {
      associateimages();
   }
}