function createCookie( name, value, days ) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function currentOffset() {
	d = new Date();
	return d.getTimezoneOffset();
}

function saveTZ() {
	var tz_offset = readCookie( 'TZ' );
	var cur_offset = currentOffset();
	if( ( ! tz_offset ) || ( tz_offset != cur_offset ) ) {
		createCookie( 'TZ', cur_offset, 1 );
	}
}

saveTZ();

function switchCat( id ) {
	if( $( '#subcat_' + id ).css( 'display' ) == 'none' ) {
		$( '#subcat_' + id ).show();
		$( '#key_' + id ).removeClass( 'vidjet-key' );
		$( '#key_' + id ).addClass( 'vidjet-key-active' );
	} else {
		$( '#subcat_' + id ).hide();
		$( '#key_' + id ).removeClass( 'vidjet-key-active' );
		$( '#key_' + id ).addClass( 'vidjet-key' );
	}
}

function ResetName( text ) {
	if ( $( '#header-search-field' ).val() == text ) $( '#header-search-field' ).val( '' );
	$( '#is_search' ).val( 1 );
}

function ResetNameOut( text ) {
	if ( $( '#header-search-field' ).val() == '' ) $( '#header-search-field' ).val( text );
}

function showLang() {
	var element=document.getElementById( 'header-language-select' );
	var myleft = 0;
	var mytop = element.offsetHeight;
	while (element) {
		myleft+=element.offsetLeft;
		mytop+=element.offsetTop;
		element=element.offsetParent;
	}
	clearTimeout( lang_timer );
	$( '#language-menu' ).css( 'left', myleft + 'px' ).css( 'top', mytop + 'px' ).fadeIn( "fast" );
}

function hideLang() {
	lang_timer = setTimeout( function() { $( '#language-menu' ).fadeOut( "fast" ); }, hide_delay );
}

function stopHide() {
	clearTimeout( lang_timer );
}

function setOsOptions( os, suffix, cat_list ) {
	$( '#td_cat_selector' + suffix ).html( $( '#cat_selector' + suffix ) );
	$( '#Cat_1' + suffix ).html( $( '#Cat_1' + suffix + ' > option:first' ) );
	$( '#subCat_1' + suffix ).html( $( '#subCat_1' + suffix + ' > option:first' ) );
	for( i=0; i < cat_list[os].length; i++ ) {
		$( '#Cat_1' + suffix ).append( '<option value="' + cat_list[os][i].id + '">' + cat_list[os][i].title  + '</option>' );
	}
	selectSubCategory( suffix );
}

function removeFromFavourites( id, abbr ) {
	$.post( "/ajax/remove_favourites/", { abbr: abbr }, function( data ) {
		if( data.error ) {
			alert( data.error );
		} else {
			$( '#' + id ).before( data.text );
			$( '#' + id ).remove();
		}
	}, "json" );
}

function removeFromFavouritesDetails( id, abbr ) {
	$.post( "/ajax/remove_favourites/", { abbr: abbr }, function( data ) {
		if( data.error ) {
			alert( data.error );
		} else {
			$( '#' + id ).attr( 'href', 'javascript:addToFavourites(\'' + id + '\',\'' + abbr + '\')' ).html( data.link_text );
		}
	}, "json" );
}

function addToFavourites( id, abbr ) {
	$.post( "/ajax/add_favourites/", { abbr: abbr }, function( data ) {
		if( data.error ) {
			alert( data.error );
		} else {
			$( '#' + id ).attr( 'href', 'javascript:removeFromFavouritesDetails(\'' + id + '\',\'' + abbr + '\')' ).html( data.link_text );
		}
	}, "json" );	
}

function removeReview( id, hash ) {
	$( '#' + id ).hide();
	$.post( "/ajax/remove_review/", { hash: hash }, function( data ) {
		if( data.error ) {
			$( '#' + id ).show();
			alert( data.error );
		} else {
			$( '#' + id ).html( $( '#' + id + ' h3 a' ).html() + ' Deleted ' );
			$( '#' + id ).show();
		}
	}, "json" );
}

function submitEditReviewForm () {
	$( '#' + $( '#back_id' ).val() + ' form' ).ajaxForm({
		beforeSubmit: function(a,f,o) {
		},
		success: function(data) { 
			if( data.result ) {
				$( '#' + $( '#back_id' ).val() + ' .positive-text' ).html( data.positive );
				$( '#' + $( '#back_id' ).val() + ' .negative-text' ).html( data.negative );
				$( '#' + $( '#back_id' ).val() + ' .details-text' ).html( data.details );
				$( '.edit-review-form' ).html( '' );
				$( ' .userComment' ).show();
			} else {
				alert( data.error );
			}
			$( '#' + $( '#back_id' ).val() + ' form' ).trigger('reset');
		},
		dataType:  'json'
	});
	$( '#' + $( '#back_id' ).val() + ' form' ).submit();
}

