
function searchImageHover()
{
document.getElementById('search_button').style.background='url(wp-content/themes/rose/images/search_icon_hover.png)' ;
}
function searchImageOut()
{
document.getElementById('search_button').style.background='url(wp-content/themes/rose/images/search_icon.png)' ;
}


function rssImageHover()
{
document.getElementById('rss_feed').style.background='url(wp-content/themes/rose/images/rss_icon_hover.png) no-repeat 70px 0px' ;
document.getElementById('rss_feed').style.color='#A70404' ;
}
function rssImageOut()
{
document.getElementById('rss_feed').style.background='url(wp-content/themes/rose/images/rss_icon.png) no-repeat 70px 0px' ;
document.getElementById('rss_feed').style.color='#5c5c5c' ;
}



function linkImageHover()
{
document.getElementById('linkedin').style.background='url(wp-content/themes/rose/images/linkedin_icon_hover.png) no-repeat 50px 0px' ;
document.getElementById('linkedin').style.color='#A70404' ;

}
function linkImageOut()
{
document.getElementById('linkedin').style.background='url(wp-content/themes/rose/images/linkedin_icon.png) no-repeat 50px 0px' ;
document.getElementById('linkedin').style.color='#5c5c5c' ;
}



function changeImageHover()
{
document.getElementById('btn_newsletter').style.background='url(wp-content/themes/rose/images/newsletter_button_hover.jpg)' ;
}
function changeImageOut()
{
document.getElementById('btn_newsletter').style.background='url(wp-content/themes/rose/images/newsletter_button.jpg)' ;
}


function commentHover()
{
document.getElementById('submit').style.background='url(wp-content/themes/rose/images/btn_post_comment_hover.gif)' ;
}
function commentOut()
{
document.getElementById('submit').style.background='url(wp-content/themes/rose/images/btn_post_comment.gif)' ;
}

function onmouseout()
{
//document.getElementById('submit').style.background='url(wp-content/themes/rose/images/btn_post_comment.gif)' ;
}

//submitComment
function submitComment(url)
 {
    var valid = new Validation('commentform', {useTitles : true},{onSubmit : false});
    var result = valid.validate();
     if(result == true )
     {
           sendComment(url);
     } 
 }
 
function sendComment(url)
{
    Dialog.info("Please wait...",{width:200, height:100, showProgress: true}); 
    var data = $('commentform').serialize();
    Form.reset('commentform');
               new Ajax.Request(url, {
					  method: 'post',
					  parameters:data,
					  onSuccess: function(transport) {
                                      Dialog.closeInfo();
                      Dialog.alert(transport.responseText, {className: "alphacube", width:350, okLabel: "Close",ok:function(win){Dialog.closeInfo();}});  
                       setTimeout(hideDialog, 9000) 
                  }
                   
           });      
  
}
//contact us 
 function submitContact(urlpage)
 {
    var valid = new Validation('frm_contact', {useTitles : true},{onSubmit : false});
    var result = valid.validate();
  		
     if(result == true )
     {    
     	 	sendContact(urlpage);                    	
     	
     } 
 }
 
function sendContact(url)
{
    
    Dialog.info("Please wait...",{width:200, height:100, showProgress: true}); 
    var data = $('frm_contact').serialize();
    Form.reset('frm_contact');
    new Ajax.Request(url, {
					  method: 'post',
					  parameters:data,
					  onSuccess: function(transport) {
                                      Dialog.closeInfo();
                      Dialog.alert(transport.responseText, {className: "alphacube", width:350, okLabel: "Close",ok:function(win){Dialog.closeInfo();}});  
                       setTimeout(hideDialog, 9000) 
                  }
                   
           });      
  
}

function hideDialog()
{
	Dialog.closeInfo();
}
// LTrim(string) : Returns a copy of a string without leading spaces.
function ltrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

//RTrim(string) : Returns a copy of a string without trailing spaces.
function rtrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}

// Trim(string) : Returns a copy of a string without leading or trailing spaces
function trim(str) {
   return rtrim(ltrim(str));
}
/**
 * Verifies if the string is in a valid email format
 * @param	string
 * @return	boolean
 */
function isEmail( text )
{
	var pattern = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp( pattern );
	return regex.test( text );
}
