






/* BEGIN jquery.pngFix.js */
/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.2, 09.03.2009
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    09.03.2009 Version 1.2
 *    - Update for jQuery 1.3.x, removed @ from selectors
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 * @example jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example jQuery(function(){jQuery('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example jQuery(function(){jQuery('div.examples').pngFix( { blankgif:'ext.gif' } );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

(function(jQuery) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: './images/blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[srcjQuery=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);
			
			/* --------------------------------------------------------------
		 	*	Jonathan Russell - 04/01/2010
		 	*	Add fix to allow for extra CSS to be applied from original
		 	*	-------------------------------------------------------------
		 	*/
			var imgPosition = (jQuery(this).css('position')=='absolute') ? 'absolute' : 'relative';
			imgStyle += (typeof(jQuery(this).css('margin-top'))!='undefined') ? 'margin-top:'+jQuery(this).css('margin-top')+';' : '';
			imgStyle += (typeof(jQuery(this).css('margin-right'))!='undefined') ? 'margin-right:'+jQuery(this).css('margin-right')+';' : '';
			imgStyle += (typeof(jQuery(this).css('margin-bottom'))!='undefined') ? 'margin-bottom:'+jQuery(this).css('margin-bottom')+';' : '';
			imgStyle += (typeof(jQuery(this).css('margin-left'))!='undefined') ? 'margin-left:'+jQuery(this).css('margin-left')+';' : '';
			imgStyle += (typeof(jQuery(this).css('float'))!='undefined') ? 'float:'+jQuery(this).css('float')+';' : '';
			//alert(addCSS);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:'+imgPosition+';white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			//strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:'+imgPosition+';display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
				//jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "')";
			}
		});
		
		//fix input with png-source
		jQuery(this).find("input[srcjQuery=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
		
		
		
		/* --------------------------------------------------------------
		 *	Jonathan Russell - 04/01/2010
		 *	Add fix to raise elements to allow interaction
		 *	-------------------------------------------------------------
		 */
		jQuery("input, textarea, a").css({
			'z-index' : '10000',
			'position' : 'relative'
		});
		jQuery('a, a img').css('cursor', 'hand');
	}
	
	return jQuery;

};

})(jQuery);

/* END jquery.pngFix.js */





var display_speed = 'fast', inputBG;

jQuery(document).ready(function()
{
		
		
		jQuery('em.error').remove();
		
		//jQuery('#toprightform').append(jQuery('#form_holder'));
		
		jQuery('img.nav').hover(function(){
			var src = jQuery(this).attr('src');
			var	pos = src.lastIndexOf('.jpg');
			var new_src = src.substring(0,pos);
			 		new_src += '-hover.jpg';
					jQuery(this).attr('src',new_src);
		},function(){
			var src = jQuery(this).attr('src');
			var	pos = src.lastIndexOf('-hover.jpg');
			var new_src = src.substring(0,pos);
			 		new_src += '.jpg';
					jQuery(this).attr('src',new_src);
		});
    
	//call the changeInputBG() function to remove or add back a background image for a form element.
	//#element:  the ID of the input tag with the background image to toggle

	/*	
		UPDATE THIS VARIABLE WITH THE UNIQUE ID OF THE INPUT ELEMENT WITH THE BACKGROUND IMAGE THAT NEEDS TO TOGGLE	
		For example:	var inputElement = jQuery('input#zip');
	*/
	var inputElement = jQuery('input#zip');
	
	inputBG = inputElement.css('background');
	changeInputBG(inputElement);
	
	inputElement
		.focus(function(){ changeInputBG(jQuery(this)); })
		.blur(function(){ changeInputBG(jQuery(this)); })
		.keyup(function(){ changeInputBG(jQuery(this)); });
	
	//automatically focus on the first input element on a page
	//jQuery('form:eq(0) input[type=text]:eq(0)').focus();
	
});//end document.ready


function changeInputBG(el){
	if(el.val() != "") el.css('background-image','none');
	else el.css('background-image',inputBG);
}//changeInputBG()


function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+jQuery", "g"), "");
}

function split_mysql_date(str)
{
  var arr = new Array();
  
  arr['y'] = str.substring(0,4);
  arr['m'] = str.substring(5,7);
  arr['d'] = str.substring(8);
  
  arr['m'] = ltrim(arr['m'], '0');
  arr['d'] = ltrim(arr['d'], '0');
  
  return arr;
}

function array_to_inputs(inputs)
{
	var str = '';
	for(var key in inputs)
	{
		str += key+'='+ inputs[key] + '&';
	}		
	return str;
}//array_to_inputs