function editReview( id, hash ) {
	var positive = $( '#' + id + ' .positive-text' ).html();
	var negative = $( '#' + id + ' .negative-text' ).html();
	var details = $( '#' + id + ' .details-text' ).html();
	var rtitle = $( '#' + id + ' h3 a' ).html();
	//var view = $( '#' + id ).html();
	//var form = $( '#review_edit_form' ).html();
	/*
	alert( $( '#editform_back' ).val() + '--->' + id );
	if( backid  = $( '#editform_back' ).val() ) {
		tmp = $( '#' + backid ).html();
		$( '#' + backid ).html( form );
		form = tmp;
	} */
	//$( '#review_edit_form' ).html( view );
	//$( '#' + id ).html( form );
	$( '.edit-review-form' ).html( '' );
	$( ' .userComment' ).show();
	$( '#' + id + ' .edit-review-form' ).html( $( '#review_edit_form' ).html() );
	$( '#' + id + ' .userComment' ).hide();
	$( '#' + id + ' .editform_title' ).html( rtitle );
	$( '#' + id + ' .editform_positive' ).val( positive );
	$( '#' + id + ' .editform_negative' ).val( negative );
	$( '#' + id + ' .editform_details' ).val( details );
	$( '#' + id + ' .editform_hash' ).val( hash );
	$( '#back_id' ).val( id );
}

function selectCategory( obj, target ) {
	if( obj.value > 0 ) {
		$( '#sub' + obj.id ).attr( 'disabled', 'true' );
		$( '#form_submit' + target ).attr( 'disabled', 'true' );
		$.post( "/ajax/sub_category_list/"+obj.value, "", function( data ){
			$( '#sub' + obj.id ).html( $( '#sub' + obj.id + ' > option:first' ) );
			for( i=0; i<data.length; i++ ) {
				$( '#sub' + obj.id ).append('<option value="' + data[i].id + '">' + data[i].title + '</option>');
			}
			$( '#sub' + obj.id ).css( 'disabled', 'false' );
			/*
			next = parseInt( obj.id.substr(4) ) + 1;
			if( $( '#Cat_' + next + target ).html() == null ) {
				var re = /Cat_1/g;
				$( '#td_cat_selector' + target ).append( $( '#cat_selector' + target ).html().replace( re, 'Cat_' + ( next ) ).replace( /selected/g, '' ) );
				$( '#td_cat_selector' + target + ' > .form_error' ).empty();
			}*/
			$( '#sub' + obj.id ).attr( 'disabled', '' );
			//$( '#form_submit' + target ).attr( 'disabled', '' );
	  	}, "json" );
	}
}

function remTemp( id ) {
	$( '#' + id + ' option[value=0]' ).remove();
}

function addCat( target ) {
	var next = parseInt( $( 'select[name="soft' + target + '[category][]"]:last' ).attr( 'id' ).substr(4) ) + 1;
	if( $( '#Cat_' + next + target ).html() == null ) {
		var re = /Cat_1/g;
		$( '#td_cat_selector' + target ).append( $( '#cat_selector' + target ).html().replace( re, 'Cat_' + ( next ) ).replace( /selected/g, '' ) );
		$( '#subCat_' + next + target + ' :not(:first)' ).remove();
		$( '#td_cat_selector' + target+ ' > .form_error' ).remove();
		$( '#add_cat_button' + target ).hide();
	}
}

function deleteCat( cat, target ) {
	if( $( '#td_cat_selector' + target + ' .cat_selector' ).length > 2 ) {
		if( cat == 'Cat_1' ) {
			$( '#' + cat + target ).html( $( '#td_cat_selector' + target + ' select[name="soft' + target + '[category][]"]:eq(1)' ).html() );
			$( '#' + cat + target ).val( $( '#td_cat_selector' + target + ' select[name="soft' + target + '[category][]"]:eq(1)' ).val() );
			$( '#sub' + cat + target ).html( $( '#td_cat_selector' + target + ' select[name="soft' + target + '[subcategory][]"]:eq(1)' ).html() );
			$( '#sub' + cat + target ).val( $( '#td_cat_selector' + target + ' select[name="soft' + target + '[subcategory][]"]:eq(1)' ).val() );
			$( '#td_cat_selector' + target + ' select[name="soft' + target + '[category][]"]:eq(1)' ).remove();
			$( '#td_cat_selector' + target + ' select[name="soft' + target + '[subcategory][]"]:eq(1)' ).remove();
			$( '#td_cat_selector' + target + ' img[class="del_button_cont"]:eq(1)' ).remove();
		} else {
			$( '#' + cat + target ).remove();
			$( '#sub' + cat + target ).remove();
			$( '#delete_cat_button' + target + '_' + cat ).remove();
		}
		selectSubCategory( target );
	}
	var sel = $( '#td_cat_selector' + target + ' .cat_selector' );  
	if( sel.length <= 2 ) {
		if( $( sel[0] ).val() * $( sel[1] ).val() > 0 ) {
			$( '#add_cat_button' + target ).show();
		}
	}
}

function selectSubCategory( target ) {
	var sel = $( 'select[name="soft' + target + '[subcategory][]"]' );
	$( '#add_cat_button' + target ).show();
	$( '#form_submit' + target ).attr( 'disabled', '' );
	for( i = 0; i < sel.length; i++ ) {
		if( $( sel[i] ).val() == 0 ) {
			$( '#form_submit' + target ).attr( 'disabled', 'disabled' );
			$( '#add_cat_button' + target ).hide();
		}
	} 
}

