// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function visibilities(name, id, method){
    new Ajax.Updater('visible'+id, name+'/'+id, {asynchronous:true, evalScripts:true, method: method});
		return false;
}
var Photo = {              
           show: function(url) {                    
                $('photo').src = url; 
                $('mask').show(  ); 
                $('photo-wrapper').visualEffect('appear', {duration:0.5}); 
           },
           hide: function(  ) {     
                $('mask').hide(  ); 
                $('photo-wrapper').visualEffect('fade', {duration:0.5}); 
           },
           minimize: function(step) {
                width_s_px = $('photo').getStyle('width');
                width_s = width_s_px.replace(/px/g,"")
                width = parseInt(width_s) - step
                width += "px"
                $('photo').setStyle({"width": width})                               
           },
           maximize: function(step) {
                width_s_px = $('photo').getStyle('width');
                width_s = width_s_px.replace(/px/g,"")
                width = parseInt(width_s) + step
                width += "px"
                $('photo').setStyle({"width": width})                               
           }
           
        }
        

function show_thumb_image(href) {
   var img = new Image();
   img.src = href;
   var attr = (img.width > img.height)? "width='192'" : "height='192'";                 
   document.write("<img src='" + href + "' border='1' " + attr + "/>");
}

function resizer(element) {
    if (element.height > element.width) {
        element.height = 192;
    }else {
        element.width = 192;
    }
}

function randomString() {
    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
    var string_length = 8;
    var randomstring = '';
    for (var i=0; i<string_length; i++) {
            var rnum = Math.floor(Math.random() * chars.length);
            randomstring += chars.substring(rnum,rnum+1);
    }
    return randomstring;
}

function resize_to_148(element) {
    if (element.height > element.width) {
        element.height = 148;
    }else {
        element.width = 148;
    }
}
var win = null; 
function new_window()
{
	win = new Window(
                    { id: "login",
                      className :"alphacube",
                      resizable: false,
                      width:550, 
                      height:260,
                      closable:false,
                      minimizable:false,
                      maximizable:false,
                      draggable:false,
                      destroyOnClose:true,
                      showEffectOptions:{afterFinish:function(){$('customer_email').focus();}}
                    }
                    );
  
  win.setContent('form_login');  
 	win.showCenter();
  //win.setConstraint(true, {left:10, right:10, top: 30, bottom:10})
	//win.toFront();
	return false;
}

function new_window2()
{ 
	win = new Window(
                    { id: "message",
                      className :"alphacube",
                      resizable: false,
                      width:550, 
                      height:260,
                      closable:false,
                      minimizable:false,
                      maximizable:false,
                      draggable:false,
                      destroyOnClose:true,
                      showEffectOptions:{afterFinish:function(){$('customer_email').focus();}}
                    }
                    );                      
  win.setContent('form_message');  
	win.showCenter();
  //win.setConstraint(true, {left:10, right:10, top: 30, bottom:10})
	//win.toFront();
	return false;
}             
              
function screenHeight() {
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	myHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    	//IE 4 compatible
    	myHeight = document.body.clientHeight;
  	}
	return myHeight;
	}
	
	function screenWidth() {
	var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	myWidth = document.documentElement.clientWidth;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    	//IE 4 compatible
    	myWidth = document.body.clientWidth;
  	}
	return myWidth;
	}