function next_el(curr_el, to_el, length)
{
  var isNum = true;
  if(jQuery('#'+curr_el).val().length == length)
  {
    num = IsNumeric(jQuery('#'+curr_el).val());
  
    if(num)
    {
      jQuery('#'+to_el).focus();
    }
    else
    {
      jQuery('#'+curr_el).val('');
    }
  }
  
  
}

function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
	 
	 
function check_year(el)
{
	 if(document.getElementById(el).value.length == 4)
	 {
   // Regular expression used to check if date is in correct format
   var pattern = new RegExp("(19|20)[0-9]{2}");

		var curr_year = Date('Y');
		var today = new Date();
		var curr_year = today.getFullYear();

   if(document.getElementById(el).value.match(pattern) && document.getElementById(el).value <= curr_year)
   {
      var year = document.getElementById(el).value;
      // Attention! Javascript consider months in the range 0 - 11
     
      // This instruction will create a date object
      source_date = new Date(year);  
   }
   else
   {
    document.getElementById(el).value = '';
      return false;
   }
	 }
}//check_year



function add_leading_zero(el)
{
	var v = document.getElementById(el).value;
	 if(v.length == 1)
	 {
   	document.getElementById(el).value = '0'+v;
   }
}//add_leading_zero


function to_digits(el)
{
	var sText = jQuery('#'+el).val();
  var ValidChars = "0123456789.";
  var IsNumber=true;
  var Char;
	var sNewText='';
	
  for (i = 0; i < sText.length; i++) 
  { 
  	Char = sText.charAt(i); 
    if (ValidChars.indexOf(Char) > -1) 
    {
    	sNewText += sText.charAt(i);
    }
	}
	
	if(el == 'phone')
	{
		if(sNewText.length == 10)
		{
			jQuery('#phone').removeClass('error');
		}
	}
	
	
  jQuery('#'+el).val(sNewText);
	
}//to_digits

jQuery(document).ready(function(){ 
	jQuery(document).pngFix(); 
    
    var hoverConfig = {    
        over: showMenu,
        timeout: 100,
        out: hideMenu
    };
    
    jQuery(".nav ul li").each(
        function(ev, li) {              
            jQuery(li).hoverIntent(hoverConfig);       
        }
    );
    
    jQuery(".set").mouseover(function() {
       jQuery(this).find("p").addClass("hover"); 
    });
    jQuery(".set").mouseout(function() {
       jQuery(this).find("p").removeClass("hover"); 
    });
    
    jQuery("#work .view").mouseover(function() {
       jQuery(this).find("p").addClass("hover"); 
    });
    jQuery("#work .view").mouseout(function() {
       jQuery(this).find("p").removeClass("hover"); 
    });
    
    jQuery("#footer .copyright ul li a").mouseover(function() {
       jQuery(this).addClass("hover"); 
    });
    jQuery("#footer .copyright ul li a").mouseout(function() {
       jQuery(this).removeClass("hover"); 
    });
    
    jQuery(".addthis_button_facebook img").mouseover(function() {
       jQuery(this).attr("src", "/wp-content/themes/creativearts/images/blog-facebook_over.png"); 
    });
    jQuery(".addthis_button_facebook img").mouseout(function() {
       jQuery(this).attr("src", "/wp-content/themes/creativearts/images/blog-facebook.png"); 
    });
    
    jQuery(".addthis_button_twitter img").mouseover(function() {
       jQuery(this).attr("src", "/wp-content/themes/creativearts/images/blog-twitter_over.png"); 
    });
    jQuery(".addthis_button_twitter img").mouseout(function() {
       jQuery(this).attr("src", "/wp-content/themes/creativearts/images/blog-twitter.png"); 
    });
    
    jQuery(".addthis_button img").mouseover(function() {
       jQuery(this).attr("src", "/wp-content/themes/creativearts/images/blog-share_over.png"); 
    });
    jQuery(".addthis_button img").mouseout(function() {
       jQuery(this).attr("src", "/wp-content/themes/creativearts/images/blog-share.png"); 
    });
}); 

function showMenu(ev) {
    li = ev.currentTarget;
  if(li.childNodes.length > 1) {
        jQuery(li).addClass('hover');
      jQuery(li.childNodes[2]).fadeIn(250);
  }
}
function hideMenu(ev) {
    li = ev.currentTarget;
  if(li.childNodes.length > 1) {
        jQuery(li).removeClass('hover');
      jQuery(li.childNodes[2]).fadeOut(250);
  }
}