function checkLatin( evt ) {
	var key = ( evt.keyCode ? evt.keyCode : evt.charCode ? evt.charCode : evt.which ? evt.which : void 0 );
	var result = false;
	if( ( key >= 97 && key <=122 ) || ( key >= 65 && key <=90 ) || ( key >= 48 && key <=57 ) ) {
		result = true;
	} else {
		switch ( key ) {
			case 8:
			case 9:
			case 13:
			case 46:
			case 37:
			case 38:
			case 39:
			case 40:
			case 32:
			case 95:
			case 45:
			case 46:
				result = true;
				break;
			default: 
				result = false;
		}
		
	}
	return result;
}

function switchBlock( hideID, showID ) {
	$( '#' + hideID ).hide();
	$( '#' + showID ).show();
}

function submitLogoForm( id ) {
	$('#' + id ).ajaxForm({
		beforeSubmit: function(a,f,o) {
		},
		success: function(data) { 
			if( data.result ) {
				img = $( '#logoURL' ).attr( 'src', data.url );
				switchBlock( 'logo_upload_form', 'logo_preview_form' );
			} else {
				alert( data.error );
			}
			$( '#' + id ).trigger('reset');
		},
		dataType:  'json'
	});
	$( '#' + id ).submit();
}

function submitReviewForm( id ) {
	$('#' + id ).ajaxForm({
		beforeSubmit: function(a,f,o) {
			$( '#write_review form' ).hide();
			$( '#wait_block' ).show();
		},
		success: function(data) { 
			if( data.result ) {
				$( '#review_new' ).html( $('#review_area').html() );
				if( data.result.positive )
					$( '#review_new .positive' ).after( ' ' + data.result.positive );
				else 
					$( '#review_new .positive' ).hide();
				if( data.result.negative )
					$( '#review_new .negative' ).after( ' ' + data.result.negative );
				else
					$( '#review_new .negative' ).hide();
				if( data.result.details )
					$( '#review_new .details' ).after( ' ' + data.result.details );
				else
					$( '#review_new .details' ).hide();
				$( '#review_new h3 b' ).html( data.result.username );
				$( '#review_new h3 span' ).html( data.result.time );
				$( '#write_review' ).empty();
			} else {
				$( '#write_review form' ).show();
				$( '#wait_block' ).hide();
				alert( data.error );
			}
			$( '#' + id ).trigger('reset');
		},
		dataType:  'json'
	});
	$( '#' + id ).submit();
}

function showAllReviews( abbr ) {
	$( '#show_all' ).html( $( '#wait_block' ).html() );
	$.post( "/ajax/all_reviews/" + abbr, "", function( data ) {
		if( data.error ) {
			alert( data.error );
		} else {
			$( '#show_all' ).empty();
			for( i = 1; i < data.reviews.length; i++ ) {
				if( $( '#' + data.reviews[i].hash ).html() ) {
					continue;
				}
				$( '#review_all' ).append( $('#review_area').html() );
				if( data.reviews[i].positive )
					$( '#review_all .positive:last' ).after( ' ' + data.reviews[i].positive );
				else
					$( '#review_all .positive:last' ).hide();
				if( data.reviews[i].negative )
					$( '#review_all .negative:last' ).after( ' ' + data.reviews[i].negative );
				else
					$( '#review_all .negative:last' ).hide();
				if( data.reviews[i].details )
					$( '#review_all .details:last' ).after( ' ' + data.reviews[i].details );
				else
					$( '#review_all .details:last' ).hide();
				$( '#review_all h3 b:last' ).html( data.reviews[i].username );
				$( '#review_all h3 span:last' ).html( data.reviews[i].time );
			}
		}
	}, "json" );	
}

function submitSSForm( id ) {
	$('#' + id ).ajaxForm({
		beforeSubmit: function(a,f,o) {
			$( '#' + id + ' input[type="file"]' ).hide().before( '<div align="center" id="wait_' + id + '">' + $( '#wait_block' ).html() + '</div>' );
		},
		success: function(data) {
			if( data.result ) {
				var img = $( '#img_tpl' ).html();
				var last_img = $( '#screenshots_area' + ' div.softScreenCont:last' );
				var newID = 'ss_' + ( parseInt( last_img.attr( 'id' ).substr( 3 ) ) + 1 );
				img = img.replace( /ex_0/gm, newID );
				img = img.replace( /\[hash\]/gm, data.hash );
				img = img.replace( /class="screenshot_preview" src=".*"/gm, 'class="screenshot_preview" src="' + data.preview + '"' );
				$('#screenshots_area').append( img );
			} else {
				alert( data.error );
			}
			$( '#wait_' + id ).remove();
			$( '#' + id + ' input[type="file"]' ).show();
			$( '#' + id ).trigger('reset');
		},
		dataType:  'json'
	});
	$( '#' + id ).submit();
}

function delSoftScreenShot( id, hash ) {
	$( '#' + id + ' a' ).before( '<div id="wait_' + id + '_' + hash + '">' + $( '#wait_block' ).html() + '</div>' ).hide();
	$.post( "/ajax/del_screenshot/" + hash, "", function( data ) {
		if( data.error ) {
			$( '#wait_' + id + '_' + hash ).remove();
			$( '#' + id + ' a' ).show();
			alert( data.error );
		} else {
			$( '#' + id ).remove();
		}
	}, "json" );
}

function delPodcast( id, soft_abbr, hash ) {
	$( '#' + id + ' a' ).before( '<div id="wait_' + id + '_' + hash +'">' + $( '#wait_block' ).html() + '</div>' ).hide();
	$.post( "/ajax/del_podcast/", { abbr: soft_abbr, hash: hash }, function( data ) {
		if( data.error ) {
			$( '#wait_' + id + '_' + hash ).remove();
			$( '#' + id + ' a' ).show();
			alert( data.error );
		} else {
			$( '#' + id ).remove();
		}
	}, "json" );
}

