// SWAP IMAGES FUNCTIONS

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var reNumbers = /^[0-9]*$/;

function only_numbers(string){
   return reNumbers.test(string);
}

var twoWords = /^.+\s+.+$/;

function has_two_words(string){
   return twoWords.test(string);
}

var reEmail = /^[a-zA-Z\-\_\.0-9]+\@[a-zA-Z\-\_\.0-9]+[a-zA-Z0-9]\.[a-zA-Z]{2,3}$/;

function is_email(string){
   return reEmail.test(string);
}

var reNumbers1 = /^[^0-9]+$/;

function no_numbers(string){
   return reNumbers1.test(string);
}

function toogle_display_class(element, last, new_class, old_class, key_item, key_class){
	if(key_item==null) key_item='item';
	if(key_class==null) key_class='class';
	for (var i = 0; i <= last; i++){
		if(i==element){
			$("#"+key_class+i).removeClass(old_class);
			$("#"+key_class+i).addClass(new_class);
						
		}
		else{
			$("#"+key_class+i).removeClass(new_class);
			$("#"+key_class+i).addClass(old_class);			
		}

		$("#"+key_item+i).hide();
	}
	$("#"+key_item+element).show();
}

function cart_quantity(id, step){
	valor = parseInt($("#qt_"+id).val())+step;
	if(valor<0) valor = 0;
	if(valor>99) valor = 99;
	$("#qt_"+id).val(valor);
	document.cart_form.submit();
}

function toogle(element){
	$(element).toggle();
}

function show(element){
	$(element).show();
}

function hide(element){
	$(element).hide();
}

var global_step=0;
function zone1_move(step, total){
	global_step=global_step+step;
	if(global_step<-5) global_step=0;
	if(global_step>=total) global_step=0;
	$.get("/ax_zone1_move.php", {global_step: global_step, total: total},
		function(data){
			if(data!=""){
				$("#items").html(data);
			}
	});
}

function chg_zone1_photo(id){
	$.get("/ax_chg_zone1_photo.php", {item: id},
		function(data){
			if(data!=""){
				$("#zone1_img").html(data);
			}
	});
}

function autochange_zone1_photo(i){
	$.get("/ax_autochange_zone1_photo.php", {i: i},
		function(data){
			if(data!=""){
				$("#zone1_img").html(data);
			}
	});
}

function chg_zone1_photo1(i){
	$("#zone1_img").html('<a href="'+url_photo[i]+'"><img src="'+big_photo[i]+'" width="962" height="333" alt="'+title_photo[i]+'" title="'+title_photo[i]+'" border="0"/></a>');
}

function switch_icn_likes(){
	if($("#img_likes").attr("src") == "/images/icn_likes_on.gif"){
		$("#img_likes").attr("src", "/images/icn_likes.gif");
	}
	else{
		$("#img_likes").attr("src", "/images/icn_likes_on.gif")
	}
}

function like(type, id){
	$.get("/ax_like.php", {type: type, ref_id: id},
		function(data){
			if(data!='') $("#nr_likes").html(data);	
	});
	return false;
}

function chp_photo(img_path, img_width, img_height, url_path){
	document.images["prod_photo"].src = img_path;
	document.images["prod_photo"].width = img_width;
	document.images["prod_photo"].height = img_height;
	$("#prod_photo_url").attr("href", url_path);
}

function ins_comment(type, ref_id){
	var cm_text = $("#comm_text").val();
	var cm_name = $("#comm_name").val();
	var cm_email = $("#comm_email").val();
	
	$.get("/ax_ins_comment.php", {type: type, ref_id: ref_id, cm_name: cm_name, cm_email: cm_email, cm_text: cm_text},
		function(data){
			$("#ins_comm").html(data);	
	});
	return false;
}

function cycle_zone1(count){
	setTimeout(function() {
		
	}, 2000);
}

function get_window_dimentsions(){
	var window_dimentsions = {Width: 0, Height: 0};
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	window_dimentsions.Width=myWidth;
	window_dimentsions.Height=myHeight;
	return window_dimentsions;
}

function center_div(key){	
	var window_dimentsions = get_window_dimentsions();	
	var x, y;
	x=Math.round(window_dimentsions.Width / 2);
	x= x-Math.round(($(key).width()/2));
	
	y=Math.round(window_dimentsions.Height / 2);
	y=y-Math.round(($(key).height()/2));
	
	if(key==".makingof") y=y-70;
	if(key==".makingof_video") y=y-115;

	$(key).css('left', x + 'px');
	$(key).css('top', y + 'px');
}

function add_fav(id){
	$.get("/ax_add_fav.php", {ref_id: id},
		function(data){
			$("#fav_resp").html(data);	
	});
	return false;
}

function remove_fav(id){
	$.get("/ax_remove_fav.php", {ref_id: id},
		function(data){
			$('#remove_prod_'+id).hide("slow");
	});
	return false;
}

function testing(){
	("div").everyTime(1000,function() {
		alert('ola')
	});
}