window.addEvent('domready', function() {	

var dwDefaults=function (s){
	s.each(function(el){
		el.set('value',el.get('title'));
		el.addEvent('focus', function() {
			if(el.get('value') == el.get('title')) { el.set('value',''); }
		});
		el.addEvent('blur', function() {
			if(el.get('value') == '') { el.set('value',el.get('title')); }
		});
 
   });
}
	dwDefaults($$('input.defs'));


  $$('.ball_btn').each(function(img) {
	var idiscr = img.get('id');	
	var setlang = parseInt(img.get('rev'));		
	switch(setlang)
{
case 3:
	var setpx_on="-126px -126px";
	var setpx_off="-126px 0";
  break;
case 2:
	var setpx_on="-63px -126px";
	var setpx_off="-63px 0";
  break;
default:
case 1:
	var setpx_on="0px -126px";
	var setpx_off="0px 0";
}		

	img.addEvent('mouseover', function() { 
		 if(idiscr!='ball_btn'){
	img.setStyle('background-position',setpx_on);
		} 				   
	});
	img.addEvent('mouseout', function() { 
		 if(idiscr!='ball_btn'){
	img.setStyle('background-position',setpx_off); 	
		}
	//alert(setpx)	;	
									  
	});

  });
  
if(haveleft){
		var mySlide = new Fx.Slide('submenu').hide();
		$('submenu').setStyle('display','none'); 
		var onoff = $('submenu').get('rel');
		if(onoff=="on"){
		}else{
		// $('submenu').setStyle('display','none'); 
		//	mySlide.hide(); 
			
		}

$('toggle_btn').addEvents({
		'mouseenter': function(e){
				 $('submenu').setStyle('display','block'); 
				e = new Event(e);
				$('submenu').slide('in');


		},
		'mouseleave': function(){
				$('submenu').slide('out');
		}
	});
}
	
	/*
  	$$('.da_cpb li').each(function(img) {
	 var p_height =img.getParent().getStyle('height');
		img.setStyle('height',p_height);					   
	});
*/
  	$$('.text-input-ex').each(function(img) {

	img.addEvent('click', function() { 
	this.setStyle('background-position','20px 40px'); 
	//this.setStyle('border','1px solid #d1ac66'); 
	});
	img.addEvent('keydown', function() { 
	this.setStyle('background-position','20px 40px'); 
	//this.setStyle('border','1px solid #d1ac66'); 
	});
	img.addEvent('blur', function() { 
	chval=this.get('value');
	backbg=this.getParent().get('rel');

	if(chval==''){
			this.setStyle('background-position',backbg); 
		}
	});

  });
	 
  	$$('.text-area').each(function(img) {

	img.addEvent('click', function() { 
	this.setStyle('background-position','0 -140px'); 
	//this.setStyle('border','1px solid #d1ac66'); 
	});
	img.addEvent('keydown', function() { 
	this.setStyle('background-position','0 -140px'); 
	//this.setStyle('border','1px solid #d1ac66'); 
	});
	img.addEvent('blur', function() { 
	chval=this.get('value');
	backbg=this.getParent().get('rel');

	if(chval==''){
			this.setStyle('background-position',backbg); 
		}
	});

  });
	 

  	  	$$('.mix_btn').each(function(img) {
									 
									 
	img.addEvent('mouseover', function() { 
	this.set('opacity','0.5'); 
	});
	img.addEvent('mouseout', function() { 
	this.set('opacity','1'); 
	});
	/*
	img.addEvent('click', function() { 
	window.location.href=this.getElements('a.d_red');
	//this.toggle();
	});
	*/
  });
		
  	  	$$('.round_btn').each(function(img) {
									 
									 
	img.addEvent('mouseover', function() { 
	this.set('opacity','0.5'); 
	});
	img.addEvent('mouseout', function() { 
	this.set('opacity','1'); 
	});
	img.addEvent('click', function() { 
	window.location.href=this.getElements('a.white');
	});
  });
		

		

  
  	
	 	$$('.change_thumb').each(function(img) {
									 
	var   thisalt_id =img.getElements('img.this_thumb').get('alt');
	var aathisalt_id= new String(thisalt_id)	
 var thisalt_src =img.getElements('img.this_thumb').get('src');
	var aathisalt_src= new String(thisalt_src)	
	

	var   rhw =img.get('lang').split(",");
	
	img.addEvent('mouseover', function() { 


	$(aathisalt_id).setAttribute("height",rhw[1]);
	$(aathisalt_id).setAttribute("width",rhw[0]);
	
	
	$(aathisalt_id).getParent().setAttribute("rev",this.get('id'));
	$(aathisalt_id).setAttribute("src",this.get('rev'));

	});
	img.addEvent('mouseout', function() { 
	//this.setStyle('background-color','#ffffff'); 
	});
	img.addEvent('click', function() { 
	window.location.href=this.getElements('a.bold');
	//this.toggle();
	});
  });
		
  


	 	$$('.change_gallery').each(function(img) {
									 
	var   thisalt_id =img.getElements('img.this_thumb').get('alt');
	var aathisalt_id= new String(thisalt_id);	
 var thisalt_src =img.getElements('img.this_thumb').get('src');
	var aathisalt_src= new String(thisalt_src)	;
	
 var mainid_val =img.getParent().get('title');
	var mainid= new String(mainid_val)	;
	
	var   rhw =img.get('lang').split(",");
	
	img.addEvent('mouseover', function() { 


	$(aathisalt_id).setAttribute("height",rhw[1]);
	$(aathisalt_id).setAttribute("width",rhw[0]);
	
	
	$(aathisalt_id).getParent().setAttribute("rev",this.get('id'));
	$(aathisalt_id).setAttribute("src",this.get('rev'));

	});
	img.addEvent('mouseout', function() { 
	//$(aathisalt_id).setAttribute("src",this.get('rev'));

	var thissrc=$(mainid).get('rev');
	$(aathisalt_id).setAttribute("src",thissrc);


	});
	img.addEvent('click', function() { 
	window.location.href=this.getElements('a.bold');
	//this.toggle();
	});
  });			
/*
  
    	  	$$('.round_btn').each(function(img) {
									 
	img.addEvent('mouseover', function() { 
	
if(this.get('id')!='red_cbtn')	{
	this.getElements('b.red_b').setStyle('background-position','0% 0%');
	this.getElements('a.red_a').setStyle('background-position','100% 0%');
	this.getElements('span.round_arrow_btn').setStyle('background-position','100% 0%');
	this.getElements('a.red_a').setStyle('text-decoration','none');
}
	});
	img.addEvent('mouseout', function() { 
if(this.get('id')!='red_cbtn')	{
	this.getElements('b.red_b').setStyle('background-position','0% 100%');
	this.getElements('a.red_a').setStyle('background-position','100% 100%');
	this.getElements('span.round_arrow_btn').setStyle('background-position','100% 100%');
}
	});
	img.addEvent('click', function() { 
	window.location.href=this.getElements('a.red_a');
	//this.toggle();
	});
  });
*/	

  
});	



var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
win=window.open(mypage,myname,settings);}



	function setdisplay(setid){
	var op_all =$(setid);

	if(op_all.get('rev')==1){
	op_all.setStyle('display','none');
	op_all.setAttribute('rev','0');
	}else{
	op_all.setStyle('display','block');
	op_all.setAttribute('rev','1');
	//window.location.href="#comment";
	}
	
}

var pwin;
function printImg(printOption) {
    var imageToPrint = document.getElementById("imgMain").src;
    var html = imageToPrint;
        pwin = window.open(html, "_blank");
    setTimeout("pwin.print()" ,20);
}

// JavaScript Document
function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name + "=" + escape(value) +	((expiredays==null) ? "" : ";expires=" + exdate.toGMTString());
}
	  
function mySearch() {
	var searchText = $('txtsearch').value;
	setCookie("hmsearch", searchText, 1);
	window.location = "./?p=search";
}