function submitPodcastForm( id ) {
	$( '#' + id ).ajaxForm({
		beforeSubmit: function(a,f,o) {
			$( '#' + id + ' input[type="button"]' ).attr( 'disabled', 'disabled' );	
		},
		success: function(data) { 
			if( data.result ) {
				oldID = $( '.podcast-table:last' ).attr( 'id' ).substr( 11 );
				if( ( oldID == '[NUM]' ) || ! ( newID = parseInt( oldID ) + 1  ) )
					newID = 0;
				html_tpl = $( '#podcast_content' ).html();
				html_tpl = html_tpl.replace( /\[NUM\]/gm, newID );
				html_tpl = html_tpl.replace( /\[HASH\]/gm, data.hash );
				$( '#podcast_list' ).append( html_tpl );
				$( '#podcast_list p:last' ).html( data.comment );
				podcastAppend( 'audioplayer_' + newID, data.link );
				$( '#podcast_tip span' ).html( '0' );
			} else {
				alert( data.error );
			}
			$( '#' + id + ' input[type="button"]' ).attr( 'disabled', '' );
			$( '#' + id ).trigger('reset');
		},
		dataType:  'json'
	});
	$( '#' + id ).submit();
}

function modifyPodcast( id, abbr, hash ) {
	$( '#podcastForm' ).hide();
	$( '#' + id ).before( '<div align="center" id="wait_podcast">' + $( '#wait_block' ).html() + '</div>' );
	$.post( "/ajax/get_podcast/", { abbr: abbr, hash: hash }, function( data ) {
		$( '#wait_podcast' ).remove();
		if( data.error ) {
			$( '#podcastForm' ).show();
			alert( data.error );
		} else {
			$( '#podcast_preview' ).empty();
			podcastAppend( 'podcast_preview', data.link );
			$( '#podcast_edit_hash' ).val( hash );
			$( '#modify_podcast_link' ).val( data.link );
			$( '#modify_podcast_info' ).val( data.desc );
			$( '#podcast_edit_id' ).val( parseInt( id.substr( 11 ) ) );
			$( '#editPodcastForm .char_count' ).html( data.desc.length );
			$( '#editPodcastForm' ).show();
			$( '#editPodcastForm' ).trigger( 'scrollIntoView', 'true' );
			$( '#modify_podcast_info' ).trigger( 'focus' );
		}
	}, "json" );
}

function submitEditPodcastForm( id ) {
	$( '#' + id ).ajaxForm({
		beforeSubmit: function(a,f,o) {
			$( '#' + id + ' input[type="button"]' ).attr( 'disabled', 'disabled' );	
			$( '#' + id ).hide().before( '<div align="center" id="wait_edit_video">' + $( '#wait_block' ).html() + '</div>' );
		},
		success: function(data) { 
			if( data.result ) {
				$( '#wait_edit_video' ).remove();
				podcastAppend( 'audioplayer_' + data.id, data.link );
				$( '#audiocomment_' + data.id ).html( data.comment );
				$( '#podcastForm' ).show();
				$( '#' + id + ' input[type="button"]' ).attr( 'disabled', '' );
				$( '#' + id ).trigger('reset');
			} else {
				$( '#wait_edit_video' ).remove();
				alert( data.error );
			}
			$( '#' + id + ' input[type="button"]' ).attr( 'disabled', '' );
			$( '#' + id ).trigger('reset');
		},
		dataType:  'json'
	});
	$( '#' + id ).submit();
	
}

function podcastInit( swfString ) {
	AudioPlayer.setup( swfString, {
		width: 290,
		initialvolume: 100,
		transparentpagebg: "yes",
		left: "000000",
		lefticon: "FFFFFF"
	} );
}

function podcastAppend( id, audioPath ) {
	try {
		AudioPlayer.embed( id, {soundFile: audioPath} );  
	} catch(exception) {
		$( '#' + id ).html( '<img src="' + ImageRootURL + 'audio-player.jpg">' );
	}
}

function submitYouTubeForm( id ) {
	$( '#' + id ).ajaxForm({
		beforeSubmit: function(a,f,o) {
			$( '#' + id + ' input[type="button"]' ).attr( 'disabled', 'disabled' );
		},
		success: function(data) { 
			if( data.result ) {
				var img = $( '#video_tpl' ).html();
				var last_img = $( '#' + id + ' .softVideo:last' );
				var newID = 'video_' + ( parseInt( last_img.attr( 'id' ).substr( 6 ) ) + 1 );
				img = img.replace( /videot0/gm, newID );
				img = img.replace( /\[hash\]/gm, data.hash );
				img = img.replace( /src="[^>]*src[^>]*"/gm, 'src="' + data.preview + '"' );
				$( '#video_area div.imgCont' ).append( img );
				$( '#youtube_tip span' ).html( '0' );
			} else {
				alert( data.error );
			}
			$( '#' + id + ' input[type="button"]' ).attr( 'disabled', '' );
			$( '#' + id ).trigger('reset');
		},
		dataType:  'json'
	});
	$( '#' + id ).submit();
}

function delSoftYouTubeVideo( id, abbr, hash ) {
	$( '#' + id + ' a' ).hide();
	$( '#' + id + ' a:first' ).before( '<div id="wait_' + id + '_' + hash +'">' + $( '#wait_block' ).html() + '</div>' );
	$.post( "/ajax/del_video/", { abbr: abbr, hash: hash }, function( data ) {
		if( data.error ) {
			$( '#wait_' + id + '_' + hash ).remove();
			$( '#' + id + ' a' ).show();
			alert( data.error );
		} else {
			$( '#' + id ).remove();
		}
	}, "json" );
}

function editYouTubeVideo( id, abbr, hash ) {
	$( '#youTubeForm' ).hide();
	$( '#editYouTubeForm' ).before( '<div align="center" id="wait_' + id + '_' + hash +'">' + $( '#wait_block' ).html() + '</div>' );
	$.post( "/ajax/get_video/", { abbr: abbr, hash: hash }, function( data ) {
		$( '#wait_' + id + '_' + hash ).remove();
		if( data.error ) {
			$( '#youTubeForm' ).show();
			alert( data.error );
		} else {
			$( '#modify_video_ss' ).attr( 'src', data.preview );
			$( '#video_edit_hash' ).val( hash );
			$( '#modify_video_info' ).val( data.desc );
			$( '#editYouTubeForm .char_count' ).html( data.desc.length );
			$( '#editYouTubeForm' ).show();
		}
	}, "json" );
}

function submitEditYouTubeForm( id ) {
	$( '#' + id ).ajaxForm({
		beforeSubmit: function(a,f,o) {
			$( '#' + id + ' input[type="button"]' ).attr( 'disabled', 'disabled' );
			$( '#' + id ).hide().before( '<div align="center" id="wait_edit_video">' + $( '#wait_block' ).html() + '</div>' );
		},
		success: function(data) {
			$( '#wait_edit_video' ).remove();
			if( data.error ) {
				alert( data.error );
			}
			$( '#youTubeForm' ).show();
			$( '#' + id + ' input[type="button"]' ).attr( 'disabled', '' );
			$( '#' + id ).trigger('reset');
		},
		dataType:  'json'
	});
	$( '#' + id ).submit();
}

function switchEditSoftTabs( obj, lang ) {
	$( '.form-lang-tab-area .form-lang-tab-active' ).attr( 'class', 'form-lang-tab' );
	$( obj ).attr( 'class', 'form-lang-tab-active' );
	$( '.form-content > .form-lang-tab-content-visible' ).attr( 'class', 'form-lang-tab-content' );
	$( '#soft_desc_' + lang ).attr( 'class', 'form-lang-tab-content-visible' );
}

function checkSybmolCount( value, tip_id, count ) {
	if( value.length > count ) {
		$( '#' + tip_id + ' > .char_count' ).attr( 'class', 'char_count_overflow' );
		$( '#' + tip_id + ' > .char_count_overflow' ).html( value.length );
	} else {
		$( '#' + tip_id + ' > .char_count_overflow' ).attr( 'class', 'char_count' );
		$( '#' + tip_id + ' > .char_count' ).html( ( ( value.length ) ? value.length : '0' ) );
	}
}

function switchRating( num ) {
	$( '#set_rating .active_star' ).attr( 'src', ImageRootURL + 'starNo.gif' );
	$( '#set_rating .active_star:lt(' + num + ')' ).attr( 'src', ImageRootURL + 'starYesRed.gif' );
}

function clearRating() {
	$( '#set_rating .active_star' ).attr( 'src', ImageRootURL + 'starNo.gif' );
}

function setRating( abbr, rating ) {
	if( $("#set_rating .active_star").attr( 'class' ) ) {
		$("#set_rating .active_star").attr( 'class', '' );
		$.post( "/ajax/add_rating/", { abbr: abbr, rating: rating }, function( data ) {
			if( data.error ) {
				alert( data.error );
			} else {
				//alert( data.rating );
			}
		}, "json" );
	} else {
		//$("#set_rating img").attr( 'class', 'active_star' );
	}
}

var AudioPlayer=function(){var F=[];var C;var E="";var A={};var D=-1;function B(G){return document.all?window[G]:document[G]}return{setup:function(H,G){E=H;A=G},getPlayer:function(G){return B(G)},embed:function(K,O){var I={};var M;var G;var P;var H;var N={};var J={};var L={};for(M in A){I[M]=A[M]}for(M in O){I[M]=O[M]}if(I.transparentpagebg=="yes"){N.bgcolor="#FFFFFF";N.wmode="transparent"}else{if(I.pagebg){N.bgcolor="#"+I.pagebg}N.wmode="opaque"}N.menu="false";for(M in I){if(M=="pagebg"||M=="width"||M=="transparentpagebg"){continue}J[M]=I[M]}L.name=K;L.style="outline: none";J.playerID=K;audioplayer_swfobject.embedSWF(E,K,I.width.toString(),"24","9",false,J,N,L);F.push(K)},syncVolumes:function(G,I){D=I;for(var H=0;H<F.length;H++){if(F[H]!=G){B(F[H]).setVolume(D)}}},activate:function(G){if(C&&C!=G){B(C).close()}C=G},load:function(I,G,J,H){B(I).load(G,J,H)},close:function(G){B(G).close();if(G==C){C=null}},open:function(G){B(G).open()},getVolume:function(G){return D}}}()
var audioplayer_swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in audioplayer_swfobject){audioplayer_swfobject[q]=null}audioplayer_swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();
var addthis_localize = {
	share_caption: "",
	email_caption: "",
	favorites: "",
	more: ""
}; 

$(document).ready(function(){
	step = 10;
	delay = 3000;
	start = 0;
	finish = 0;
	$( '.soft-details-screenshots-button-r' ).mouseout( function() {
			$( '#soft-details-screenshots-preview-content' ).stop()
		})
	.mouseover(function() { 
			fsh = parseInt( $( '#soft-details-screenshots-preview-content' ).width() ) - parseInt( $( '#soft-details-screenshots-preview-frame' ).width() ) + 10;
			if( finish < fsh ) finish = fsh;
			if( finish != 0 ) $( '#soft-details-screenshots-preview-content' ).animate( { marginLeft: -finish + 'px' }, delay * ( finish - parseInt( $( '#soft-details-screenshots-preview-content' ).css( 'marginLeft' ) ) ) / finish );
		});
		
	$( '.soft-details-screenshots-button-l' ).mouseout( function(){
			$( '#soft-details-screenshots-preview-content' ).stop()
		})
	.mouseover(function(){ 
			fsh = parseInt( $( '#soft-details-screenshots-preview-content' ).width() ) - parseInt( $( '#soft-details-screenshots-preview-frame' ).width() ) + 10;
			if( finish < fsh ) finish = fsh;
			if( finish != 0 ) $( '#soft-details-screenshots-preview-content' ).animate( { marginLeft: start + 'px'}, delay * ( (-1) * parseInt( $( '#soft-details-screenshots-preview-content' ).css( 'marginLeft' ) ) ) / finish );
	});
});

// Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
(function($) {
	/**
	 * $ is an alias to jQuery object
	 *
	 */
	$.fn.lightBox = function(settings) {
		// Settings to configure the jQuery lightBox plugin how you like
		settings = jQuery.extend({
			// Configuration related to overlay
			overlayBgColor: 		'#000',		// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
			overlayOpacity:			0.8,		// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
			// Configuration related to navigation
			fixedNavigation:		false,		// (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
			// Configuration related to img/slideshow
			imageLoading:			ImageRootURL + 'slideshow/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			ImageRootURL + 'slideshow/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
			imageBtnNext:			ImageRootURL + 'slideshow/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
			imageBtnClose:			ImageRootURL + 'slideshow/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:			ImageRootURL + 'slideshow/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
			// Configuration related to container image box
			containerBorderSize:	10,			// (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
			containerResizeSpeed:	400,		// (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
			// Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
			txtImage:				'Image',	// (string) Specify text "Image"
			txtOf:					'of',		// (string) Specify text "of"
			// Configuration related to keyboard navigation
			keyToClose:				'c',		// (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
			keyToPrev:				'p',		// (string) (p = previous) Letter to show the previous image
			keyToNext:				'n',		// (string) (n = next) Letter to show the next image.
			// Donґt alter these variables in any way
			imageArray:				[],
			activeImage:			0
		},settings);
		// Caching the jQuery object with all elements matched
		var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
		/**
		 * Initializing the plugin calling the start function
		 *
		 * @return boolean false
		 */
		function _initialize() {
			_start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
			return false; // Avoid the browser following the link
		}
		/**
		 * Start the jQuery lightBox plugin
		 *
		 * @param object objClicked The object (link) whick the user have clicked
		 * @param object jQueryMatchedObj The jQuery object with all elements matched
		 */
		function _start(objClicked,jQueryMatchedObj) {
			// Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'hidden' });
			// Call the function to create the markup structure; style some elements; assign events in some elements.
			_set_interface();
			// Unset total img/slideshow in imageArray
			settings.imageArray.length = 0;
			// Unset image active information
			settings.activeImage = 0;
			// We have an image set? Or just an image? Letґs see it.
			if ( jQueryMatchedObj.length == 1 ) {
				settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));
			} else {
				// Add an Array (as many as we have), with href and title atributes, inside the Array that storage the img/slideshow references		
				for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
					settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));
				}
			}
			while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {
				settings.activeImage++;
			}
			// Call the function that prepares image exibition
			_set_image_to_view();
		}
		/**
		 * Create the jQuery lightBox plugin interface
		 *
		 * The HTML markup will be like that:
			<div id="jquery-overlay"></div>
			<div id="jquery-lightbox">
				<div id="lightbox-container-image-box">
					<div id="lightbox-container-image">
						<img src="../fotos/XX.jpg" id="lightbox-image">
						<div id="lightbox-nav">
							<a href="#" id="lightbox-nav-btnPrev"></a>
							<a href="#" id="lightbox-nav-btnNext"></a>
						</div>
						<div id="lightbox-loading">
							<a href="#" id="lightbox-loading-link">
								<img src="../img/slideshow/lightbox-ico-loading.gif">
							</a>
						</div>
					</div>
				</div>
				<div id="lightbox-container-image-data-box">
					<div id="lightbox-container-image-data">
						<div id="lightbox-image-details">
							<span id="lightbox-image-details-caption"></span>
							<span id="lightbox-image-details-currentNumber"></span>
						</div>
						<div id="lightbox-secNav">
							<a href="#" id="lightbox-secNav-btnClose">
								<img src="../img/slideshow/lightbox-btn-close.gif">
							</a>
						</div>
					</div>
				</div>
			</div>
		 *
		 */
		function _set_interface() {
			// Apply the HTML markup into body tag
			$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');	
			// Get page sizes
			var arrPageSizes = ___getPageSize();
			// Style overlay and show it
			$('#jquery-overlay').css({
				backgroundColor:	settings.overlayBgColor,
				opacity:			settings.overlayOpacity,
				width:				arrPageSizes[0],
				height:				arrPageSizes[1]
			}).fadeIn(); 
			// Get page scroll
			var arrPageScroll = ___getPageScroll();
			// Calculate top and left offset for the jquery-lightbox div object and show it
			$('#jquery-lightbox').css({
				top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
				left:	arrPageScroll[0]
			}).show();
			// Assigning click events in elements to close overlay
			$('#jquery-overlay,#jquery-lightbox').click(function() {
				_finish();									
			});
			// Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
			$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
				_finish();
				return false;
			});
			// If window was resized, calculate the new overlay dimensions
			$(window).resize(function() {
				// Get page sizes
				var arrPageSizes = ___getPageSize();
				// Style overlay and show it
				$('#jquery-overlay').css({
					width:		arrPageSizes[0],
					height:		arrPageSizes[1]
				});
				// Get page scroll
				var arrPageScroll = ___getPageScroll();
				// Calculate top and left offset for the jquery-lightbox div object and show it
				$('#jquery-lightbox').css({
					top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
					left:	arrPageScroll[0]
				});
			});
		}
		/**
		 * Prepares image exibition; doing a imageґs preloader to calculate itґs size
		 *
		 */
		function _set_image_to_view() { // show the loading
			// Show the loading
			$('#lightbox-loading').show();
			if ( settings.fixedNavigation ) {
				$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
			} else {
				// Hide some elements
				$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
			}
			// Image preload process
			var objImagePreloader = new Image();
			objImagePreloader.onload = function() {
				$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
				// Perfomance an effect in the image container resizing it
				_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
				//	clear onLoad, IE behaves irratically with animated gifs otherwise
				objImagePreloader.onload=function(){};
			};
			objImagePreloader.src = settings.imageArray[settings.activeImage][0];
		};
		/**
		 * Perfomance an effect in the image container resizing it
		 *
		 * @param integer intImageWidth The imageґs width that will be showed
		 * @param integer intImageHeight The imageґs height that will be showed
		 */
		function _resize_container_image_box(intImageWidth,intImageHeight) {
			// Get current width and height
			var intCurrentWidth = $('#lightbox-container-image-box').width();
			var intCurrentHeight = $('#lightbox-container-image-box').height();
			// Get the width and height of the selected image plus the padding
			var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the imageґs width and the left and right padding value
			var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the imageґs height and the left and right padding value
			// Diferences
			var intDiffW = intCurrentWidth - intWidth;
			var intDiffH = intCurrentHeight - intHeight;
			// Perfomance the effect
			$('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },settings.containerResizeSpeed,function() { _show_image(); });
			if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {
				if ( $.browser.msie ) {
					___pause(250);
				} else {
					___pause(100);	
				}
			} 
			$('#lightbox-container-image-data-box').css({ width: intImageWidth });
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
		};
		/**
		 * Show the prepared image
		 *
		 */
		function _show_image() {
			$('#lightbox-loading').hide();
			$('#lightbox-image').fadeIn(function() {
				_show_image_data();
				_set_navigation();
			});
			_preload_neighbor_images();
		};
		/**
		 * Show the image information
		 *
		 */
		function _show_image_data() {
			$('#lightbox-container-image-data-box').slideDown('fast');
			$('#lightbox-image-details-caption').hide();
			if ( settings.imageArray[settings.activeImage][1] ) {
				$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
			}
			// If we have a image set, display 'Image X of X'
			if ( settings.imageArray.length > 1 ) {
				$('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + ( settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
			}		
		}
		/**
		 * Display the button navigations
		 *
		 */
		function _set_navigation() {
			$('#lightbox-nav').show();

			// Instead to define this configuration in CSS file, we define here. And itґs need to IE. Just.
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
			
			// Show the prev button, if not the first image in set
			if ( settings.activeImage != 0 ) {
				if ( settings.fixedNavigation ) {
					$('#lightbox-nav-btnPrev').css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' })
						.unbind()
						.bind('click',function() {
							settings.activeImage = settings.activeImage - 1;
							_set_image_to_view();
							return false;
						});
				} else {
					// Show the images button for Next buttons
					$('#lightbox-nav-btnPrev').unbind().hover(function() {
						$(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });
					},function() {
						$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
					}).show().bind('click',function() {
						settings.activeImage = settings.activeImage - 1;
						_set_image_to_view();
						return false;
					});
				}
			}
			
			// Show the next button, if not the last image in set
			if ( settings.activeImage != ( settings.imageArray.length -1 ) ) {
				if ( settings.fixedNavigation ) {
					$('#lightbox-nav-btnNext').css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' })
						.unbind()
						.bind('click',function() {
							settings.activeImage = settings.activeImage + 1;
							_set_image_to_view();
							return false;
						});
				} else {
					// Show the images button for Next buttons
					$('#lightbox-nav-btnNext').unbind().hover(function() {
						$(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });
					},function() {
						$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
					}).show().bind('click',function() {
						settings.activeImage = settings.activeImage + 1;
						_set_image_to_view();
						return false;
					});
				}
			}
			// Enable keyboard navigation
			_enable_keyboard_navigation();
		}
		/**
		 * Enable a support to keyboard navigation
		 *
		 */
		function _enable_keyboard_navigation() {
			$(document).keydown(function(objEvent) {
				_keyboard_action(objEvent);
			});
		}
		/**
		 * Disable the support to keyboard navigation
		 *
		 */
		function _disable_keyboard_navigation() {
			$(document).unbind();
		}
		/**
		 * Perform the keyboard actions
		 *
		 */
		function _keyboard_action(objEvent) {
			// To ie
			if ( objEvent == null ) {
				keycode = event.keyCode;
				escapeKey = 27;
			// To Mozilla
			} else {
				keycode = objEvent.keyCode;
				escapeKey = objEvent.DOM_VK_ESCAPE;
			}
			// Get the key in lower case form
			key = String.fromCharCode(keycode).toLowerCase();
			// Verify the keys to close the ligthBox
			if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {
				_finish();
			}
			// Verify the key to show the previous image
			if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {
				// If weґre not showing the first image, call the previous
				if ( settings.activeImage != 0 ) {
					settings.activeImage = settings.activeImage - 1;
					_set_image_to_view();
					_disable_keyboard_navigation();
				}
			}
			// Verify the key to show the next image
			if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {
				// If weґre not showing the last image, call the next
				if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) {
					settings.activeImage = settings.activeImage + 1;
					_set_image_to_view();
					_disable_keyboard_navigation();
				}
			}
		}
		/**
		 * Preload prev and next images being showed
		 *
		 */
		function _preload_neighbor_images() {
			if ( (settings.imageArray.length -1) > settings.activeImage ) {
				objNext = new Image();
				objNext.src = settings.imageArray[settings.activeImage + 1][0];
			}
			if ( settings.activeImage > 0 ) {
				objPrev = new Image();
				objPrev.src = settings.imageArray[settings.activeImage -1][0];
			}
		}
		/**
		 * Remove jQuery lightBox plugin HTML markup
		 *
		 */
		function _finish() {
			$('#jquery-lightbox').remove();
			$('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
			// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'visible' });
		}
		/**
		 / THIRD FUNCTION
		 * getPageSize() by quirksmode.com
		 *
		 * @return Array Return an array with page width, height and window width, height
		 */
		function ___getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};
		/**
		 / THIRD FUNCTION
		 * getPageScroll() by quirksmode.com
		 *
		 * @return Array Return an array with x,y page scroll values.
		 */
		function ___getPageScroll() {
			var xScroll, yScroll;
			if (self.pageYOffset) {
				yScroll = self.pageYOffset;
				xScroll = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
				yScroll = document.documentElement.scrollTop;
				xScroll = document.documentElement.scrollLeft;
			} else if (document.body) {// all other Explorers
				yScroll = document.body.scrollTop;
				xScroll = document.body.scrollLeft;	
			}
			arrayPageScroll = new Array(xScroll,yScroll);
			return arrayPageScroll;
		};
		 /**
		  * Stop the code execution from a escified time in milisecond
		  *
		  */
		 function ___pause(ms) {
			var date = new Date(); 
			curDate = null;
			do { var curDate = new Date(); }
			while ( curDate - date < ms);
		 };
		// Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
		return this.unbind('click').click(_initialize);
	};
})(jQuery); // Call and execute the function immediately passing the jQuery object

// Bump text
/*
$(document).ready(function(){
$('.shadowed').each(function(){
$(this).textDropShadow('shadow')
});
});
(function($) {
$.fn.textDropShadow = function(ShdwClass){
$(this).css('position','relative').html('<span class='+ShdwClass+'>'+$(this).html()+'</span><span style="position:relative;">'+$(this).html()+'</span>');
return $(this);
}
})(jQuery);
*/
// Accordion
$(document).ready(function()
{
	//slides the element with class "menu_body" when paragraph with class "menu_head" is clicked 
	$("#firstpane div.accordion_head").click(function()
    {
		$(this).css({backgroundImage:"url(down.png)"}).next("div.accordion_body").slideToggle(300);
       	$(this).siblings().css({backgroundImage:"url(left.png)"});
	});
	//slides the element with class "menu_body" when mouse is over the paragraph
	$("#secondpane div.accordion_head").mouseover(function()
    {
	     $(this).css({backgroundImage:"url(down.png)"}).next("div.accordion_body").slideDown(500).siblings("div.accordion_body").slideUp("slow");
         $(this).siblings().css({backgroundImage:"url(left.png)"});
	});
});
//Close-Open
function closeOpen(t) {
	var $obj = $(t);
	if($obj.hasClass('accordionTitleOpen')){
		$obj.removeClass('accordionTitleOpen');
	}else{
		$obj.addClass('accordionTitleOpen');
	}
}

function screenWidth(){
if(window.innerWidth){
width = window.innerWidth;
} else if(document.documentElement && document.documentElement.clientWidth){
width = document.documentElement.clientWidth;
} else if(document.body && document.body.clientWidth){
width = document.body.clientWidth;
}
return width;
}
function setScreenImgWidth() {
document.getElementById("scroll_independence").style.width = ( ( screenWidth( ) ) - 25)+"px";
if( typeof( as ) != "undefined" ) {moveadvancedsearch();}
}
